<< 16-05-2023 >>

00:09:59FromDiscord<huantian> Hey beef you should add a trm to slicerator that detects toSeq/map/filter usage that could be written with your iterator stuffs
00:10:38FromDiscord<Elegantbeef> What does that solve?
00:10:49FromDiscord<Elegantbeef> If you import my module you get the performance benefit
00:11:27FromDiscord<Elegantbeef> Atleast with itermacros
00:13:53FromDiscord<Elegantbeef> Assuming i get all the sequtils templates inside `itermacros` you can just replace all `sequtils` usage with my macros
00:15:23FromDiscord<huantian> Huh yeah ig
00:23:06FromDiscord<Elegantbeef> The real nice part is `var a = theVal.items.enumerate.filterIt(it[0] > 30).collect` just works
00:25:08FromDiscord<Elegantbeef> That slight hack really gives us so much more flexibility in iterators
01:13:52*nanxiao joined #nim
01:17:01FromDiscord<etra> In reply to @jmgomez "are you building a": maybe unrelated but, I've heard the term DSL multiple times and I know what the letters means, but do you know of any examples? either in Nim or well, I've mostly heard it from Ruby people
01:21:19FromDiscord<Elegantbeef> https://github.com/zevv/npeg↵https://nim-lang.org/docs/strscans.html↵https://github.com/can-lehmann/owlkettle
01:29:14*derpydoo joined #nim
01:33:06FromDiscord<ranok (Jacob Torrey)> Any tips for handling async JS calls in Nim? I pass a cb proc, but now how do I await it
01:57:07FromDiscord<sOkam!> In reply to @etra "maybe unrelated but, I've": owlkettle is probably a great nim example on what dsl is
01:57:32FromDiscord<sOkam!> essentially, you create a mini language to describe the funtionality that you want
01:57:47FromDiscord<sOkam!> nim metaprogramming is perfect for it, which is what owlkettle does
01:58:42FromDiscord<JJ> In reply to @etra "maybe unrelated but, I've": racket is well-known for ridiculous examples
02:04:14FromDiscord<JJ> sent a long message, see http://ix.io/4vVd
02:04:32FromDiscord<JJ> actually, i'm unsure if scribble is a dsl, i haven't used it
02:28:13*azimut_ joined #nim
02:30:08*azimut quit (Ping timeout: 240 seconds)
03:03:27*nanxiao quit (Quit: Client closed)
03:14:22*nanxiao joined #nim
03:24:51FromDiscord<etra> thanks for all the examples, now it's pretty clear to me what a DSL is 🙂
03:33:52FromDiscord<michaelb.eth> In reply to @apropos "actually, i'm unsure if": scribble is a DSL that's a bit like markdown on super-steriods
03:33:56FromDiscord<michaelb.eth> (edit) "super-steriods" => "super-steroids"
03:34:25FromDiscord<michaelb.eth> https://docs.racket-lang.org/scribble/getting-started.html
03:36:10FromDiscord<michaelb.eth> It's been years since I played with it, but I was disappointed at the time to find that the implementation was very closely tied to the main use case, which is generating docs for Racket itself and Racket libraries. I had hoped it would be more extensible, as I wanted to use it for something else. It may have evolved since then, though.
03:57:32FromDiscord<voidwalker> any idea why compiler wouldn't pick up on an overloaded function variant ?
03:57:43FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vVN
03:59:30FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vVO
04:03:11FromDiscord<that_dude> The error should show each func. Is there something that could cause the second one to be missing?
04:03:12FromDiscord<Elegantbeef> Are you importing this module directly?
04:03:22FromDiscord<voidwalker> `import ./piece`
04:03:51FromDiscord<Elegantbeef> And it's definedi n `piece`?
04:04:14FromDiscord<voidwalker> indeed
04:04:19FromDiscord<that_dude> Kinda obvious question, but the file has been saved before compilation right?
04:04:41FromDiscord<voidwalker> yes, restart vscode a few times.. wanted to try nim stable but I already changed my code to use std/paths which is not in stable :\
04:05:30FromDiscord<Elegantbeef> Well i'm internally saying you're lying to me
04:08:47FromDiscord<Elegantbeef> I'll say throw it on a branch if you want another set of eyes
04:10:39FromDiscord<voidwalker> https://media.discordapp.net/attachments/371759389889003532/1107882784153944104/simplescreenrecorder-2023-05-16_07.09.04.mkv
04:11:50FromDiscord<Elegantbeef> Is that async proc a generic?
04:13:09FromDiscord<voidwalker> just an async proc
04:13:33FromDiscord<Elegantbeef> Well I cannot say much without being able to reproduce so if it's not generic i'm lost
04:17:07FromDiscord<voidwalker> shall I update it on github ?
04:17:20FromDiscord<voidwalker> will you look at it I mean
04:17:21FromDiscord<Elegantbeef> If you want another set of eyes
04:19:52FromDiscord<Rika> takes your eyeballs
04:20:50FromDiscord<voidwalker> https://github.com/sgmihai/torrentim/tree/master
04:22:55FromDiscord<voidwalker> welp, try again, forgot to de-ignore test torrents folder, although this is compile time error so it shouldn't matter
04:24:10FromDiscord<Elegantbeef> Really need to setup an nimble file
04:24:38FromDiscord<voidwalker> I did
04:24:48FromDiscord<voidwalker> https://github.com/sgmihai/torrentim/blob/master/torrentim.nimble
04:25:10FromDiscord<voidwalker> Not sure how proper it is, I need to update it with nim version requirement
04:26:17FromDiscord<Elegantbeef> You have main and master branches 😄
04:26:32FromDiscord<voidwalker> `requires "nim >= 1.9.3"`
04:26:59FromDiscord<voidwalker> Yeah idk anything about those and how it works, I am confused by git things ;\
04:27:00FromDiscord<Elegantbeef> Uh huh
04:27:12FromDiscord<Elegantbeef> `types.nim(27, 33) Error: undeclared identifier: 'BencodeObj'`
04:27:29FromDiscord<voidwalker> requires "https://github.com/z-------------/nim-bencode#head"
04:27:47FromDiscord<Elegantbeef> I did `nimble install -d`
04:27:52FromDiscord<Elegantbeef> So i have bencode
04:27:55FromDiscord<Elegantbeef> But i now see the issue
04:27:56FromDiscord<Elegantbeef> It's on me
04:29:27FromDiscord<Elegantbeef> You modified a library and didnt use a fork to depend on 😄
04:29:41FromDiscord<Elegantbeef> `privateAccess` from `importutils` probably is what you want
04:29:46FromDiscord<Elegantbeef> or `{.all.}`
04:30:49FromDiscord<voidwalker> oh shit I think I did.. bitVector
04:31:08FromDiscord<Elegantbeef> Or just PR into bitvector a `dataAddr` proc 😄
04:31:08FromDiscord<voidwalker> #hack - BitVector.Base is not exported, I modified the file manually to export it. See if there is any workaround to this.
04:31:09FromDiscord<voidwalker> lmao
04:31:50FromDiscord<Elegantbeef> Ok now we're on the same page
04:32:23FromDiscord<voidwalker> I should put that lib in the project's folder I guess then ? Or make my fork on github and depend on that
04:32:37FromDiscord<Elegantbeef> `files2PiecesMap` vs. `files2PieceMap`
04:32:39FromDiscord<Elegantbeef> We're both blind
04:33:24FromDiscord<voidwalker> omfg
04:33:34FromDiscord<voidwalker> how does that compile though
04:33:42FromDiscord<Vincent Kadar> !!! Enjoy the most profitable financial market (crypto market ) as you get 100% profit...and you can also make up to $100k or more in 3days send me a private message and ask me HOW on TGhttps://t.me/VincentKadar
04:34:04FromDiscord<Elegantbeef> `BitVector` is a generic
04:34:09FromDiscord<Elegantbeef> You didnt give it a generic argument
04:34:14FromDiscord<that_dude> <@&371760044473319454> Clasic
04:35:03FromDiscord<voidwalker> so that makes it compile ?
04:35:17FromDiscord<voidwalker> even though there is no " files2PiecesMap(t.files, t.filesWanted, t.pieceSize, t.numPieces)" proc definition anywhere
04:35:25FromDiscord<Elegantbeef> You used the proc internally
04:36:19FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vVX
04:36:24FromDiscord<Elegantbeef> This does not error cause `MyType` is not concrete
04:36:32FromDiscord<Elegantbeef> Though it's not usable
04:36:37FromDiscord<Elegantbeef> So this is a compiler bug
04:36:46*nanxiao quit (Quit: Client closed)
04:37:11FromDiscord<voidwalker> I guess it's debateable if a bug or design
04:37:20FromDiscord<Elegantbeef> Well it's design but accidental bug
04:39:02FromDiscord<Elegantbeef> It's the mixin logic kicking in properly but for an unusable proc
04:42:50FromDiscord<Elegantbeef> Man docker really makes me feel like an idiot, I just want to copy a file after I build it to my host machine
04:52:06FromDiscord<wick3dr0se> Well if you ever need scripting help, I'm here
05:08:19NimEventerNew thread by JohnAD: Macro compile-time comparison with define-pragmas, see https://forum.nim-lang.org/t/10199
05:17:03*rockcavera quit (Remote host closed the connection)
05:32:26FromDiscord<michaelb.eth> In reply to @voidwalker "Yeah idk anything about": free online book, it's quite good and pretty easy to work through: https://git-scm.com/book/en/v2
05:33:46FromDiscord<voidwalker> 500 page book.. yeah, very encouraging
05:39:09FromDiscord<michaelb.eth> Git Basics and Git Branching chapters would get you a pretty long way
05:40:15FromDiscord<michaelb.eth> (edit) "chapters" => "sections"
05:48:02FromDiscord<Arathanis> why is `M..<N` unusable in so many places where `M..N` is usable?
05:49:27FromDiscord<Elegantbeef> Cause `..<` is a template for a slice
05:49:46FromDiscord<Arathanis> No way around it?
05:50:12FromDiscord<Elegantbeef> `..<` is in userspace
05:50:34FromDiscord<Elegantbeef> `..` is both a type language syntax and user space slice
05:51:39FromDiscord<Arathanis> so `..` is part of a type definition, and `..<` is a template?
05:52:28FromDiscord<Elegantbeef> Right `..` is the only thing that exists in the type language
05:53:08FromDiscord<Arathanis> got it, so when instantiating a set for example, you have to have an Ordinal type in the square brackets and `..<` is not a type.
05:53:40FromDiscord<Arathanis> I suppose I assumed a template would rewrite to the appropriate type but I am guessing the square brackets on a set are not evaluated at that stage, they are evaluated earlier'
05:53:41FromDiscord<Elegantbeef> Yea
05:53:42FromDiscord<Arathanis> which is why this fails
05:55:17FromDiscord<Elegantbeef> Well `..` in type language is hard coded and defined as a range
06:09:20*azimut_ quit (Ping timeout: 240 seconds)
06:21:52*PMunch joined #nim
06:44:54*nanxiao joined #nim
06:57:19*Notxor joined #nim
08:12:43FromDiscord<voidwalker> not possible to provide a default type for a generic type parameter?
08:14:57PMunchhttps://play.nim-lang.org/#ix=4vWt
08:15:08PMunchSeems to work fine voidwalker
08:15:49FromDiscord<voidwalker> hm I guess I was not very clear
08:16:26FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vWu
08:16:32FromDiscord<voidwalker> and to my surprise this compiles, so maybe the answer is yes
08:16:51FromDiscord<Rika> Why does there need to be a default type?
08:17:02FromDiscord<Rika> What does it bring in terms of functionality
08:17:33FromDiscord<voidwalker> well I am trying to write a bit array library by stealing from all the existing ones
08:18:20FromDiscord<voidwalker> And it would be nice not to need to specify integer unit base type, since it will be uint most of the times
08:18:34FromDiscord<voidwalker> while also allowing specifying other types, for whatever reason I can't think of now
08:19:22PMunchOften you'd have a deeper implementation type, and then just have your BitArray type be a specialized version of that using uint
08:19:56FromDiscord<Rika> I was thinking that’s not exactly an issue of generics
08:21:31FromDiscord<voidwalker> Not exactly sure I get what you mean PMunch.. example ? 🙂
08:24:02PMunchSomething like this: https://play.nim-lang.org/#ix=4vWv
08:25:34FromDiscord<voidwalker> BitVecSImpl[S: static int, B: SomeUnsignedInt = uint] = object # whatever your definition is here↵ BitVecS[S: static int] = BitVecSImpl[S] # This is now a specialized alias
08:26:04PMunchDid you just paste back my sample to me?
08:26:20FromDiscord<voidwalker> no, I put the default type parameter in there
08:26:33PMunchBut you just said that that didn't work?
08:26:36PMunchI'm confused
08:26:49FromDiscord<voidwalker> It does work, at least it compiles
08:27:08FromDiscord<voidwalker> I read a stackoverflow answer that it doesn't, from 2021, maybe it got implemented in 1.9
08:27:57FromDiscord<voidwalker> works in 1.6 as well
08:29:49*nanxiao quit (Ping timeout: 245 seconds)
08:30:40FromDiscord<N00nehere> how can i use nim with aws lambda?
08:37:49PMunchSame way you'd use AWS Lambda in any language I assume
08:37:55PMunchOr you could try a package: https://github.com/lambci/awslambda.nim
09:08:17FromDiscord<voidwalker> sent a code paste, see https://paste.rs/rXm
09:08:36FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4vWE" => "https://play.nim-lang.org/#ix=4vWD"
09:08:54FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4vWD" => "https://play.nim-lang.org/#ix=4vWF"
09:09:12FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4vWF" => "https://play.nim-lang.org/#ix=4vWG"
09:09:51FromDiscord<voidwalker> I am wondering why the author chose to do that here: https://github.com/JorySchossau/bitset/blob/main/src/bitset.nim#LL9C16-L9C51
09:09:59*nanxiao joined #nim
09:13:47FromDiscord<Elegantbeef> https://godbolt.org/z/T6Yfhnd4x
09:16:20FromDiscord<voidwalker> nice
09:21:41FromDiscord<voidwalker> @ElegantBeef https://play.nim-lang.org/#ix=4vWJ does this look right ?
09:23:17FromDiscord<Elegantbeef> Nope
09:23:27FromDiscord<Elegantbeef> Generics cannot have default types
09:23:55FromDiscord<voidwalker> says who ?
09:24:07FromDiscord<Elegantbeef> The compiler
09:24:07FromDiscord<voidwalker> the code appears to work correctly
09:24:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vWL
09:25:33*nanxiao quit (Quit: Client closed)
09:26:45FromDiscord<voidwalker> then how come this works ? https://play.nim-lang.org/#ix=4vWO
09:28:17FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vWQ
09:29:45FromDiscord<Elegantbeef> Compiler bug that works in your favour
09:29:55FromDiscord<voidwalker> I'd say that's a feature
09:31:58FromDiscord<Elegantbeef> It's not intended so it's a bug
09:32:09FromDiscord<voidwalker> Well if it works correctly then it's a feature : D
09:32:17FromDiscord<voidwalker> an accidental feature ?
09:35:28FromDiscord<voidwalker> Is it because of using SomeUnsignedInt type class ?
09:36:56FromDiscord<voidwalker> well, anyways, it works so I don't complain. besides that, are there any improvements that could be done ?
09:49:11FromDiscord<Rika> In reply to @voidwalker "well, anyways, it works": Are you sure it will work for every case or are you just assuming
09:49:42FromDiscord<Rika> You will, will, will encounter weird behaviour in accepting something like that as “okay it works that’s the end of it”
09:52:28FromDiscord<voidwalker> Obviously I am assuming, and there's just 4 cases here, all uints, for which I tested and it works (apparently)
09:53:15FromDiscord<demotomohiro> sent a code paste, see https://paste.rs/IZI
09:53:39FromDiscord<voidwalker> well, it's supposed to be the size of an array, what does a -9 size array mean hmm
09:55:03FromDiscord<voidwalker> I was pondering if it's worth to write each uint size in bit operations instead of div/mod, but in this case the size of the array is compile time known and computed, so it makes no difference for the speed of the program
09:55:13FromDiscord<voidwalker> (edit) "I was pondering if it's worth to write ... each" added "for"
10:00:31FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4vWW
10:14:15Amun-Rais there a way for this to work: https://play.nim-lang.org/#ix=4vX0
10:24:25FromDiscord<voidwalker> use let or var instead of const
10:35:04FromDiscord<chmod222> I think I already know the answer ("no"), but is it possible to modify the value of a global `const` or does Nim reserve the right to copy-paste `const`s like C #defines?
10:35:52FromDiscord<chmod222> Reason I'm asking is, my API definition contains a bunch of consts that are obviously const in a semantic sense, but I do have to query the actual const values from the API first, which can only be done on module load time
10:35:55PMunchchmod222§, the answer is no. If you want a compile-time variable you can edit you can use `var myThing: string {.compileTime.}`
10:36:23FromDiscord<chmod222> Not compile time as well sadly, if I knew the value at compile time I could just write them through the macro that's generating the code
10:36:44PMunchSo you just need a runtime variable?
10:37:05FromDiscord<chmod222> It's a proper constant for the application loading my library as a shared library, but my shared library can only ask the host application for that consts value once loaded at runtime
10:37:46FromDiscord<chmod222> Semantically it's a const but for technical reasons it has to be a "set once and never modified ever again in this runtime" thing
10:37:56PMunchSo a `let`?
10:38:12FromDiscord<chmod222> That'd be my next best option
10:38:17Amun-Ravoidwalker: hmm, yes, it works with let; I would have to check how that looks like in C code
10:38:34PMunchchmod222, that'd be your only option :P
10:38:41FromDiscord<chmod222> I assume `addr` of a let is a necessary evil
10:39:00FromDiscord<chmod222> I really don't want to expose my const as a var
10:39:00PMunch`addr` of let is still invalid isn't it?
10:39:10PMunchIt at least used to be called `unsafeAddr`
10:39:14FromDiscord<chmod222> Well it's about to be made valid in nim 2
10:39:20PMunchRight
10:39:22FromDiscord<chmod222> for now it's `unsafeAddr`
10:39:27FromDiscord<sOkam!> it will be available on devel afaik. in stable you can use unsafe
10:39:36FromDiscord<chmod222> But I live on the bleeding edge
10:39:40PMunchWell using `addr` should never be considered safe
10:39:40FromDiscord<chmod222> I care not for stable
10:40:09FromDiscord<chmod222> True
10:40:18FromDiscord<chmod222> But I'm already dealing with FFI so properly safe is out the window
10:41:02*derpydoo quit (Quit: derpydoo)
10:41:16PMunchFair enough
10:41:26PMunchI use a bunch of `addr` for my Gtk stuff :P
10:41:31FromDiscord<chmod222> The annoying thing is that the API json I'm expanding into code already contains the const values, but they are in C++ notation and I'd have to parse it, which is even more painful
10:42:02*jmdaemon quit (Ping timeout: 246 seconds)
10:42:20PMunchC++ notation?
10:42:30FromDiscord<chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4vX4
10:42:40PMunchA simple const might be possible to feed through c2nim
10:44:01FromDiscord<chmod222> True, but then I'd have to actually replicate the type as C++ so the generated constructor binding works, which is another can of worms
10:44:20FromDiscord<chmod222> I'd rather generate the types as proper nim types since the boundary only deals in pointers anyways
10:45:23FromDiscord<chmod222> It's fine, I can deal with `let` consts
10:47:04FromDiscord<voidwalker> Can someone explain why this doesn't work: https://play.nim-lang.org/#ix=4vX5 - while the commented line variant works fine ?
10:51:18FromDiscord<Rika> Because you forgot to bind the generic parameters on the any types?
10:54:17FromDiscord<Piko> when the compiler throws an error in some module I haven't imported, how can I know what module is importing it? or what macro is generating that code or something
10:57:56FromDiscord<voidwalker> ohhh ok, thanks Rika. First time working with type aliases, only did generics once
10:58:32FromDiscord<voidwalker> (edit) "aliases," => "classes,"
11:00:50FromDiscord<Piko> specifically, I'm getting↵`[...]/nim-1.6.12/lib/pure/nativesockets.nim(365, 22) Error: undeclared identifier: 'cstringArrayToSeq'`↵when using the js backend, and I have no idea why, no traceback, etc...
11:01:39FromDiscord<Piko> (exactly the same problem with nim devel)
11:03:13FromDiscord<demotomohiro> Is `nativesockets` module supports js backend?
11:05:13FromDiscord<Piko> I don't think so, but I'm not using it!! that's why I'm stumped
11:05:58FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4vXc
11:07:27FromDiscord<chmod222> Well, `Vector2i` gets generated to ` Vector2i = object x: int32 y: int32` and I'd have to create a function called `proc Vector2i(...)` to replicate the constructor and that's much more annoying than swapping `const` for `let`
11:08:12FromDiscord<chmod222> All these objects have multiple constructors with various overloads but they can only be called at runtime because it goes through the godot API FFI interface
11:08:21FromDiscord<chmod222> So it cannot be a const even then
11:08:37FromDiscord<chmod222> I'd have to "guess" which parameter of the constant belongs to which field
11:08:59FromDiscord<demotomohiro> In reply to @Piko "I don't think so,": `--verbosity:2` compiler option might provide more info.
11:10:05FromDiscord<Piko> In reply to @demotomohiro "`--verbosity:2` compiler option might": it only adds:↵`/home/runner/work/nightlies/nightlies/nim-1.9.3/compiler/lookups.nim(558, 13) compiler msg initiated here [MsgOrigin]`
11:10:32FromDiscord<Piko> oh wait it added more things, hold on
11:10:58FromDiscord<Piko> no, just "added path ..."
11:11:03FromDiscord<demotomohiro> `--verbosity:3` provides more info and more noise.
11:11:19FromDiscord<jmgomez> chmod, hmm I thought you were at compile time, arent you? You want to generate Nim code that has the shape of the bindings, right? You can create a macro that gives you your const from that json
11:11:36FromDiscord<jmgomez> No need for for FFI if you already know the value
11:11:50FromDiscord<chmod222> Yes but the value is in a mostly unusable format
11:12:18FromDiscord<jmgomez> why is that? The sample you proposed is quite usable
11:12:36FromDiscord<chmod222> I don't have access to the "actual" constructor that is called in the string because it's C++ and I'm not binding to C++ where the constructor itself would be available
11:13:04FromDiscord<jmgomez> You dont need access to it, you just need to match the final result in memory
11:13:24FromDiscord<chmod222> The constructor I need to call at runtime is "globalGdInterfacePtr.variant\_get\_ptr\_constructor(5)(&args)"
11:14:38FromDiscord<chmod222> That's what I'm doing by reifying the API into the object, but how do I go from the String "Vector2i(0, 1)" to create an "Vector2i = object x\: int, y\: int"
11:14:51FromDiscord<jmgomez> I dont know, sounds too convoluted. If it helps, in NimForUE I have two kind of types, the actual real cpp type for what's in the PCH and a mirror type that is only compatible at the memory level
11:14:51FromDiscord<Piko> so I disabled all code, separated imports into their own lines and enabled one by one... I get the error with chronos (but also with asyncdispatch) ... how can I use JS async/await with nim?
11:15:16FromDiscord<chmod222> The constructors are overloaded so I cannot simply map parameter 0 to field 0
11:15:40FromDiscord<jmgomez> What Im trying to say is are you sure you need to use the constructor?
11:15:41FromDiscord<Rika> In reply to @Piko "so I disabled all": Use https://nim-lang.org/docs/asyncjs.html
11:16:07FromDiscord<chmod222> I don't need the constructor for the simplest cases, no
11:16:07FromDiscord<Piko> In reply to @Rika "Use https://nim-lang.org/docs/asyncjs.html": ah thanks
11:16:19FromDiscord<chmod222> If you only want to set the fields, you can do that because I replicate the memory layout
11:16:28FromDiscord<chmod222> But there are multiple ctors
11:16:47FromDiscord<chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4vXd
11:17:18FromDiscord<chmod222> And the constants in the json can use any format
11:19:05FromDiscord<chmod222> And yes, you can absolutely set x and y yourself (if the fields are exported in the API, that is, not all types do), but it wouldn't be a good autogenerated API if I don't auto generate all APIs
11:21:38FromDiscord<jmgomez> Not sure how "all APIs" look in Godot but you can just have `makeVector2i` in regular nim with all overloads and someone that uses Nim and Godot will see the equivalence
11:22:28FromDiscord<chmod222> That's pretty much what this above is, except `Vector2i.init` rather than `makeVector2i`, the overloads work in either case
11:22:58FromDiscord<chmod222> But to make the `"Vector2i(0, -1)"` exported constant work, I'd have to generate `proc Vector2i` which doesn't fit into the Nim style
11:23:16FromDiscord<chmod222> Or I'd generate both styles and have duplication
11:23:29FromDiscord<chmod222> Or muddle with the string...
11:23:32FromDiscord<chmod222> well
11:23:39FromDiscord<chmod222> Now that I think of it
11:23:46FromDiscord<jmgomez> You just need to parse it in macro time and assign the value
11:24:12FromDiscord<chmod222> Maybe I can just `konst.replace(selfType, selfType & ".init")`
11:26:16FromDiscord<voidwalker> How expensive is it to call `T.sizeof` in a generic proc ? vs using a literal
11:27:03FromDiscord<Rika> It is compile time calculated though
11:27:17FromDiscord<voidwalker> `proc sizeof[T](x: T): int {.magic: "SizeOf", noSideEffect.}`
11:27:39FromDiscord<voidwalker> so it's as good as a numeric literal ?
11:27:53FromDiscord<Rika> Pretty much
11:29:48*Guest28 joined #nim
11:31:44FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4vXh
11:34:12FromDiscord<voidwalker> @System64 ~ Flandre Scarlet seems to work in nim-devel, but not in nim-stable
11:34:20*Guest28 quit (Client Quit)
11:34:26FromDiscord<voidwalker> (edit) "@System64 ~ Flandre Scarlet seems to work ... in" added "(compiles)"
11:36:12FromDiscord<System64 ~ Flandre Scarlet> Ah alright
11:42:06FromDiscord<Chronos [She/Her]> WASM library system might be interesting to implement... But a PAIN to actually use lmao, would need a ton of stubs
11:42:19FromDiscord<Chronos [She/Her]> Also no real use for it ig?
11:42:28FromDiscord<voidwalker> whaaat is the deaaal with waaasm
11:43:01FromDiscord<Chronos [She/Her]> Sandboxed environment that allows freedom of languages you can use, I'm gonna be using it in my MC server impl for the plugin system
11:43:33FromDiscord<Chronos [She/Her]> This way I can minimize the risks of someone blindly installing a malicious plugin
11:43:45FromDiscord<voidwalker> Minecraft?
11:43:56FromDiscord<Chronos [She/Her]> Yeah aha
11:44:04FromDiscord<voidwalker> whaaat is the deaaal with minecraft ?
11:44:23FromDiscord<Chronos [She/Her]> My favourite game xD
11:44:28FromDiscord<voidwalker> sanboxed environment in a sandbox game.. nice
11:44:38FromDiscord<voidwalker> where you can sanbox a nes emulator
11:44:57FromDiscord<Chronos [She/Her]> If the NES emulator is small enough probably could work xD
12:10:17FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vXw
12:10:24FromDiscord<voidwalker> any idea why I have to write return before the last expression for it to work ?
12:10:44FromDiscord<voidwalker> oh nvm, it's not the (potentially) last line in the proc
12:11:00FromDiscord<voidwalker> even though logically it is : )
12:15:15FromDiscord<Chronos [She/Her]> Is `runForever` blocking?
12:16:02FromDiscord<Chronos [She/Her]> Also if the `while true` block is already in the function, why is runForever needed?
12:16:08FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4vXz
12:28:31FromDiscord<voidwalker> well if you know your async proc should never stop, you can also use waitFor
12:28:43FromDiscord<voidwalker> and yes, of course it is blocking
12:29:26FromDiscord<voidwalker> https://github.com/nim-lang/Nim/blob/f222625b17f90238cf7a31fec2d1b31447b6cd22/lib/pure/asyncdispatch.nim#L1953
12:32:53FromDiscord<Duskhorn The Eclipsed> In reply to @Elegantbeef "<@786958459878637589> just remember I": Yes! It was me misunderstanding how to use generics in concepts
13:26:10om3gadouble free or corruption (!prev)
13:27:03om3galooks like using `=destroy`(.. ) was not the best idea
13:30:29*progranner joined #nim
13:34:24FromDiscord<voidwalker> can someone explain to me what's going on here ? https://godbolt.org/z/xnvrz8bb8
13:34:38FromDiscord<voidwalker> (edit) "can someone explain to me what's going on here ? ... https://godbolt.org/z/xnvrz8bb8" added "test1 vs test2 procs"
13:35:27FromDiscord<voidwalker> Obviously the compiler does some optimisation, but one proc has one less shl, and a data16, whatever that is. Which is better ?
13:35:40FromDiscord<voidwalker> (edit) "a" => "an extra"
13:35:44*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
13:37:11*progranner joined #nim
13:52:36FromDiscord<demotomohiro> In reply to @voidwalker "can someone explain to": Measure speed correctly.↵Less instruction does not always mean faster code.↵Modern CPU do out of order execution, instruction level parallelism, register renaming etc.
13:52:59FromDiscord<voidwalker> Ok, I will do a 1 gazillion element benchmark when I finish
13:54:17*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
13:55:33FromDiscord<demotomohiro> On modern PC, memory access or IO is slower than speed of CPU.↵Such optimization might not make difference if your program is IO bound or memory bound.
13:58:20FromDiscord<voidwalker> When writing a general purpose public library, it is best to try your best to optimise
13:59:16*progranner joined #nim
14:09:36NimEventerNew thread by alexeypetrushin: Get type of code block in template?, see https://forum.nim-lang.org/t/10200
14:12:21FromDiscord<System64 ~ Flandre Scarlet> Is it possible to init a value type as reference type?
14:12:52*PMunch quit (Quit: Leaving)
14:13:34FromDiscord<voidwalker> what do you mean ?
14:14:26FromDiscord<System64 ~ Flandre Scarlet> instanciate on the heap
14:15:25FromDiscord<demotomohiro> Just add `ref` to type name like `ref array[2, int]`.
14:16:16FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4vXZ
14:16:38FromDiscord<demotomohiro> yes
14:17:12FromDiscord<System64 ~ Flandre Scarlet> https://media.discordapp.net/attachments/371759389889003532/1108035425383239730/image.png
14:18:33NimEventerNew Nimble package! sha256_64B - sha256 hash of batches of 64B blocks in parallel via pure asm lib hashtree, see https://github.com/status-im/sha256_64B
14:19:06*azimut joined #nim
14:19:30FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4vY2
14:19:39FromDiscord<Rika> but also that new Type thing you do is already making refs no?
14:22:10FromDiscord<System64 ~ Flandre Scarlet> not sure↵But why between parenthesis? Is that a cast?
14:24:11*Notxor quit (Quit: Leaving)
14:37:43FromDiscord<Rika> no, i dont exactly know why the parentheses are needed but it might be related to parsing
14:50:19FromDiscord<JeanCareau> sent a long message, see http://ix.io/4vY9
14:52:53FromDiscord<Chronos [She/Her]> I need to set up a simple environment now for my plugin system, that's a pain lol
14:55:08*lucasta joined #nim
15:12:08FromDiscord<Chronos [She/Her]> And a decent event handler system f
15:12:14FromDiscord<Chronos [She/Her]> Generics time
15:18:09FromDiscord<michaelb.eth> In reply to @JeanCareau "I get some fields": What OS are you using?
15:22:21*krux02 joined #nim
15:27:39FromDiscord<JeanCareau> @michaelb.eth Win11
15:30:45FromDiscord<michaelb.eth> In reply to @JeanCareau "<@383034029135364096> Win11": one thing you can try is enabling UTF-8 support system wide, just a sec will get the instructions
15:31:23FromDiscord<JeanCareau> @michaelb.eth I think I already did
15:31:56FromDiscord<JeanCareau> Language settings -> Administrative language settings -> Change system locale -> Beta: Use Unicode UTF-8 for worldwide language support
15:32:01FromDiscord<JeanCareau> This one?
15:32:04FromDiscord<michaelb.eth> yes
15:32:13FromDiscord<michaelb.eth> and you restarted afterward, right?
15:32:17FromDiscord<JeanCareau> Yes
15:32:27FromDiscord<JeanCareau> I did change it a few weeks ago
15:32:56FromDiscord<michaelb.eth> I see, and are you running your nim program in Windows Terminal?
15:33:14FromDiscord<JeanCareau> Powershell.
15:33:41FromDiscord<michaelb.eth> that's the shell, the question is which terminal, though I realize that can be confusing
15:33:56FromDiscord<michaelb.eth> e.g. Windows Terminal can launch cmd.exe shell, PowerShell, bash, etc.
15:36:03FromDiscord<JeanCareau> Oh. I do not know. I start Windows PowerShell and then compile the nim files. Then I start the exe
15:36:20FromDiscord<michaelb.eth> that's okay, I was trying to think what else might be happening
15:37:04FromDiscord<JeanCareau> title_short = title[0..maxLen-1]
15:37:10FromDiscord<JeanCareau> Could it be this one?
15:37:25FromDiscord<JeanCareau> That the bytes get not connected correctly?
15:37:33FromDiscord<JeanCareau> When slicing?
15:37:46FromDiscord<michaelb.eth> looking at your code, it's not clear if maybe some of the procs you're using could possibly be treating the strings as ascii text (i.e. one byte, one character) but shouldn't be making that assumption
15:38:02FromDiscord<michaelb.eth> In reply to @JeanCareau "That the bytes get": yeah, that's what I'm wondering
15:38:49FromDiscord<michaelb.eth> you're probably already aware, but with utf-8 a codepoint can be 1, 2, 3, or 4 bytes
15:39:15FromDiscord<JeanCareau> sent a long message, see http://ix.io/4vYx
15:39:39FromDiscord<JeanCareau> sent a long message, see http://ix.io/4vYy
15:39:42FromDiscord<JeanCareau> These are my procs
15:39:58FromDiscord<JeanCareau> I have not much knowledge about encoding, UTF8 etc...
15:43:54FromDiscord<michaelb.eth> can you disable some of the text processing your doing (with the procs you pasted above), try saving the unprocessed data into a file, and see if you have the same problem when trying to read the file with python?
15:44:37FromDiscord<michaelb.eth> I suspect that one or more places where you're working with `char` isn't working out correctly for the utf-8 data
15:44:51FromDiscord<michaelb.eth> one `char` is basically one byte
15:45:24FromDiscord<wick3dr0se> How can I import a module I made? It's just a simple file with a few procs named test.nim. Shouldn't I be able to import it with absolute path or with just `import test` since it's in the same directory?
15:45:41FromDiscord<michaelb.eth> In reply to @wick3dr0se "How can I import": `import ./test`
15:45:45FromDiscord<wick3dr0se> I tried that too
15:47:24FromDiscord<enthus1ast> And it could also be that the connection itself is not set to utf-8 iirc for postgres this was an issue
15:47:28FromDiscord<wick3dr0se> It seems like it's importing fine. I think the issue is the procs. Maybe I need to export them or something
15:48:17FromDiscord<enthus1ast> @wick3dr0se\: yes, you must export your procs with "\" of course
15:48:42FromDiscord<enthus1ast> foo\()
15:49:10FromDiscord<wick3dr0se> In reply to @enthus1ast "<@772217344680001556>\: yes, you must": ..Thank you!
15:50:56FromDiscord<michaelb.eth> In reply to @enthus1ast "And it could also": good point
15:51:07FromDiscord<enthus1ast> @Chronos [She/Her]\: runForever internally calls poll() which drives the async "engine"
15:52:35FromDiscord<enthus1ast> Your async function have a different "color" they yield back control to the dispatcher on certain things (I think only on await)
15:52:50FromDiscord<wick3dr0se> The AI is so far behind on NIm..
15:52:58FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4vYB
15:53:15FromDiscord<michaelb.eth> wow, that's wildly wrong
15:53:25FromDiscord<wick3dr0se> It spews the most random bullshit
15:53:33FromDiscord<JeanCareau> I now tested it without the procs. Then python can read it without any warnings
15:53:37FromDiscord<michaelb.eth> otoh, per Araq's post last night, ChatGPT showed amazing understanding of his rather sophisticated Nim code
15:53:42FromDiscord<JeanCareau> The DB connection should be set up right
15:53:51FromDiscord<JeanCareau> The DB is innoDB utf8
15:53:56FromDiscord<michaelb.eth> In reply to @JeanCareau "I now tested it": okay, so now try adding back the processing steps a bit at a time
15:54:01FromDiscord<JeanCareau> So the problem seems to be the procs
15:54:06FromDiscord<JeanCareau> Yes
15:54:15FromDiscord<enthus1ast> This ai thing will never be popular same as this strange internet
15:54:23FromDiscord<wick3dr0se> It's helped me write a lot don't get me wrong but it also causes way too much confusion. It takes it hours to write something on it's own that actually compiles and works
15:54:59FromDiscord<wick3dr0se> Idk I use AI a lot in bash and it can do half decent. It uses really outdated and non-performant methods but it definitely helps
15:55:55FromDiscord<enthus1ast> ChatGpt wrote lexing code for once that was twice as fast than my hand "tuned" stuff ....
15:56:24FromDiscord<JeanCareau> In reply to @michaelb.eth "okay, so now try": Yes, I will do so. Tomorrow. Here it is already quite late. I will come back here.
15:56:26FromDiscord<JeanCareau> Thanks
16:03:13*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
16:05:18*progranner joined #nim
16:09:08FromDiscord<michaelb.eth> a resource that may be helpful/interesting re: Unicode (and UTF-8 encoding, etc.) is https://codepoints.net/U+1F63C
16:09:12FromDiscord<michaelb.eth> (edit) "https://codepoints.net/U+1F63C" => "https://codepoints.net/"
16:09:21FromDiscord<michaelb.eth> e.g. https://codepoints.net/U+1F63C
16:09:41FromDiscord<michaelb.eth> if you scroll down on that page a bit, look at the section Representations
16:09:52*cm_ joined #nim
16:10:15FromDiscord<michaelb.eth> for any valid codepoint it shows the decimal number of the point, the UTF-8 bytes, etc.
16:10:20*cm quit (Ping timeout: 246 seconds)
16:10:20*cm_ is now known as cm
16:11:03FromDiscord<michaelb.eth> (edit) "for any valid codepoint it shows the decimal number of the point, the UTF-8 bytes, etc. ... " added "(click show more to see a bunch of representations)"
16:57:40FromDiscord<Arathanis> what module/library has synchronization primitives in it? locks, semaphores, conditions, etc.
16:57:44FromDiscord<Arathanis> is there a builtin?
16:58:33FromDiscord<demotomohiro> In reply to @Arathanis "what module/library has synchronization": https://nim-lang.org/docs/locks.html
16:58:49FromDiscord<Arathanis> 🤦 im dumb
16:58:54FromDiscord<Arathanis> In reply to @demotomohiro "https://nim-lang.org/docs/locks.html": thank you
16:59:03FromDiscord<demotomohiro> https://nim-lang.org/docs/rlocks.html
16:59:31FromDiscord<wick3dr0se> How can I make a proc able to return two different types? Pretty sure the implementation is fine but the compiler seems to make auto always expect string if I return char and string
17:00:34FromDiscord<Arathanis> In reply to @demotomohiro "https://nim-lang.org/docs/rlocks.html": ohhh rlocks too, appreciate it
17:01:24FromDiscord<demotomohiro> In reply to @wick3dr0se "How can I make": A proc can return a tuple or object type if you want to return two different types at sametime.
17:02:23FromDiscord<Arathanis> auto is evil!
17:02:55FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4vYY
17:03:10FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vYZ
17:03:24FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vZ0
17:04:06FromDiscord<demotomohiro> In reply to @wick3dr0se "I want to return": Proc with auto return type is a generic proc. Return type must be determined at compile time.
17:04:35FromDiscord<voidwalker> I am trying to have a common implementation for the BitVecS (static) and BitVec (dynamic) bit arrays, I made the typeclasses as you can see above. Problem is, when I try to make a dynamic one, I get "Error: cannot instantiate: 'S'". The dynamic one does not use the S generic parameter (size of array for static).
17:05:13*jmdaemon joined #nim
17:05:25FromDiscord<voidwalker> Should/could this work ?
17:05:25FromDiscord<wick3dr0se> In reply to @demotomohiro "Proc with auto return": So it's impossible?
17:06:08FromDiscord<Arathanis> In reply to @wick3dr0se "So it's impossible?": auto infers the return type, but it still has to have a single unchanging return typew
17:06:09FromDiscord<Arathanis> (edit) "typew" => "type"
17:06:25FromDiscord<Arathanis> auto is not the ability to have multiple return types, it just means "you figure it out"
17:06:40FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZ2
17:06:43FromDiscord<Arathanis> auto will infer "int" as the return type
17:06:58FromDiscord<voidwalker> What is the use case of auto then ?
17:07:09FromDiscord<wick3dr0se> Ok that makes sense. But how could I go about returning two different types then?
17:07:28FromDiscord<voidwalker> object variant, tuple
17:07:33FromDiscord<Arathanis> In reply to @voidwalker "What is the use": my opinion? not much you should be explicit with the return types
17:07:46FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4vZ3
17:07:49FromDiscord<Arathanis> maybe in something small where its extremely obvious what you are returning you can use it
17:08:04FromDiscord<Arathanis> but i specifically dont use auto
17:08:21FromDiscord<Arathanis> cause it just tells the user "go read the proc if you want to know what the return type is 😎 "
17:08:29FromDiscord<voidwalker> @demotomohiro can you look a bit at my code above and maybe try to see what's wrong ?
17:08:37FromDiscord<demotomohiro> In reply to @wick3dr0se "Ok that makes sense.": https://internet-of-tomohiro.netlify.app/nim/faq.en.html#procedures-how-to-vary-a-return-type-of-procedure-at-runtimeqmark
17:09:02FromDiscord<Arathanis> but in nim you can just
17:09:03FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZ4
17:09:16FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZ5
17:09:21FromDiscord<Arathanis> and the auto is implied.
17:09:57FromDiscord<Arathanis> these are all my opinions, maybe someone else likes auto and can explain a good use case. I think it just makes our code harder to read.
17:10:01FromDiscord<⚶ Zeno> Sup people, my friend asked one funny question that i haven't wondered:↵"Are nim programmers nimmers or nimists ?"↵↵What do you people think ? :D
17:10:05FromDiscord<Arathanis> (edit) "our" => "your"
17:10:14FromDiscord<Arathanis> In reply to @⚶ Zeno "Sup people, my friend": nimrods
17:10:44FromDiscord<⚶ Zeno> In reply to @Arathanis "nimrods": hmmmm
17:10:45FromDiscord<wick3dr0se> In reply to @demotomohiro "https://internet-of-tomohiro.netlify.app/nim/faq.en": Thanks a lot.. Looks like I need to learn some more lol
17:11:00FromDiscord<Rika> nimions was used as well
17:11:11*rockcavera joined #nim
17:11:17FromDiscord<ieltan> Does `jsony` have a `to` equivalent?
17:11:28FromDiscord<voidwalker> Hey Rika can you please see if you have any idea about this : https://discord.com/channels/371759389889003530/371759389889003532/1108077235874836590
17:12:05FromDiscord<⚶ Zeno> In reply to @Rika "nimions was used as": thats interesting name
17:12:18FromDiscord<Rika> In reply to @ieltan "Does `jsony` have a": "fromJson"?
17:13:13FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4vZ6
17:13:16FromDiscord<Rika> In reply to @voidwalker "Hey Rika can you": i dont think you can, you must split them it seems
17:13:18FromDiscord<ieltan> In reply to @Rika ""fromJson"?": I tried calling `fromJson` but I am dealing with `JsonNode` already and it seems like it doesn't work with 'em
17:13:32FromDiscord<Rika> In reply to @ieltan "I tried calling `fromJson`": jsony is not meant to work with jsonnode in any sense
17:13:56FromDiscord<ieltan> yeah, figured.... Thanks
17:13:58FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZ7
17:15:17FromDiscord<voidwalker> @demotomohiro thanks but I'd rather not import a module for 1 line of code : D
17:16:52FromDiscord<Arathanis> In reply to @voidwalker "<@288750616510201856> thanks but I'd": any reason you cant use the built in bit vectors?
17:17:05FromDiscord<voidwalker> what built in bit vectors ?
17:17:19FromDiscord<Arathanis> `set` is implemented as a high performance bit vector
17:17:20FromDiscord<voidwalker> I know there are some bit sets, not bit vectors
17:17:32FromDiscord<Arathanis> or, you could treat it as a bit vector
17:18:13FromDiscord<voidwalker> https://nim-lang.org/docs/sets.html this ?
17:19:11FromDiscord<Arathanis> nah, there is a builtin called "set", this is hashsets
17:19:18FromDiscord<Arathanis> the module name is bad...
17:19:30FromDiscord<voidwalker> link ? I can't find : D
17:19:31FromDiscord<demotomohiro> In reply to @Arathanis "any reason you cant": I guess @voidwalker wants bit vector that supports variable length or larger than 2^16 bits.
17:19:47FromDiscord<voidwalker> ah yes, for sure : )
17:19:57FromDiscord<Arathanis> In reply to @demotomohiro "I guess <@323176231098908672> wants": ive done this by making a custom object that composes sequences of "set" :P
17:20:00FromDiscord<voidwalker> I am tryint to make it both for static (array) and dynamic length (seq).
17:20:14FromDiscord<voidwalker> I also want to make it super efficient
17:20:18FromDiscord<Arathanis> you could also do an array of set
17:20:25FromDiscord<voidwalker> with SIMD and all possible optimisations
17:20:59FromDiscord<Arathanis> but by all means, roll your own!
17:21:14FromDiscord<Arathanis> i like leveraging what exists if i can
17:21:21FromDiscord<demotomohiro> Nims built in bit vector is limited to 2^16bits:↵https://nim-lang.org/docs/manual.html#types-set-type
17:21:51FromDiscord<voidwalker> yes, I've been thinking about it for a while now, I am using bit vectors in my wannabe in the works torrent library. And while BitVector one is okay, I found today that I can't assign slices bigger than 64 elements/bits
17:22:06FromDiscord<voidwalker> Others allow you to do this but lack other functions and so on
17:22:29FromDiscord<voidwalker> there's like 8 bit array libs in nimble, each one has something nice. I wanna combine them into the ultimate lib : )
17:24:04FromDiscord<voidwalker> I should have waited for Beef to wake up before asking heh
17:24:48FromDiscord<voidwalker> It's a pity to copy paste code two times just because one type has an extra generic param, that is not even used in the implementation
17:27:54FromDiscord<voidwalker> maybe concepts ?
17:47:01*junaid_ joined #nim
17:47:35*junaid__ joined #nim
17:51:52*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:53:42*progranner joined #nim
18:26:04FromDiscord<wick3dr0se> Is there a simple way to trap SIGINT?
18:26:17FromDiscord<wick3dr0se> Or signals in general
18:38:58*Notxor joined #nim
18:40:45FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZt
18:41:41FromDiscord<wick3dr0se> My mann
18:44:14FromDiscord<voidwalker> https://play.nim-lang.org/#ix=4vZu
18:45:04FromDiscord<chmod222> Source filters are a quite unusual but fun thing to play with, it turns out
18:45:06FromDiscord<voidwalker> I managed to make the code compile by adding a useless/meaningless generic param to the type that was missing it and the other one had, in the type class union
18:45:50FromDiscord<voidwalker> but now I have to use it when calling the proc, which is not nice, cause it can be any random number with no consequence
18:46:00FromDiscord<Arathanis> whew, why did you alias `static int`?
18:46:12FromDiscord<voidwalker> so it's shorter : )
18:46:20FromDiscord<Arathanis> way harder to read
18:46:31FromDiscord<Arathanis> this has been comment #1 of the code review 😉
18:46:43FromDiscord<voidwalker> I aliased SomeUnsignedInt as well
18:46:46FromDiscord<Arathanis> my eyes just slide off "IntS"
18:46:56FromDiscord<voidwalker> what should I alias it to then ?
18:47:03FromDiscord<voidwalker> IntStatic would defeat the purpose
18:47:04FromDiscord<Arathanis> just leave it as `static int`
18:47:46FromDiscord<Arathanis> that is, don't alias it
18:48:09FromDiscord<Arathanis> probably for `SomeUnsignedInt` too.
18:48:32FromDiscord<voidwalker> ok, I removed the alias, but there's no way I am writing SomeUnsignedInt more than once in my code
18:49:30FromDiscord<voidwalker> some personal context is allowed in libraries
18:49:58FromDiscord<Arathanis> you gotta balance it with readability
18:50:07FromDiscord<Arathanis> and why wouldnt you want to type SomeUnsignedInt more than once?
18:50:40FromDiscord<voidwalker> anyway, not time for code review now, I am not finished with it, I just want to know how I can use two generic types that take 1 and 2 generic params, into one type class
18:51:36FromDiscord<Arathanis> sure
18:51:41FromDiscord<voidwalker> cause it's way too long, and a better name is Units, for my use case
18:51:54FromDiscord<voidwalker> units of storage that is
18:52:14FromDiscord<voidwalker> I have to write it at every generic proc definition, it will not be pretty
18:52:21FromDiscord<Arathanis> it does obfuscate it though
18:52:38FromDiscord<Arathanis> gonna make users dive through the source to figure out what it means :/
18:52:49FromDiscord<voidwalker> it's literally the first line
18:52:57FromDiscord<voidwalker> and that's what you first read to make sense of the code, the types
18:53:19FromDiscord<Arathanis> more likely someone imports it, types out a procedure and sees "Units" and says "what is that?"
18:53:58FromDiscord<voidwalker> https://github.com/MarcAzar/BitVector/blob/cd8af9d00e05f0a261fb84419a06630143d25559/src/bitvector.nim#L45
18:54:07FromDiscord<voidwalker> borrowed it from here, and I think it's good
18:54:34FromDiscord<Rika> They would see the sign and see that yes units is some unsigned integer
18:54:38FromDiscord<Rika> But then ask
18:54:43FromDiscord<Rika> Why the fuck is it called units??
18:54:44FromDiscord<Arathanis> its your code man, im just giving you my thoughts, i wont be offended if you ignore it
18:55:04FromDiscord<voidwalker> how would you call it ?
18:55:05FromDiscord<Arathanis> In reply to @Rika "Why the fuck is": pmuch
18:55:12FromDiscord<Arathanis> i just wouldn't alias it
18:55:48FromDiscord<Rika> In reply to @voidwalker "how would you call": If I had to shorten it, SomeUInt
18:55:49FromDiscord<voidwalker> that is just out of the question, completely unreasonable : P
18:55:57FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZx
18:56:04FromDiscord<Rika> If i wanted to use units as a name, comment the reason
18:56:59FromDiscord<voidwalker> lol I just realised that generic type redefinition is not needed when specifying procs
18:57:07FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=
18:57:24FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vZy
18:57:36FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4vZy" => "https://play.nim-lang.org/#ix=4vZz"
18:58:09FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZA
18:58:14FromDiscord<Arathanis> obvious at a glance what everything is
18:58:44FromDiscord<Elegantbeef> Jeez what's with full captial generic parameters
18:58:45FromDiscord<Elegantbeef> Who hurt you
18:58:47FromDiscord<voidwalker> 😄
18:59:05FromDiscord<Arathanis> In reply to @Elegantbeef "Who hurt you": i just to justify the existence of the capslock key
18:59:16FromDiscord<Arathanis> (edit) "just" => "like"
18:59:20FromDiscord<Rika> You don’t have it rebound to either control or escape?
18:59:24FromDiscord<voidwalker> Beef I was staying awake in hopes that you would wake up soon
18:59:26FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4vZC
18:59:40FromDiscord<Elegantbeef> My capslock is just a macro that writes "Jesus christ, why do you need this key"
18:59:47FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vZD
18:59:59FromDiscord<Elegantbeef> I don't even know what i'm supposed to do/say
19:00:03FromDiscord<Arathanis> beefified?
19:00:05FromDiscord<Elegantbeef> Use a concept if you want to typeclass over 2 types
19:00:22FromDiscord<voidwalker> omfg that's what I thought, thanks
19:00:30FromDiscord<Arathanis> In reply to @Elegantbeef "Use a concept if": wdym?
19:00:43FromDiscord<Rika> I was thinking if that would work with differing generic parameter counts
19:00:51FromDiscord<Chronos [She/Her]> Also is there any type for callables? Any proc, no matter the parameters (if any) or return type
19:00:51FromDiscord<Rika> I don’t think it’s an issue but I don’t know why I did
19:00:53FromDiscord<Elegantbeef> It does
19:01:13FromDiscord<Elegantbeef> Concepts are a typeclass that does not care about instantiation only about functionality
19:01:14FromDiscord<Rika> In reply to @Hourglass, When the Hour Strikes "Also is there any": No? How would you use it
19:01:55FromDiscord<voidwalker> https://play.nim-lang.org/#ix=4vZH this is how I made it work, but I had to cram one redundant int param to be able to call it, so it matches the other type params
19:02:01FromDiscord<Elegantbeef> The best way to do that is a `proc(p: pointer)` and unpack parameters
19:02:21FromDiscord<Chronos [She/Her]> In reply to @Rika "No? How would you": For a generic type that accepts a proc and can be called with parameters
19:02:59FromDiscord<demotomohiro> In reply to @Hourglass, When the Hour Strikes "Also is there any": https://nim-lang.org/docs/manual.html#generics-type-classes↵Do you want `proc` type class?
19:03:28FromDiscord<Chronos [She/Her]> Oh yeah, I didn't even realise it worked like that
19:03:31FromDiscord<Chronos [She/Her]> Thanks aha
19:03:46FromDiscord<Chronos [She/Her]> In reply to @Hourglass, When the Hour Strikes "This is my code,": But this is confusing me lol
19:06:53FromDiscord<voidwalker> @ElegantBeef pls give us some clues here, concepts are not intuitive at the moment
19:06:59FromDiscord<voidwalker> what does this even mean
19:07:00FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vZJ
19:07:35FromDiscord<Elegantbeef> https://www.jasonbeetham.com/codereuse.html
19:07:41FromDiscord<Elegantbeef> Goto the concepts segment
19:08:21FromDiscord<Elegantbeef> You're 100% wrong with the concept
19:08:51FromDiscord<Rika> sent a long message, see http://ix.io/4vZK
19:09:04FromDiscord<Elegantbeef> Something like this is proper
19:09:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vZL
19:09:13FromDiscord<Rika> (edit) "http://ix.io/4vZK" => "https://paste.rs/1bk"
19:09:13FromDiscord<Elegantbeef> Why the hell are fields capitalise 😄
19:09:21FromDiscord<voidwalker> okay. And are you sure there's no way to hack two very similar types, with 1 and 2 generic params, of which the first is not actually used in the implementations they share ?
19:09:26FromDiscord<voidwalker> without using concepts
19:09:40FromDiscord<voidwalker> the second param is the same for both
19:09:47FromDiscord<voidwalker> (edit) "the second param is the same ... for" added "type"
19:10:04FromDiscord<Elegantbeef> `AnyBitVec[T] = BitVec[T] or BitVecS[auto, T]` perhaps?
19:10:16FromDiscord<Elegantbeef> I do not know i just use concepts here cause they're more sensible
19:10:29FromDiscord<Rika> In reply to @Elegantbeef "`AnyBitVec[T] = BitVec[T] or": Wow that sounds cursed
19:10:36FromDiscord<voidwalker> well if it's all compile time and no overhead..
19:10:52FromDiscord<voidwalker> I believe it's abit overkill for this particular use case
19:10:58FromDiscord<Rika> In reply to @voidwalker "well if it's all": Overhead is in compile time now, concepts can potentially add a lot of time
19:11:34FromDiscord<Rika> By the way beef do you think old concepts are gonna get removed any time soon because I don’t want them gone 🥺
19:11:56FromDiscord<Chronos [She/Her]> In reply to @Rika "<@909883978717204561> `proc": Oh that actually worked thanks!
19:12:09FromDiscord<Chronos [She/Her]> Well, not my entire issue but should be able to fix that part myself
19:13:06FromDiscord<ElegantBeef> Jesus christ you people need to use matrix! 😛
19:13:14FromDiscord<ElegantBeef> I do not see them being removed rika
19:13:32FromDiscord<ElegantBeef> There are things you can do with present concepts you cannot ever express with new style
19:13:56FromDiscord<ElegantBeef> I foresee the old style being the lowlevel control based concepts and new style the high level even a monkey can use them style
19:14:30FromDiscord<Rika> Don’t the old ones have some performance issues
19:14:32FromDiscord<ElegantBeef> sent a code paste, see https://paste.rs/ubh
19:14:42FromDiscord<ElegantBeef> I mean you have to evaluate the code at compile time
19:14:49FromDiscord<ElegantBeef> So sure if that's a performance issue
19:15:04FromDiscord<ElegantBeef> They are a hell of a lot more capable
19:15:49FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=4vZN
19:15:58FromDiscord<ElegantBeef> This type of introspection you just cannot get with newstyle
19:16:18FromDiscord<Rika> I’ve usually been wary when using concepts because I’ve hit some nasty shit before
19:16:58FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vZO
19:16:58FromDiscord<Chronos [She/Her]> Okay I lied, `/home/horizon/Projects/Nim/Nimberite/EventSystem/src/events.nim(36, 24) Error: type mismatch: got <>` is the issue and this is even more confusing lol
19:17:29FromDiscord<voidwalker> ah wait, I forgot to remove the extra S param
19:17:48FromDiscord<voidwalker> still doesn't work
19:18:47FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4vZO" => "https://play.nim-lang.org/#ix=4vZP"
19:19:27FromDiscord<@theperfectcomputer-628303036da0> I remember some time ago, I was able to run nim repl on some sort of nim vm
19:19:29FromDiscord<@theperfectcomputer-628303036da0> This was two years ago
19:19:36FromDiscord<@theperfectcomputer-628303036da0> But I can't quite remember how I did this
19:19:50FromDiscord<demotomohiro> Do you mean `nim secret`?
19:19:58FromDiscord<@theperfectcomputer-628303036da0> ye
19:23:29*junaid_ quit (Remote host closed the connection)
19:23:29*junaid__ quit (Remote host closed the connection)
19:23:42FromDiscord<Chronos [She/Her]> In reply to @Hourglass, When the Hour Strikes "Okay I lied, `/home/horizon/Projects/Nim/Nimberite/": Yep I am dead this is horrid
19:27:38FromDiscord<@theperfectcomputer-628303036da0> how do I exit nim secret? I can't seem to be able to figure out how
19:27:57FromDiscord<demotomohiro> `quit()`
19:29:13FromDiscord<@theperfectcomputer-628303036da0> oh yeah - parens
19:29:13FromDiscord<demotomohiro> It is a proc in system module.
19:29:19FromDiscord<@theperfectcomputer-628303036da0> That's what I was missing
19:32:25FromDiscord<Chronos [She/Her]> Yeah anyone able to help? `/home/horizon/Projects/Nim/Nimberite/EventSystem/src/events.nim(36, 24) Error: type mismatch: got <>` code https://play.nim-lang.org/#ix=4vZS
19:38:34FromDiscord<demotomohiro> In reply to @Hourglass, When the Hour Strikes "Yeah anyone able to": I think `es.listenerAddCond()` should be `es.listenerAddCond(es)`.
19:38:53FromDiscord<wick3dr0se> Weird there isn't procs in std/terminal for the alternative and main buffer switching, just takes a simple ANSI sequence like echo("\e[?1049h"). It's odd that eraseScreen(), which is just echo("\e[2J\e[H"), is included but not buffers
19:41:15FromDiscord<Chronos [She/Her]> In reply to @demotomohiro "I think `es.listenerAddCond()` should": What why?
19:41:31FromDiscord<Chronos [She/Her]> In reply to @demotomohiro "I think `es.listenerAddCond()` should": That makes no sense to me?
19:42:09FromDiscord<Chronos [She/Her]> Since it's two parameters when the proc only accepts one
19:43:11FromDiscord<demotomohiro> `listenerAddCond` is a procedual type `proc(es: EventSystem[T]): bool`.
19:43:33FromDiscord<Elegantbeef> Field access does not pass the left hand in
19:44:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vZU
19:45:43*lucasta quit (Quit: Leaving)
19:55:02FromDiscord<Chronos [She/Her]> Oh, weird but works, thanks!
19:55:37FromDiscord<Chronos [She/Her]> Makes sense too but a bit of a pain lol
19:56:04FromDiscord<Chronos [She/Her]> How do streams work then? Is that why there's the `setPosition` procs and then the `impl` field for it exists?
19:58:26FromDiscord<Chronos [She/Her]> Now I'm not too sure on how to get the `fire` proc to work... `/home/horizon/Projects/Nim/Nimberite/EventSystem/src/events.nim(42, 19) Error: type mismatch: got <varargs[untyped]>` makes sense to me, maybe a macro would make it better?
19:59:53FromDiscord<Chronos [She/Her]> Yeah okay a simple macro should help
20:07:58FromDiscord<Chronos [She/Her]> I am so confused on how to make this work damn it
20:08:20FromDiscord<Chronos [She/Her]> Aha, template instead of proc!
20:08:53FromDiscord<Chronos [She/Her]> Now works as intended! And is almost guaranteed to be horrific when actually used :)
20:09:13*xet7 joined #nim
20:17:39FromDiscord<Elegantbeef> I still say you just pass data using `pointer` and unpack it inside
20:21:43FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "I still say you": For packet data? I am gonna do that
20:22:18FromDiscord<Chronos [She/Her]> But I'm making the event system so I can actually call the proc in the WASM runtimr
20:22:20FromDiscord<Chronos [She/Her]> Runtime
20:45:08*jkl quit (Quit: Gone.)
20:45:13*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
20:45:44*progranner joined #nim
20:47:43*jkl joined #nim
20:50:42FromDiscord<Ayy Lmao> Would any Nim gods be willing to look at this and tell me what I might be doing wrong? I'm getting these very hard to deal with segfaults. https://github.com/Alkamist/clap/blob/main/demo.nim
20:53:08FromDiscord<Elegantbeef> Firstly that emit code is odd
20:53:46FromDiscord<Ayy Lmao> How do I get around doing that?
20:53:59FromDiscord<Ayy Lmao> Nim just ignores when you try to export a variable
20:54:34FromDiscord<Ayy Lmao> The emit code works though. The plugin registers in my DAW and I can open it
20:54:58FromDiscord<Elegantbeef> Secondly I have no idea how to run the code
20:56:22FromDiscord<Ayy Lmao> Running unfortunately is a little complicated as it requires opening the plugin in a DAW. I'm also on Windows, but I think it should work on Linux.
20:57:05FromDiscord<Elegantbeef> You can do `{.exportc, dynlib.}` I think to get what you want
20:57:35FromDiscord<Elegantbeef> nm -D reports `0000000000009400 R myVal`↵for `let myVal {.exportc, dynlib.}= MyType(a: 10, b: 20)`
20:57:58FromDiscord<Ayy Lmao> I will try it. I don't think I tried adding dynlib to it yet.
20:58:09FromDiscord<Elegantbeef> Ok so where dos `foo` get allocated?
20:58:50FromDiscord<Elegantbeef> There's the create shared I guess, and you pass this as user data
20:59:23FromDiscord<Ayy Lmao> I have also tried AudioPlugin being a ref object instead and doing GcRef and GcUnref to clean it up
20:59:32FromDiscord<Elegantbeef> That's all the same
20:59:43FromDiscord<Elegantbeef> Do you get the line it segfaults at?
21:00:24FromDiscord<Ayy Lmao> Yeah let me get it again. It points me to some place inside alloc.nim if I remember correctly
21:01:49FromDiscord<Ayy Lmao> If I have threads:on, `let eventCount = process.in_events.size(process.in_events)` segfaults and says `Exception 0xc0000005 encountered at address 0x7ffd09a2974f: Access violation reading location 0x00000040`
21:01:55FromDiscord<Ayy Lmao> I'll get the error for when threads is off
21:03:19FromDiscord<Elegantbeef> You should call the `NimMain` fro minsidie `mainInit`
21:03:23FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w0e
21:03:54FromDiscord<Ayy Lmao> In reply to @Elegantbeef "You should call the": I have done that before, I still get the same segfaults
21:04:13FromDiscord<Ayy Lmao> If I have threads off, I get a segfault in `alloc.nim` in the function `proc rawAlloc(a: var MemRegion, requestedSize: int): pointer =`
21:04:33FromDiscord<Ayy Lmao> line 735 `c.freeList = c.freeList.next`
21:04:38FromDiscord<Elegantbeef> Even though it doesnt help you still should call `NimMain` that's what inits your `clapDescriptor`
21:05:12FromDiscord<Ayy Lmao> I will call it there if that is the proper way. I think it's actually getting called anyway somehow because the clapDescriptor is definitely initialized since it's showing up in my DAW
21:05:38FromDiscord<Elegantbeef> If you do not call NimMain it should be an empty object
21:06:17FromDiscord<Ayy Lmao> For whatever reason it's not. Maybe a windows specific thing?
21:07:55FromDiscord<Elegantbeef> Ah seems top level code uses C init
21:08:08FromDiscord<Elegantbeef> `N_LIB_EXPORT_VAR NIM_CONST tyObject_MyTypeGKf3qs3DosB7llBKfn52xQ myVal = {((NI)10), ((NI)20)}`
21:08:22FromDiscord<Elegantbeef> If you do not call a procedure I guess it can use the {} init
21:08:39*lucasta joined #nim
21:10:55FromDiscord<Ayy Lmao> `{.exportc, dynlib.}` seems to export the variable properly which is nice
21:11:13FromDiscord<Ayy Lmao> I can get rid of that nasty emit code
21:11:23FromDiscord<Elegantbeef> I'm still looking at the code, trying to see bugs
21:11:31FromDiscord<Ayy Lmao> Still the same segfaults though, even with calling NimMain
21:12:09FromDiscord<Elegantbeef> You're certain the bindings are correct?
21:12:12FromDiscord<Ayy Lmao> I think there is some sort of oddity with the way Nim's allocation is or something. I'm not sure. I have done this exact kind of logic in Odin and it doesn't segfault.
21:12:33FromDiscord<Ayy Lmao> I can double check them I guess but I'm pretty sure.
21:12:55FromDiscord<Elegantbeef> Do you have a link to the original header?
21:13:50FromDiscord<Ayy Lmao> It's spread over like a million files but this is it https://github.com/free-audio/clap/tree/main/include/clap
21:14:31FromDiscord<Elegantbeef> Does `pluginProcess` segfault if you just do `plugin.foo.add(1)`?
21:15:19FromDiscord<Ayy Lmao> It seems to kind of unpredictably segfault. Anything that allocates on the audio thread can segfault it seems. The program can run for a while and then randomly like `plugin.foo.add(3)` will segfault.
21:15:49FromDiscord<Ayy Lmao> I can try only doing that though
21:15:50FromDiscord<Elegantbeef> Ok so this sounds a lot like something being subtly incorrect and writing to invalid memory
21:16:06FromDiscord<Ayy Lmao> Incorrect in the binding?
21:16:19FromDiscord<Elegantbeef> Either in the binding or in your usage
21:16:31FromDiscord<Elegantbeef> This sounds a lot like invalid memory write
21:16:47FromDiscord<Elegantbeef> It seems to work and runs fine but your accidentally corrupting the heap hence the random segfault
21:17:39FromDiscord<Ayy Lmao> If you want an example of what I was following https://raw.githubusercontent.com/nakst/cdn/main/clap-tutorial-part-1-plugin.cpp
21:18:03FromDiscord<Elegantbeef> sorry that `.cpp` extensio nmeans i do not dare read
21:18:25FromDiscord<Ayy Lmao> This is probably better actually https://github.com/free-audio/clap/blob/main/src/plugin-template.c
21:19:16FromDiscord<Ayy Lmao> I'll keep looking through my binding to make sure it's correct
21:19:24FromDiscord<Elegantbeef> It doesnt really matter, it's simple code to follow to me
21:20:19FromDiscord<Elegantbeef> I'd suggest use memory analysers and friends but no clue what tool to use on windows
21:24:54FromDiscord<Ayy Lmao> I've just been using lldb to see where in the source code it goes wrong. I have no idea what to try to do from there.
21:25:00FromDiscord<Ayy Lmao> I'm not very experienced in debugging.
21:25:15FromDiscord<Elegantbeef> You dont need lldb
21:25:17FromDiscord<Elegantbeef> You need like valgrind
21:25:25FromDiscord<Ayy Lmao> I don't think that works for windows.
21:25:43FromDiscord<Ayy Lmao> I have this thing called remedybg
21:25:47FromDiscord<Elegantbeef> There are alternatives
21:26:18FromDiscord<Elegantbeef> No clue about the efficacy though
21:26:36FromDiscord<Dudugz> Should I use thread for non-blocking database operations? I mean, the code must not stop at any time to wait for the database to perform the operation so as not to cause a delay.
21:28:58FromDiscord<Elegantbeef> Arent DBs IO bound?
21:34:25FromDiscord<Ayy Lmao> So a weird quirk about these segfaults is that they only happen when there are two or more instances of my plugin.
21:34:39FromDiscord<Ayy Lmao> I don't know if that is useful info at all.
21:35:27FromDiscord<jmgomez> In reply to @Dudugz "Should I use thread": why cant you just use a `Future`?
21:35:49FromDiscord<jmgomez> In reply to @Ayy Lmao "So a weird quirk": what gc are you using?
21:35:58FromDiscord<Ayy Lmao> In reply to @jmgomez "what gc are you": I'm using arc
21:36:35FromDiscord<Dudugz> In reply to @Elegantbeef "Arent DBs IO bound?": They still block the statements below because the operation is waiting for the database to process the request.
21:36:36FromDiscord<jmgomez> Are you using a dll?
21:36:56FromDiscord<Dudugz> In reply to @jmgomez "why cant you just": Because it wouldn't solve my problem lol
21:37:12FromDiscord<Ayy Lmao> In reply to @jmgomez "Are you using a": I am exporting a dll. I am not using any dlls from my program.
21:37:17FromDiscord<jmgomez> In reply to @Dudugz "Because it wouldn't solve": what is your problem?
21:38:03FromDiscord<Dudugz> "database operation blocking code "
21:38:03FromDiscord<jmgomez> In reply to @Ayy Lmao "I am exporting a": So you have hooked two instances of the dlls? That should be fine on ARC. I do have a similar approach in NUE
21:38:37FromDiscord<Ayy Lmao> In reply to @jmgomez "So you have hooked": It's one .dll but the host spawns instances of an object that is contained inside the dll.
21:38:50FromDiscord<Ayy Lmao> The dll itself is loaded once I believe
21:39:11FromDiscord<jmgomez> In reply to @Dudugz ""database operation blocking code": doenst the driver have a pool or what?
21:39:36FromDiscord<Dudugz> The driver is sync, at least the std
21:40:26FromDiscord<Dudugz> (edit) "The driver is sync, at least the std ... " added "one"
21:40:28FromDiscord<jmgomez> So that's your problem, you dont need a "thread"
21:40:54FromDiscord<jmgomez> see if there is any callback it should have something
21:41:18FromDiscord<jmgomez> never used the std bindings, if not, you may want to extend it. Shouldnt be too hard
21:42:18FromDiscord<jmgomez> In reply to @Ayy Lmao "It's one .dll but": so with instances of your plugin you mean instance of an object inside your plugin?
21:43:04FromDiscord<Ayy Lmao> In reply to @jmgomez "so with instances of": Yeah, the host tells me when to allocate and free them.
21:43:27FromDiscord<Ayy Lmao> And they can be passed into callbacks that are running on different threads.
21:44:23FromDiscord<jmgomez> different threads? are they refs?
21:45:01FromDiscord<Ayy Lmao> Threads managed by the host. There is a realtime audio thread and a non realtime main thread. It doesn't matter if they are refs or pointers, I still get segfaults.
21:45:22FromDiscord<jmgomez> @Dudugz you may want to look into this https://github.com/cheatfate/asyncpg
21:47:58FromDiscord<jmgomez> In reply to @Ayy Lmao "Threads managed by the": you get segfaults without using strings/seqs or refs then?
21:48:19*xet7 quit (Ping timeout: 265 seconds)
21:49:16FromDiscord<Ayy Lmao> In reply to @jmgomez "you get segfaults without": I get segfaults specficially when doing anything involving allocation. So in my case, appending to a sequence or sorting it.
21:50:01FromDiscord<Ayy Lmao> I also get a segfault if I turn `threads:on` just for interacting with a pointer that the host gives me.
21:50:10FromDiscord<Ayy Lmao> With `threads:off` it's fine.
21:50:25FromDiscord<Ayy Lmao> (edit) "it's fine." => "I can interact with that pointer."
21:50:56FromDiscord<Ayy Lmao> (edit) "specficially" => "specifically"
21:51:00*Notxor quit (Remote host closed the connection)
21:53:08FromDiscord<jmgomez> In reply to @Ayy Lmao "I get segfaults specifically": seq and strings are refs. Try to dont use refs at all to see if that's the issue
21:54:38FromDiscord<Ayy Lmao> Well I still get the `threads:on` segfault since that doesn't involve refs at all. And not using seqs would be quite difficult.
21:55:08FromDiscord<Elegantbeef> On orc/arc seqs/strings arent technicall refs 😄
21:56:20FromDiscord<jmgomez> why is that? Because they are always copied over?
21:56:53FromDiscord<jmgomez> I see them crashing NUE when passing it into another thread create by UE
21:57:21FromDiscord<jmgomez> I do mostly use `FStrint` and `TArray` though so not really a super big issue in NUE's case
21:57:40FromDiscord<jmgomez> (edit) "`FStrint`" => "`FString`"
22:02:11*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
22:06:49FromDiscord<Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4w0m
22:07:35FromDiscord<Dudugz> In reply to @jmgomez "<@265937132886032407> you may want": I'll take a look, internet is bad
22:15:38FromDiscord<jmgomez> That's why I asked about the callback. You may also want to check this one out https://github.com/itsumura-h/nim-allographer
22:17:11FromDiscord<jmgomez> Here is the Postgres binding: https://github.com/itsumura-h/nim-allographer/blob/main/src/allographer/async/database/impls/postgres.nim
22:19:56FromDiscord<jmgomez> Nim async is an event loop which I personally think it's a good approach to concurrency
22:21:09FromDiscord<Dudugz> In reply to @jmgomez "That's why I asked": This looks good, I'll test it when I get home, thx.
22:23:50FromDiscord<Dudugz> In reply to @jmgomez "Nim async is an": I don't. JS's async it is better. There is no such thing as an asynchronous function blocking the operation of another asynchronous function, they must run in parallel.
22:24:10FromDiscord<Dudugz> (edit) removed "it"
22:26:38FromDiscord<Dudugz> Asynchronous functions serve precisely to parallelize tasks, if it were to block code execution then it would be easier to make everything synchronous.
22:31:07FromDiscord<jmgomez> Actually they both use exactly the same approach. The "problem" is the "API". If you call a blocking function in javascript it will block as it does in Nim. Parallelism and concurrency are two different things
22:34:17FromDiscord<Prestige> Looking at karax, how can I focus a VNode? Been looking through the docs trying to figure out a way
22:38:28FromDiscord<Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4w0o
22:42:06FromDiscord<hotdog> In reply to @Avahe "Looking at karax, how": `vnode.dom.focus()` probably
22:42:10FromDiscord<hotdog> https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
22:42:15FromDiscord<Dudugz> https://media.discordapp.net/attachments/371759389889003532/1108162524672700506/Screenshots_2023-05-16-18-42-01.png
22:42:39FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4w0p
22:42:44FromDiscord<Dudugz> It would block if I had used await
22:43:16FromDiscord<Prestige> In reply to @hotdog "`vnode.dom.focus()` probably": unfortunately that dom property is nil
22:43:36FromDiscord<Arathanis> JS also uses an event loop
22:43:38FromDiscord<Dudugz> In reply to @jmgomez "": 🤔 Well this is strange so because for me it never blocked, it could be because you are using devtools.
22:43:49FromDiscord<hotdog> In reply to @Avahe "unfortunately that dom property": Needs to be done after the render to the page
22:43:55FromDiscord<jmgomez> In reply to @Arathanis "JS also uses an": that's what Im trying to say for a bit now..
22:44:06FromDiscord<hotdog> How are you calling it?
22:44:12FromDiscord<Prestige> Also it says that's not a function for dom
22:45:15FromDiscord<jmgomez> In reply to @Dudugz "🤔 Well this is": doesnt matter the "tricks" the interpreter uses. If the loop hangs it wont be able to continue
22:45:18FromDiscord<Prestige> `Error: attempting to call undeclared routine: 'focus'` https://play.nim-lang.org/#ix=4w0q
22:45:21FromDiscord<hotdog> In reply to @Avahe "Also it says that's": https://nim-lang.org/docs/dom.html#focus%2CElement
22:45:37FromDiscord<Arathanis> In reply to @jmgomez "that's what Im trying": you are absolutely correct. JS does a lot of things implicitly in its async which I kind of hate. It hides what is actually going on.
22:46:24FromDiscord<hotdog> In reply to @Avahe "`Error: attempting to call": Try ev.target.focus and import std/dom
22:46:46FromDiscord<Arathanis> it works fine, but its causes some serious whiplash when someone who knows JS encounters async in just about any other language.
22:47:00FromDiscord<Dudugz> In reply to @Arathanis "you are absolutely correct.": Well i love, if that allows me to run two long tasks in parallel without blocking the rest of the page.
22:47:13FromDiscord<Arathanis> In reply to @Dudugz "Well i love, if": nothing is stopping you from doing this in Nim
22:47:35FromDiscord<Arathanis> the point we are trying to make is that the implicitness of JS's async has given you incorrect preconceptions about async in other languages
22:47:48FromDiscord<Dudugz> 🤔 I was once told that any synchronous task in an async proc would block the poll
22:47:53FromDiscord<Prestige> interesting, just importing std/dom kind of fixed it. But if I click another element, I get an error than `n.dom` is nil
22:48:41FromDiscord<hotdog> In reply to @Avahe "interesting, just importing std/dom": Try the ev.target.focus instead. There is an issue in the current release of Karax that causes dom to be nil sometimes
22:49:17FromDiscord<Arathanis> In reply to @Dudugz "🤔 I was once": this is true in JS as well it just implicitly yeilds to the event loop all the time
22:49:30FromDiscord<Arathanis> in Nim and most other languages the yields are explicit
22:49:33FromDiscord<Dudugz> Hm
22:49:46FromDiscord<Prestige> cool, looks to be working pretty much how I want it. Thanks hotdog
22:50:09FromDiscord<Dudugz> So how would you do it in Nim to run your tasks at the same time without one interfering with the other causing delay?
22:50:24FromDiscord<BoomBang> >-> i'll speak in this thread
22:50:45FromDiscord<Arathanis> callSoon queues a task without blocking
22:50:47FromDiscord<Elegantbeef> @Dudugz you're describing threads
22:50:55FromDiscord<BoomBang> nvm
22:50:56FromDiscord<Arathanis> anywhere there is an `await` yields to the event loop
22:51:05FromDiscord<Elegantbeef> "same time" means threads
22:51:07FromDiscord<Arathanis> so in your while loop throw in an `await sleepAsync(0)`
22:51:11FromDiscord<Elegantbeef> thems the rules
22:51:41FromDiscord<Arathanis> and what beef is saying is correct, nothing is actually concurrent in async event loop, Js or otherwise. It is just a bunch of synchrnous code occasionally letting others do worj
22:51:44FromDiscord<Arathanis> (edit) "worj" => "work"
22:51:56FromDiscord<jmgomez> What @Dudugz wants for this particular case is a db library that does the pooling in the driver
22:51:58FromDiscord<Dudugz> In reply to @Elegantbeef ""same time" means threads": I don't say in the literal sense, I mean I have two asynchronous procs executing a code, these procs must not block the code.
22:52:16FromDiscord<Elegantbeef> So then give up the cpu whenever you can
22:53:27FromDiscord<jmgomez> In reply to @Arathanis "and what beef is": hence the difference between concurrency vs parallelism
22:53:27FromDiscord<Dudugz> Sure, so should I spruce up all procs that do longss tasks with await sleepAsync(0)? I wonder why this needs to be explicit.
22:53:53FromDiscord<Arathanis> In reply to @jmgomez "hence the difference between": ok sure, you got me on semantics llol
22:53:54FromDiscord<Arathanis> (edit) "llol" => "lol"
22:53:59FromDiscord<Arathanis> i concede
22:54:23FromDiscord<Elegantbeef> Why would you randomly add sleeps↵(@Dudugz)
22:54:29FromDiscord<Arathanis> In reply to @Dudugz "Sure, so should I": they dont wait at all, it basically says "hey event loop ill continue right this second, but also if someone else needs a chance to run thats ok too, you decide"
22:55:02FromDiscord<Elegantbeef> All async procedure calls using `await` ill give up the cpu
22:55:04FromDiscord<Dudugz> In reply to @Elegantbeef "Why would you randomly": "give up cpu whenever you can" so that the poll is released I think.
22:55:05FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Why would you randomly": Probably to yield after long synchronous code?
22:55:31*jmdaemon quit (Ping timeout: 240 seconds)
22:55:58FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4w0r
22:56:58FromDiscord<Dudugz> But the solution jmgomez gave is good, I'll have a look at the library he referenced. Worse is when a server blocks all data processing because it needs to find a specific information in the database.
22:57:45FromDiscord<Elegantbeef> I do not use async much but if you're using async stop using sync code 😛
22:57:56FromDiscord<Arathanis> the way ive heard it described is that async is "cooperative multitasking" or "cooperative concurrency"
22:58:18FromDiscord<Arathanis> everyone just runs synchronously except for "checkpoints" where they yield to the event loop which can then choose to give the cpu to a different task
22:58:31FromDiscord<Arathanis> in Nim, anywhere you see "await" yields to the event loop
22:58:36FromDiscord<Dudugz> In reply to @Elegantbeef "I do not use": Well yes, I'm using it since making a server without async is the same as shooting yourself in the foot. Imagine processing 10k requests one at a time.
22:59:01FromDiscord<Elegantbeef> You say that but async can be broken down to `select` on your sockets↵(@Dudugz)
22:59:23FromDiscord<jmgomez> In reply to @Elegantbeef "I do not use": dont you? In your game engine you just put everything that you want to check in a tick function?
22:59:25FromDiscord<Dudugz> Hm
22:59:37FromDiscord<Elegantbeef> Yes↵(@jmgomez)
22:59:55FromDiscord<Dudugz> In reply to @Elegantbeef "Yes (<@726017160115126333>)": Is the game small?
23:00:01FromDiscord<Elegantbeef> Yes
23:00:19FromDiscord<Elegantbeef> I do not have a very robust designed API
23:00:21FromDiscord<Dudugz> So it makes sense, in that case you don't need to process multiple things at the same time.
23:00:22FromDiscord<jmgomez> In reply to @Elegantbeef "Yes (<@726017160115126333>)": Interesting, I was in a kinda oposite direction where I connected the UE engine loop to epol so I can use async everywhere 😛
23:00:25FromDiscord<Elegantbeef> Cause I do not need one
23:00:48FromDiscord<Arathanis> my understanding is you wont see much async in video game programming
23:00:56FromDiscord<Arathanis> the event loop causes overhead and degrades performance.
23:00:57FromDiscord<Elegantbeef> You generally do not see much async
23:00:58FromDiscord<Elegantbeef> simplescreenrecorder-2023-05-15\_00.31.16.mp4 [simplescreenrecorder-2023-05-15_00.31.16.mp4](https://t2bot.io/_matrix/media/r0/download/matrix.org/pqymPIoFAVjjeojWqzcqudXP)
23:01:00FromDiscord<Elegantbeef> This is my present game
23:01:03FromDiscord<Arathanis> you just have a tick function that updates the state
23:01:05FromDiscord<Elegantbeef> Why do i need async
23:01:24FromDiscord<jmgomez> In reply to @Arathanis "my understanding is you": it's handy for some tricks. You dont see it often because cpp sucks at it
23:01:37FromDiscord<Arathanis> In reply to @jmgomez "it's handy for some": yeah cpp is good at that
23:02:01FromDiscord<Dudugz> In reply to @Arathanis "you just have a": Well yes, but then there are algorithms to determine priorities of what should be updated. Because updating various information one by one causes delay in the game.
23:02:27FromDiscord<Elegantbeef> Speaking of it's time for a GUI api redesign
23:02:28FromDiscord<Elegantbeef> This is going to be fun
23:02:57FromDiscord<Dudugz> Good luck
23:02:59FromDiscord<jmgomez> Here an example of using async await to make a hover effect https://twitter.com/_jmgomez_/status/1649887235934765061/video/1
23:04:02FromDiscord<Elegantbeef> Yea I'd just make a main loop timer and call it a day
23:04:57FromDiscord<Elegantbeef> Also using async in a game loop is horrendous if you want game time to be different than real time
23:05:28FromDiscord<jmgomez> yeah, but things can get more complicated when you start to compound them or wait for other to complete before acting
23:05:29FromDiscord<Elegantbeef> like that `sleepAsync` will fire in 500ms regardless if you pause the time
23:05:58FromDiscord<jmgomez> oh no, since it's connected to the loop it doesnt. When the world stop, it stop too
23:06:05FromDiscord<Elegantbeef> Ok
23:06:28FromDiscord<Elegantbeef> I assumed it was based of system primitives still and independent of the game loop
23:07:06FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4w0t
23:07:11FromDiscord<Dudugz> It is also possible to make a cancelable timer, you can cancel if the world stop
23:07:23FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4w0t" => "https://paste.rs/Izg"
23:07:30FromDiscord<Elegantbeef> I mean I know that it's possible 😄
23:08:01FromDiscord<Elegantbeef> C#'s task system for instance does not work with Unity's time which means sleeping for 100ms is not the same if you set timescale to 0
23:08:24FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4w0w" => "https://play.nim-lang.org/#ix=4w0v"
23:08:29FromDiscord<jmgomez> You see? Nim integration on UE is better than C# in Unity 😛
23:08:52FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4w0v" => "https://play.nim-lang.org/#ix=4w0x"
23:11:33FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4w0y
23:11:37FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4w0y" => "https://paste.rs/epg"
23:11:48FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4w0A" => "https://play.nim-lang.org/#ix=4w0z"
23:12:08FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4w0z" => "https://play.nim-lang.org/#ix=4w0B"
23:12:43FromDiscord<BoomBang> How do I run a function with only the name of a function as a string in Nim?
23:12:54FromDiscord<Elegantbeef> You make a look up table
23:14:19*jmdaemon joined #nim
23:15:08FromDiscord<Elegantbeef> Hmm tuples + stack based inheritance might be all one needs to make a good GUI
23:15:13FromDiscord<Elegantbeef> Let's see how bad this goes 😄
23:15:57FromDiscord<BoomBang> In reply to @Elegantbeef "You make a look": What's a look up table?
23:16:17FromDiscord<Elegantbeef> A table that you look values up in
23:16:25FromDiscord<BoomBang> In reply to @Elegantbeef "A table that you": Ohhhh
23:16:32FromDiscord<BoomBang> kind of like a dictionary
23:16:53FromDiscord<Elegantbeef> A dictionary is a table yes
23:17:39FromDiscord<BoomBang> I just want it to be able to get one function from a file and use it
23:17:54FromDiscord<BoomBang> like this:
23:19:02FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4w0C
23:24:16FromDiscord<BoomBang> sent a code paste, see https://play.nim-lang.org/#ix=4w0E
23:24:30FromDiscord<Elegantbeef> You cannot do that
23:24:32FromDiscord<BoomBang> Kind of like import but I use functions from nim
23:24:37FromDiscord<Elegantbeef> They are not exported
23:24:46FromDiscord<Elegantbeef> Why do you want to use a string
23:25:13FromDiscord<BoomBang> (edit) "https://play.nim-lang.org/#ix=4w0E" => "https://paste.rs/IWM"
23:25:34FromDiscord<BoomBang> In reply to @Elegantbeef "Why do you want": So that you can use an arbitrary function
23:25:55FromDiscord<Elegantbeef> You cannot arbitrarily use functions Nim is statically compiled and only includes what you use
23:27:13FromDiscord<Dale> Sounds like you want function pointers
23:27:26FromDiscord<BoomBang> In reply to @Elegantbeef "You cannot arbitrarily use": oh
23:27:49FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4w0F
23:28:19FromDiscord<BoomBang> sent a code paste, see https://play.nim-lang.org/#ix=4w0G
23:28:26FromDiscord<BoomBang> because the main file wouldn't know
23:28:28FromDiscord<Arathanis> oh, you gonna have to load any function you want to support
23:28:46FromDiscord<BoomBang> but ig it makes sense that it would need to be interpreted
23:28:55FromDiscord<Elegantbeef> Like I said Nim has dead code elimination and is statically typed
23:29:02FromDiscord<Elegantbeef> Which means you need to use all the procedures and know their type
23:29:07FromDiscord<Arathanis> its compiled, it will only have the functions it can tell are used in the code and nothing else
23:30:02FromDiscord<Arathanis> so yeah i misunderstood and beef is right
23:30:05FromDiscord<Elegantbeef> Technically being compiled doesnt really matter 😄
23:30:17FromDiscord<Arathanis> ok also true on a technicality lol
23:30:33FromDiscord<Elegantbeef> Just no sane language doesnt do dead code elim
23:30:53FromDiscord<Arathanis> In reply to @Elegantbeef "Just no sane language": maybe i want huge binaries? the man cant tell me what to do
23:31:11FromDiscord<Elegantbeef> Hey Nim used to not have dead code elim!
23:31:41FromDiscord<Arathanis> its 2023, if my program doesn't use all available RAM it will never be popular!
23:31:44FromDiscord<Arathanis> just look at Chrome!
23:32:10FromDiscord<Arathanis> dominate the RAM == dominate the market share
23:32:11FromDiscord<Arathanis> it is known
23:32:44FromDiscord<Dale> Is there not a pragama to tell that a prof shouldn’t be discarded?
23:32:51FromDiscord<Dale> (edit) "pragama" => "pragma"
23:32:59FromDiscord<Dale> (edit) "prof" => "proc"
23:33:13FromDiscord<Elegantbeef> Nope
23:33:39FromDiscord<Dale> I guess if you stick it in a structure then it would t matter anyway
23:58:48*progranner joined #nim