<< 26-08-2021 >>

00:00:42FromDiscord<Gustavo6046> oops
00:00:50FromDiscord<Gustavo6046> i redid the generic way and somehow it worked this time lol
00:01:34FromDiscord<Gustavo6046> so
00:01:46FromDiscord<Gustavo6046> i have an iterator that iterates on possibly multiple chunks of struct-of-arrays values
00:02:12FromDiscord<Gustavo6046> what if i don't want arrays that aren't used in the for loop's body to be fetched by the iterator?
00:02:43FromDiscord<Gustavo6046> like, `for ray in ray_iterator(my_ray_list): ray.position[0] += ray.direction[0] ray.stepSize; # ...`
00:03:08FromDiscord<Gustavo6046> i would want this iterator to fetch position, direction, and stepSize, but not attenuate, numBounces, or sourcePos
00:03:13FromDiscord<Gustavo6046> I could implement a naive iterator like this
00:07:09FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYa
00:07:50FromDiscord<Gustavo6046> but `getValue` involves constructing a `RayValue` by fetching values from all of the respective arrays in each ray chunk's `RaysValuesArray`
00:08:07FromDiscord<Gustavo6046> So I guess the crux of the question is, is there some way to lazy construct an object?
00:09:53FromDiscord<Gustavo6046> Oo
00:09:55FromDiscord<Gustavo6046> maybe using a closure!
00:09:59FromDiscord<Gustavo6046> But can a closure argument be like a block?
00:13:55*auxym_ quit (Ping timeout: 252 seconds)
00:27:21FromDiscord<Gustavo6046> Ah it can
00:27:22FromDiscord<Gustavo6046> I'm dumb
00:29:12FromDiscord<impbox [ftsf]> `for i in 0..size - 1:`↵btw you can use `for i in 0..<size:`
00:36:08FromDiscord<Gustavo6046> \:o
00:36:09FromDiscord<Gustavo6046> thanks
00:42:15madpropsso this is not permitted it seems: https://dpaste.org/rcQv
00:49:00FromDiscord<impbox [ftsf]> why do you say it's not permitted?
00:50:59FromDiscord<impbox [ftsf]> what kind of value do you want to return?
00:52:04FromDiscord<impbox [ftsf]> the return type needs to be determinable at compile time
00:52:11madpropseither float or int
00:52:27madpropsi guess i have to pick one
00:52:54FromDiscord<impbox [ftsf]> or return a variant object
00:53:11FromDiscord<impbox [ftsf]> what's your use-case?
00:54:08madpropswell I have a proc that changes words to numbers, like "three hundred twelve" == 312 . But there can also be decimals "two point two" == 2.2
00:54:31FromDiscord<impbox [ftsf]> but what are you using it for?
00:54:36FromDiscord<impbox [ftsf]> what do you use the numbers for?
00:55:00madpropsit's for a library, so it's for the users to decide
00:55:33madpropsmaybe returning float all the time is not that bad
00:55:37FromDiscord<impbox [ftsf]> well it's probably better to return a float
00:55:53FromDiscord<impbox [ftsf]> or have two procs
00:58:37FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3wYh
01:00:41madpropsgenerics
01:01:01FromDiscord<Gustavo6046> aa finally I did it and the tests passed
01:01:27FromDiscord<Gustavo6046> In reply to @impbox "what's your use-case?": updating certain arrays of the RaysValueArray object type selectively, which should be more CPU-cache-friendly
01:01:41FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYk
01:01:46FromDiscord<Gustavo6046> (edit) "https://play.nim-lang.org/#ix=3wYk" => "https://paste.rs/u09"
01:02:02FromDiscord<Gustavo6046> for example, updating position using direction shouldn't require loading attenuation or the # of bounces
01:03:15FromDiscord<impbox [ftsf]> awesome (sorry my q was for madprops)
01:08:16*krux02 quit (Remote host closed the connection)
01:10:06*xet7 quit (Remote host closed the connection)
01:11:14*xet7 joined #nim
01:14:56*auxym_ joined #nim
01:17:01madpropsso I made this thing https://play.nim-lang.org/#ix=3wYm
01:25:54FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYo
01:25:54FromDiscord<retkid> you ever find a solution for thijs
01:25:56FromDiscord<retkid> (edit) "thijs" => "this"
01:28:01FromDiscord<impbox [ftsf]> madprops, cool, can you make it do fractions too? eg "one hundredth"
01:28:21madpropshmm that's an interesting idea
01:28:50madpropscould make another proc for that
01:29:05FromDiscord<impbox [ftsf]> "one and three quarters"
01:29:28FromDiscord<impbox [ftsf]> also localisation support? =p
01:29:38FromDiscord<retkid> is there anyway to just install the nim compiler
01:29:48FromDiscord<retkid> for windows
01:29:53FromDiscord<retkid> so i dont have to crosscompile
01:30:07*auxym_ quit (Ping timeout: 240 seconds)
01:30:11FromDiscord<retkid> (edit) "crosscompile" => "crosscompile, thats just giving too many issues"
01:32:52FromDiscord<retkid> oh look at that its working
01:32:53FromDiscord<retkid> cool nevermind
01:33:02FromDiscord<impbox [ftsf]> you can install nim on windows... not sure if you can install it without the other stuff
01:33:25FromDiscord<retkid> is cross compiling from linux to bsd and macos easier?
01:36:59FromDiscord<impbox [ftsf]> easier cross-compiling from linux to windows than, anything to macos
01:37:06FromDiscord<impbox [ftsf]> i've done it in the past but it was a massive pain
01:46:44FromDiscord<Gustavo6046> Is there a fast inverse square root?
01:46:51FromDiscord<Gustavo6046> Oh wait
01:47:08FromDiscord<Gustavo6046> It's in the x86 extensions ever since Carmack did it in Quake 3, isn't it
01:47:13FromDiscord<Gustavo6046> (edit) "It's in the x86 extensions ever since ... Carmack" added "John"
01:47:24FromDiscord<Gustavo6046> But there should be a proc in math that does FISR if it's not hardware available
01:47:37FromDiscord<Gustavo6046> Rather than calling sqrt, which probably is just opaque enough that it can't be optimized by a compiler into a FISR
01:47:40FromDiscord<Gustavo6046> I dunno
01:54:38FromDiscord<Gustavo6046> Okay that's just curiosity
01:55:04FromDiscord<Gustavo6046> In reply to @impbox "awesome (sorry my q": oh ok, sorry
02:16:41*arkurious quit (Quit: Leaving)
02:18:41FromDiscord<retkid> In reply to @impbox "easier cross-compiling from linux": really
02:18:52FromDiscord<retkid> ugh
02:19:21FromDiscord<impbox [ftsf]> https://github.com/tpoechtrager/osxcross i think i used this
02:19:23nrds<R2D299> itHub: 7"Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)"
02:19:23FromDiscord<retkid> https://media.discordapp.net/attachments/371759389889003532/880275197364686858/unknown.png
02:19:34FromDiscord<retkid> what i got so far
02:19:43FromDiscord<retkid> windows32 doesn't work so im figuring that out
02:20:18FromDiscord<impbox [ftsf]> are you using mingw32?
02:20:21FromDiscord<Elegantbeef> If you're on linux and want to make a windows binary you may be able to just install mingw
02:20:27FromDiscord<impbox [ftsf]> (edit) "mingw32?" => "mingw32/64?"
02:20:38FromDiscord<retkid> it was being weird so i just installed nim in wine
02:20:41FromDiscord<impbox [ftsf]> yeah, cross compiling using mingw was pretty easy
02:21:12FromDiscord<Elegantbeef> "being weird?
02:21:39FromDiscord<retkid> lemme get the command i was using
02:24:09FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYz
02:24:32FromDiscord<retkid> easier just to use wine
02:24:44FromDiscord<Elegantbeef> Ehhh
02:25:16FromDiscord<Elegantbeef> What's the program you were making, simple exported hello world still?
02:27:00FromDiscord<retkid> theres some more complex stuff but just hello world testing stuff
02:27:07FromDiscord<retkid> by complex i mean just tests
02:27:14FromDiscord<retkid> nothing actually useful
02:27:25FromDiscord<retkid> iterators and there was hashmaps i think
02:28:24FromDiscord<retkid> but now im testing this library for packaging native libraries to give the illusion of things being platform independant
02:28:24FromDiscord<Elegantbeef> You did install mingw?
02:28:29FromDiscord<retkid> (edit) "independant" => "independent"
02:28:35FromDiscord<retkid> yea i have mingw
02:29:45FromDiscord<Elegantbeef> I can only say for some reason you dont have the header files
02:29:58FromDiscord<Elegantbeef> Which fixing makes more sense than to use wine
02:31:26FromDiscord<retkid> Not having headerfiles for c itself sounds like an arch related rabbithole
02:31:31FromDiscord<retkid> that i dont wanna deal with
02:32:25FromDiscord<impbox [ftsf]> `external compiler program 'gcc` looks like it's not using mingw's gcc
02:32:55FromDiscord<retkid> which makes sense
02:33:02FromDiscord<retkid> but how else do i engage it beside d:mingw
02:33:03FromDiscord<impbox [ftsf]> you can tell nim which gcc to use in config.nims
02:33:10FromDiscord<Elegantbeef> Oh i see the issue
02:33:14FromDiscord<Elegantbeef> you're doing `--os:windows`
02:33:16FromDiscord<Elegantbeef> That's not needed
02:33:22FromDiscord<Elegantbeef> just do `-d:mingw`
02:33:25FromDiscord<Gustavo6046> (edit) "https://play.nim-lang.org/#ix=3wYA" => "https://paste.rs/q3q"
02:33:26FromDiscord<Gustavo6046> sent a code paste, see https://paste.rs/Ehw
02:33:31FromDiscord<Gustavo6046> sadly this is pre-1.5 and thus pre-`random.randState()`
02:33:35FromDiscord<retkid> In reply to @Gustavo6046 "can I set an": probably predefine them
02:33:47FromDiscord<Gustavo6046> ?
02:34:15FromDiscord<retkid> declaring a proc and assigning something to a variable is very different and i think the way to do that is to define the function then assign it
02:34:24FromDiscord<impbox [ftsf]> `let randfunc = if rng == nil: ... else: ...`
02:34:24FromDiscord<retkid> but maybe im wrong thats just general coding stuff
02:34:35FromDiscord<Elegantbeef> Yea imp has the proper solution
02:35:07FromDiscord<retkid> new compiler
02:35:11FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYB
02:35:11FromDiscord<retkid> (edit) "new compiler ... " added "problems"
02:35:19FromDiscord<retkid> should probably rename helloworld\
02:35:21FromDiscord<retkid> (edit) "helloworld\" => "helloworld"
02:35:22FromDiscord<Gustavo6046> ahh
02:35:34FromDiscord<impbox [ftsf]> compiler is working! now it's just your linker
02:35:45FromDiscord<impbox [ftsf]> progress
02:35:49FromDiscord<Gustavo6046> thing is
02:35:55FromDiscord<retkid> oh haha
02:35:58FromDiscord<retkid> sorry wrong biot
02:36:07FromDiscord<retkid> (edit) "biot" => "bit"
02:36:10FromDiscord<Gustavo6046> it's just so rng.rand is used if rng is passed, otherwise the random module-level rand
02:36:25FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYC
02:36:33FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYD
02:36:37FromDiscord<retkid> thats what i would do
02:36:37FromDiscord<Gustavo6046> but sadly that is not the case
02:36:40FromDiscord<Elegantbeef> Can we see the entire proc?
02:36:44FromDiscord<retkid> why not just define them
02:36:55FromDiscord<impbox [ftsf]> retkid, where's the error?
02:36:56FromDiscord<Gustavo6046> sure
02:37:01FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYE
02:37:06FromDiscord<retkid> In reply to @impbox "retkid, where's the error?": that is the entire output
02:37:10FromDiscord<Gustavo6046> ignore that `ref`
02:37:31FromDiscord<Gustavo6046> actually no don't ignore that `ref`
02:37:36FromDiscord<impbox [ftsf]> @retkid if you run that command does it output anything? `/usr/bin/x86_64-w64-mingw32-gcc -shared -o /home/retkid/Desktop/downloads/jnim/nimcompile/src/helloworld.dll /home/retkid/.cache/nim/helloworld_d/stdlib_io.nim.c.o /home/retkid/.cache/nim/helloworld_d/stdlib_system.nim.c.o /home/retkid/.cache/nim/helloworld_d/@mhelloworld.nim.c.o -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now`
02:38:08FromDiscord<retkid> same error
02:38:12FromDiscord<impbox [ftsf]> what error?
02:38:32FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYF
02:38:45FromDiscord<impbox [ftsf]> ok, you didn't show that error above
02:39:01FromDiscord<retkid> it... is
02:39:20FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYG
02:39:23FromDiscord<retkid> sorry i have a bit of a birthday headache
02:39:24FromDiscord<retkid> haha
02:39:46FromDiscord<retkid> can you see why i just like used wine
02:39:55FromDiscord<impbox [ftsf]> because you wanted more of a headache?
02:39:59FromDiscord<Elegantbeef> What's the issue with the code you provided hustavo?
02:40:01FromDiscord<retkid> well, the wine worked fine
02:40:06FromDiscord<impbox [ftsf]> wine -> hangover
02:40:43FromDiscord<impbox [ftsf]> https://stackoverflow.com/questions/55418931/ld-exe-unrecognized-option-z
02:40:45FromDiscord<retkid> the only thing i cant work with wine is the x32 but thats probably because i need to figure out how to install ming32
02:40:50FromDiscord<impbox [ftsf]> apparently -z doesn't exist on windows
02:40:55FromDiscord<impbox [ftsf]> where is that command coming from?
02:41:18FromDiscord<retkid> somewhere within nim
02:41:28FromDiscord<retkid> because im not supplying anything with a z in it
02:41:31FromDiscord<impbox [ftsf]> what is your build command?
02:41:33FromDiscord<Elegantbeef> Gustavo here you go https://play.nim-lang.org/#ix=3wYI
02:41:41FromDiscord<impbox [ftsf]> are you passing --os:windows ?
02:41:42FromDiscord<retkid> nim c -d:mingw --app:lib --gc:arc src/(
02:41:44FromDiscord<retkid> (edit) "src/(" => "src/"
02:41:54FromDiscord<Elegantbeef> need to dereference the rng to make it work
02:41:55FromDiscord<retkid> lets try with arc
02:42:21FromDiscord<Elegantbeef> Now the real question gustavo is can this be resolved at compile time?
02:42:38FromDiscord<impbox [ftsf]> retkid, you're already using arc? try adding --os:windows
02:43:45FromDiscord<retkid> well, if i ad --os:windows with mingw it creates a different problem
02:43:50FromDiscord<retkid> (edit) "ad" => "add"
02:43:55FromDiscord<impbox [ftsf]> which is?
02:44:12FromDiscord<Elegantbeef> Like does this work for your use case gustavo? https://play.nim-lang.org/#ix=3wYK
02:44:16FromDiscord<retkid> In reply to @Elegantbeef "you're doing `--os:windows`": a
02:44:41FromDiscord<impbox [ftsf]> that was when you were using the wrong compiler
02:44:53FromDiscord<Elegantbeef> when passing `--os:windows` to the nim compiler you get a nice cannot find header error it seems to me
02:45:04FromDiscord<retkid> yea
02:45:05FromDiscord<retkid> i do
02:45:11FromDiscord<retkid> if i use mingw with windows
02:45:21FromDiscord<retkid> if i used use mingw i get a more complicated error
02:45:28FromDiscord<retkid> (edit) "used" => "just"
02:45:54FromDiscord<retkid> with no clear or definite solution besides "use wine lol"
02:45:57FromDiscord<retkid> which works
02:46:28FromDiscord<Elegantbeef> Can i get the exact code you're using?
02:47:19FromDiscord<retkid> im gonna delete all the code and just do a echo "Hello World" to try and isolate the issue
02:47:53FromDiscord<Elegantbeef> Well i have an exported proc + hello world echo'd and mine runs fine
02:48:00FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3wYL
02:48:01FromDiscord<retkid> > echo "hello world"
02:50:36FromDiscord<Elegantbeef> Hmm your mingw is newer than mine so perhaps it's a version issue?
02:50:53FromDiscord<Elegantbeef> Does it compile fine without `--app:lib`?
02:50:54FromDiscord<impbox [ftsf]> nim version?
02:51:36FromDiscord<retkid> In reply to @Elegantbeef "Does it compile fine": same issue
02:51:54FromDiscord<retkid> 1.4.8
02:52:19FromDiscord<retkid> should i submit an issue to nim github?
02:53:18FromDiscord<impbox [ftsf]> There's one already, but maybe add some detail
02:54:16FromDiscord<retkid> but yea
02:54:22FromDiscord<impbox [ftsf]> https://github.com/nim-lang/Nim/issues/17441
02:54:23FromDiscord<retkid> wine is really the only way to gabout this right now
02:54:41FromDiscord<retkid> > Arch-specific
02:54:44FromDiscord<retkid> always cool\
02:54:45FromDiscord<retkid> (edit) "cool\" => "cool"
02:54:55FromDiscord<impbox [ftsf]> Or figure out what's causing the -z to be added and remove it
02:54:59FromDiscord<retkid> its a matter of tracking down whatever the fuck arch is mixing
02:55:01FromDiscord<retkid> (edit) "mixing" => "missing"
02:55:40FromDiscord<retkid> i'll add a stack trace to the issue
03:00:22FromDiscord<retkid> alright time to see how im gonna cross compile to macos
03:00:28FromDiscord<impbox [ftsf]> Good luck
03:00:49FromDiscord<retkid> im scrolling for the tool you linked
03:01:11FromDiscord<retkid> but i might just do the wine thing but with darling
03:01:58*rockcavera quit (Remote host closed the connection)
03:02:06FromDiscord<retkid> why does apple wanna make compiling to their platform hard
03:02:14FromDiscord<retkid> wouldn't a logical company make and maintain a gcc fork
03:03:56FromDiscord<Elegantbeef> Apple likes walled gardens
03:04:05FromDiscord<Gustavo6046> oops
03:04:31FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYS
03:04:33FromDiscord<Gustavo6046> currently complains with
03:04:43FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYT
03:04:52FromDiscord<Gustavo6046> and realy I min min, not max, but beside that
03:05:02FromDiscord<retkid> In reply to @Elegantbeef "Apple likes walled gardens": to quote wendell
03:05:17FromDiscord<retkid> "while apple perverts the unix ethos"
03:06:31FromDiscord<j-james> Could I get some structural feedback on my wlroots wrapper?
03:06:33FromDiscord<j-james> https://github.com/j-james/wlroots
03:06:35nrds<R2D299> itHub: 7"Nim bindings for wlroots."
03:06:54FromDiscord<Elegantbeef> The issue gustavo is your concept gives a typedesc in the second slot
03:07:00FromDiscord<Elegantbeef> It should be like `default Vector3` or similar
03:07:15FromDiscord<Gustavo6046> oh
03:07:16FromDiscord<Gustavo6046> (edit) "oh" => "oh?"
03:07:39FromDiscord<Elegantbeef> `Vector3` is a type description so that procedure will never match
03:07:43FromDiscord<Gustavo6046> ahh
03:07:55FromDiscord<Gustavo6046> ah I se
03:07:57FromDiscord<Gustavo6046> (edit) "se" => "see"
03:08:01FromDiscord<Gustavo6046> huh
03:08:08FromDiscord<Gustavo6046> it still complains, but now for an unrelated line
03:08:10FromDiscord<j-james> I'd mostly like to know if I'm wrapping things right
03:08:21FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYU
03:08:23FromDiscord<Gustavo6046> this time here:
03:08:29FromDiscord<j-james> Since that can't really be tested until it's finished and working
03:08:50FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYV
03:09:30FromDiscord<Gustavo6046> (line 37 char 24, though I indented the original line with one single extra space to fit the comment's # because I wanted the "arrow" to be as wide as the offset of 24)
03:10:40FromDiscord<Elegantbeef> james depending on the level of these bindings i do have to ask if you want to use C bitsets or Nim? \:D
03:10:55FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wYW
03:17:45FromDiscord<Elegantbeef> You dont have a `collidable(Vector3, Vector3)`?
03:17:55FromDiscord<Elegantbeef> Rather `checkCollidable`
03:25:21FromDiscord<j-james> In reply to @Elegantbeef "james depending on the": Fair, haha! My goal was to get working bindings and then try to remove pointer use as much as possible with `var` and so forth
03:26:01FromDiscord<j-james> It's just an annoyingly large library to get working
03:26:09FromDiscord<Elegantbeef> Yea i can see
03:26:47FromDiscord<Elegantbeef> I dont know the api much so aside from telling you to remove `wlr` from everything and also making the flags nim bitsets not much i can say \:D
03:30:48FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=3wYZ
03:34:41FromDiscord<retkid> i pinged you because i found you posted the error
03:35:04FromDiscord<retkid> it was the nim installer someone made that has no need because nim already comes with a good one
03:35:19FromDiscord<retkid> i was setting up nim on wine
03:39:24FromDiscord<impbox [ftsf]> retkid the -z is coming from /etc/nim/nim.cfg most likely
03:42:34FromDiscord<impbox [ftsf]> chuck a nim.cfg in your project dir with `gcc.options.linker = ""` and test
03:43:21FromDiscord<impbox [ftsf]> on arch i was able to compile with `nimc c -o:main.exe -d:mingw main.nim`
03:43:38FromDiscord<impbox [ftsf]> after i added that nim.cfg
03:51:59FromDiscord<Gustavo6046> In reply to @Elegantbeef "Rather `checkCollidable`": no, `check_collision` is meant to be a signed distance function
03:52:11FromDiscord<Gustavo6046> positive numbers mean outside, negative means inside, 0 is right on the surface
03:52:14*stkrdknmibalz joined #nim
03:52:20FromDiscord<Gustavo6046> the larger the number, the larger the distance (in or uot)
03:52:24FromDiscord<Gustavo6046> (edit) "uot)" => "out)"
03:52:58FromDiscord<Gustavo6046> so it's not meant to compare two points
03:53:03FromDiscord<Gustavo6046> that would be their distances
03:53:26FromDiscord<Gustavo6046> but heh
03:53:28FromDiscord<Gustavo6046> that makes it work
03:53:28FromDiscord<Gustavo6046> funny
03:54:06FromDiscord<Gustavo6046> I guess having an overload of something that is `Collidable` but not `CollidableWorld` in the same module hints at the compiler that there can be _other_ overloads with `Collidable`
03:54:07FromDiscord<Gustavo6046> neat!
03:55:19FromDiscord<Gustavo6046> Btw I made a test case for the normal finder, for a plane whose positive side faces -Y, and it seems to get something near <0, -1, 0> pretty consistently \:D
03:55:28FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZ0
03:55:33FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZ1
03:55:36FromDiscord<Gustavo6046> Yay!
04:01:40FromDiscord<Elegantbeef> Well @Gustavo6046 concepts are so you can abstract procedures to operator on a type that fulfils a prerequisite so there are always overloads when calling a procedure with a concept that then calls procedures on it
04:01:51FromDiscord<Gustavo6046> Ah
04:02:17FromDiscord<Gustavo6046> hmm
04:02:25FromDiscord<Gustavo6046> wait that's confusing
04:02:40FromDiscord<Gustavo6046> procedures _to_ operator?
04:02:50FromDiscord<Elegantbeef> to operate on a type\
04:02:52FromDiscord<Gustavo6046> ah
04:03:10FromDiscord<Gustavo6046> I see
04:03:16FromDiscord<Gustavo6046> how does a concept call procedures on itself?
04:03:26FromDiscord<Gustavo6046> it doesn't run anything, it's just a structural definition
04:03:30FromDiscord<Elegantbeef> It doesnt of course
04:03:36FromDiscord<Gustavo6046> ah
04:03:39FromDiscord<Gustavo6046> you said at the end
04:04:26FromDiscord<Elegantbeef> In your example you've made it so there is a `checkCollision` procedure that you want for this procedure, which means any call to that procedure has an type overloaded version of that procedure
04:05:20FromDiscord<Elegantbeef> Well i say "has" but i just mean there is overload which matches the concept so it pretty much has one
04:06:01*supakeen quit (Quit: WeeChat 3.2)
04:06:30*supakeen joined #nim
04:06:39FromDiscord<impbox [ftsf]> @retkid updated the issue with a fix, error might be coming from arch's/etc/nim/nim.cfg
04:07:54FromDiscord<retkid> https://media.discordapp.net/attachments/371759389889003532/880302511272116344/nim.cfg
04:07:56FromDiscord<retkid> theres mine
04:08:04FromDiscord<retkid> if you need it
04:08:12FromDiscord<retkid> lemme upload it as .txt
04:08:51FromDiscord<retkid> https://media.discordapp.net/attachments/371759389889003532/880302752037752835/nim.txt
04:10:30FromDiscord<impbox [ftsf]> I don't, but try the suggested fix and see if it solves it for you
04:18:10FromDiscord<retkid> In reply to @impbox "I don't, but try": return 0
04:18:13FromDiscord<retkid> 👍
04:18:34FromDiscord<impbox [ftsf]> \o/
04:19:00FromDiscord<retkid> however, you failed to get it to me before midnight, it does not count as a birthday gift
04:19:24FromDiscord<retkid> i kid
04:19:27FromDiscord<retkid> i appreciate you <3
04:24:58FromDiscord<Gustavo6046> Imo, if any concept in the same module has that proc's name, the compiler should assume that proc _will_ be overloaded by other types that satisfy this trait at some point, and if there is only one concrete implementation of this proc in this moduile, it should not attempt to assume that this proc is the implementation and that its type signature overrides the one implied by this concept.
04:25:16FromDiscord<Elegantbeef> I dont follow what you mean
04:25:21FromDiscord<Gustavo6046> As in
04:27:05FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZ6
04:28:03FromDiscord<Gustavo6046> Compiling this should probably error because↵1. it assumes that `getName` only accepts `NameTag` because that's the only implementation the compiler sees;↵2. `NameTag::content` is a `Named`, not a `NameTag`, which does not satisfy this preliminary type signature `getName(NameTag)`.
04:28:41FromDiscord<Elegantbeef> Well `Named` is not a concrete type
04:28:50FromDiscord<Gustavo6046> True, but this has no reason to error.
04:29:06FromDiscord<Gustavo6046> I assume that the compiler parses concepts before it deals with procs' type signatures, right?
04:29:35FromDiscord<Elegantbeef> I believe concepts checked at instantiation
04:30:26FromDiscord<Yardanico> In reply to @impbox "<@217459674700578816> updated the issue": Yeah, seems like it's yet another bug of Nim installed from a package manager
04:30:39FromDiscord<Yardanico> @retkid are you on arch or on an arch based distro?
04:31:27FromDiscord<Gustavo6046> In that case, when the compiler sees `Named`, it sees the condition `getName(n) is string`. Since `n` is a _concept variable_, as soon as it sees `getName(n)` and no further, it should automatically consider `getName(typeof n)`, in this case `getName(Named)`, as a valid signature for future passes, and only bark if in the specific future instance that `getName` _is_ called, that specific implementation doesn't exist.
04:32:14FromDiscord<Gustavo6046> Of course, a proc that takes a `Named` and then calls `getName` on that value, is guaranteed that such a `getName` implementation exists by the mere virtue of taking a `Named` because `Named` by definition requires that a `getName ` is defined for it.
04:32:22FromDiscord<Elegantbeef> but `getName(n)` != `getName(typeof(n))`
04:32:35FromDiscord<Elegantbeef> You might very well have a procedure which takes a type description
04:32:37FromDiscord<Gustavo6046> In reply to @Elegantbeef "but `getName(n)` != `getName(typeof(n))`": the latter was a type signature thing
04:32:44FromDiscord<Gustavo6046> not an actual expression
04:32:50FromDiscord<Gustavo6046> it should consider that as a valid signature
04:33:11FromDiscord<Gustavo6046> That is a very simple example that has no reason to cause a compiler error and yet it does
04:33:18FromDiscord<Gustavo6046> So let's look at where else the issue could be
04:33:35FromDiscord<Elegantbeef> Can you provide an example that isnt invalid code?
04:33:37FromDiscord<Gustavo6046> `getName(tag: NameTag)` tries to call `getName(tag.content: Named)`
04:34:04FromDiscord<Elegantbeef> IE remove the vector and also write the NameTag properly
04:34:14FromDiscord<Gustavo6046> `tag.content` is a Named, therefore the compiler should assume that there is an implementation for it, and only check in instantiations of `tag.content`.
04:34:34FromDiscord<Elegantbeef> And you can do that
04:34:37FromDiscord<Gustavo6046> Oh wait
04:34:53FromDiscord<Gustavo6046> `NameTag` isn't a concrete type, is it?
04:35:06FromDiscord<Gustavo6046> Since `Named` isn't a concrete type and we're basically trying to define a member variable `content` that is
04:35:10FromDiscord<Gustavo6046> Yep!
04:35:12FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/I06
04:35:21FromDiscord<Gustavo6046> I think that would work
04:35:42FromDiscord<Elegantbeef> Well it's what i think you were trying to describe with that odd `NameTag = type` and `content: Named` \:D
04:36:02FromDiscord<Gustavo6046> That works
04:36:16FromDiscord<Gustavo6046> Ehehe
04:36:29FromDiscord<Gustavo6046> Well
04:36:35FromDiscord<Gustavo6046> turns out the other code barked a different thing
04:36:45FromDiscord<Gustavo6046> Which would be the right error message
04:36:49FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZ8
04:36:50FromDiscord<Gustavo6046> But in the real world example it was actually a seq
04:37:20FromDiscord<Elegantbeef> well if you ever feel equipped to improve the state of concepts it's one PR away to contribute 😀
04:38:03FromDiscord<Elegantbeef> I do know they're rather cryptic error wise, and often result in some weird issues
04:38:23FromDiscord<Elegantbeef> And there's also the new concept syntax
04:38:50FromDiscord<Elegantbeef> where you do `getName(n: Self): string` instead of the `getName(n) is string`
04:39:10FromDiscord<Gustavo6046> Odd
04:39:11FromDiscord<Gustavo6046> this worked too
04:39:24FromDiscord<Gustavo6046> it was very similar to the example that didn't work
04:39:27FromDiscord<Gustavo6046> sent a code paste, see https://paste.rs/F4j
04:40:29FromDiscord<Gustavo6046> which implemented a concept for a seq where each item also satisfied this concept, and involved calling a 'concept method' on each element of this seq
04:41:25FromDiscord<Gustavo6046> (edit) "seq" => "seq," | "concept," => "concept (`seq[X] satisfies X`)," | "where each item also satisfied thisconcept (`seq[X] satisfies X`),and involved calling a 'concept method' on each element of this seq ... " added "(`f(s) where s: seq[X] involves f(s[0]), f(s[1]), ...`)"
04:41:35FromDiscord<Elegantbeef> Well i know it's a multi file project so you could throw what you have on https://doongjohn.github.io/nim-playground/ and i could see if i can reason the issue
04:41:38FromDiscord<Gustavo6046> (edit) "f(s[0]), f(s[1]), ...`)" => "f(s[i]) for every i in s`)"
04:42:21FromDiscord<Gustavo6046> My case was fixed simply by implementing `f` for its own return type (`f(T): T`), or I guess could be any other overload (`f(X): T`)
04:42:29*FromDiscord quit (Remote host closed the connection)
04:42:42*FromDiscord joined #nim
04:43:53FromDiscord<Gustavo6046> I'm just astonished that, when there was only implementation for `checkCollision`, the compiler assumed that it was only for `CollidableWorld = seq[Collidable]` when it should have considered that `Collidable` by definition implied a `checkCollision` implementation for itself and that we were only calling `checkCollision` on the items of this seq (which were `Collidable`s)
04:44:21FromDiscord<Gustavo6046> Like how did it even once ever think that.
04:44:24FromDiscord<Gustavo6046> That's what gets me.
04:44:50FromDiscord<Gustavo6046> My nametag example doesn't seem to reproduce this strange issue even if I make it closer to what the real example was.
04:45:09FromDiscord<Elegantbeef> I dont follow, it got a type mismatch and printed the procedure(s) which was closest to what you wanted
04:45:20FromDiscord<Gustavo6046> In reply to @Elegantbeef "Well i know it's": It's simple, though, and in this case I think one module suffices it show it.
04:45:23FromDiscord<Gustavo6046> A) works, B) doesn't.
04:45:24FromDiscord<Gustavo6046> A):
04:45:31FromDiscord<Gustavo6046> B):
04:45:37FromDiscord<Gustavo6046> sent a code paste, see https://paste.rs/ebh
04:45:51FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZc
04:45:55FromDiscord<Elegantbeef> "one module suffices"... `import vector` 😀
04:46:11FromDiscord<Gustavo6046> `Vector3` is just a `array[3, float64]` with some operator overloads
04:46:23FromDiscord<Gustavo6046> I don't see why that would cause issues
04:46:33FromDiscord<Gustavo6046> Nonetheless, I did your suggestion of implementing `check_collision` for two `Vector3` . That somehow fixed the error.
04:46:38FromDiscord<Elegantbeef> Well i meant for me to test the code and see the error
04:46:41FromDiscord<Gustavo6046> Ah
04:48:20FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3wZd
04:49:49FromDiscord<Gustavo6046> Yep
04:50:38FromDiscord<Gustavo6046> But for some reason, without implementing the `check_collision(Vector3, Vector3)`, calling it in the implementation of `check_collision(CollidableWorld)` raises errors.
04:51:40FromDiscord<Elegantbeef> I'm trying to understand why you think it shouldnt cause an error
04:52:37FromDiscord<Elegantbeef> You're attempting to call a procedure `checkCollision` that takes `Vector3, Vector3` which doesnt exist
04:53:41FromDiscord<Gustavo6046> In reply to @Elegantbeef "You're attempting to call": `CollidableWorld` items are `Collidable`, not `Vector3`.
04:55:29FromDiscord<Elegantbeef> Ok so what's your present input data then
04:55:45FromDiscord<Elegantbeef> Like https://play.nim-lang.org/#ix=3wZe
04:58:24FromDiscord<Gustavo6046> Ah well
04:58:30FromDiscord<Gustavo6046> it works in play.nim-lang.org if I merge it into one module
04:58:32FromDiscord<Gustavo6046> but not for me
04:59:02FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZg
04:59:11FromDiscord<Gustavo6046> Where do you think I'm calling it for Vector3? I'm not
05:00:04FromDiscord<Elegantbeef> I thought the one error said that mismatch, but looking back seems i was wrong
05:02:42FromDiscord<Gustavo6046> It was this
05:02:58FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZj
05:03:09FromDiscord<Gustavo6046> (edit) "https://play.nim-lang.org/#ix=3wZj" => "https://play.nim-lang.org/#ix=3wZk"
05:03:17FromDiscord<Gustavo6046> (the other lines are because test case)
05:03:18FromDiscord<Gustavo6046> (edit) "https://play.nim-lang.org/#ix=3wZk" => "https://play.nim-lang.org/#ix=3wZl"
05:04:09FromDiscord<Elegantbeef> Whatever the `Collidable` is in this case is missing a `checkCollision` procedure
05:04:51FromDiscord<Elegantbeef> Collidable isnt a concrete type remember, it's just a type that quacks like that concept
05:09:52FromDiscord<Gustavo6046> Well, nothing is calling `check_collision` for `CollidableWorld` yet
05:10:03FromDiscord<Gustavo6046> It was just for a `YPlane` in this test case:
05:10:23FromDiscord<Gustavo6046> sent a code paste, see https://play.nim-lang.org/#ix=3wZo
05:10:53FromDiscord<Gustavo6046> Ignore that last part where I printed 30 of them and posted them here earlier lol
05:11:36FromDiscord<Gustavo6046> (edit) "https://play.nim-lang.org/#ix=3wZo" => "https://play.nim-lang.org/#ix=3wZp"
05:12:25FromDiscord<Elegantbeef> Which line is the error?
05:14:13FromDiscord<Gustavo6046> It was earlier in `ray_interface` in the line that called `check_collision` for `obj` (which was also `world[ind]`)
05:16:51FromDiscord<Elegantbeef> Ah so this just might be the odd binding of concepts, and the procedure not being accessible
05:23:26FromDiscord<Gustavo6046> Ah
05:24:47FromDiscord<ondrejoda> sent a code paste, see https://play.nim-lang.org/#ix=3wZt
05:25:15FromDiscord<Elegantbeef> Cause color is a reference object in this case so you need to do `new result`
05:25:23FromDiscord<ondrejoda> oh
05:25:28FromDiscord<ondrejoda> and it returns itself?
05:26:03FromDiscord<ondrejoda> by that i mean that i don't have to write `return result` at the end of the proc
05:26:36FromDiscord<Elegantbeef> result is an implicit return value
05:27:27FromDiscord<Elegantbeef> Also is there a reason you're using a `ref object` for colour?
05:28:12FromDiscord<codic> yeah you often don't need to
05:28:34FromDiscord<codic> you can also write `(r, g, b, a: uint8)`
05:28:42FromDiscord<ondrejoda> well i wanted to make my own object
05:28:51FromDiscord<codic> you can use plain object
05:28:56FromDiscord<ondrejoda> but i didn't know that it doesn't have to be a ref
05:28:57FromDiscord<codic> no real need for ref object in this case
05:29:11FromDiscord<codic> ref object = passed around by reference
05:29:25FromDiscord<codic> it's just a shorthand for in every plcae you use it making the type ref T instead of T iirc
05:29:46FromDiscord<ondrejoda> i get that↵ok, so i will replace that
05:30:09FromDiscord<Elegantbeef> With that change you dont need `new result`
05:30:18FromDiscord<Elegantbeef> since `new` initializes a reference
05:30:40FromDiscord<ondrejoda> figured
05:32:03FromDiscord<Elegantbeef> also you'll want to rename it `initColor` since it's a non reference
05:32:19FromDiscord<Elegantbeef> That's the convention atleast
05:36:07FromDiscord<impbox [ftsf]> sent a code paste, see https://paste.rs/6BN
05:36:31FromDiscord<Elegantbeef> Indeed, with ref or non ref aswell
05:36:37FromDiscord<impbox [ftsf]> yep
05:36:49FromDiscord<Elegantbeef> Or you can drop the `result =` and be cool
05:36:56FromDiscord<impbox [ftsf]> that's too confusing for me
05:37:26FromDiscord<impbox [ftsf]> `proc newColor(r:uint8, g:uint8, b:uint8, a:uint8): Color = Color(r: r, g: g, b: b, a: a)`
05:37:44FromDiscord<impbox [ftsf]> (edit) "newColor(r:uint8, g:uint8, b:uint8, a:uint8):" => "newColor(r,g,b,a: uint8):"
06:05:59*PMunch joined #nim
06:07:29FromDiscord<retkid> In reply to @Yardanico "<@217459674700578816> are you on": arch\
06:28:52FromDiscord<enthus1ast> @Gustavo6046\: btw you can annotate the concept with the {.explain.} pragma then it should give more hints why a concept does not match
06:29:03FromDiscord<Gustavo6046> ahh
06:30:08FromDiscord<Gustavo6046> In reply to @codic "ref object = passed": Isn't it better for large values to pass by reference rather than copying the raw values everytime? Or is that only when "copying"?
06:30:18FromDiscord<Gustavo6046> I remember Rust makes a big deal of things like this
06:30:28FromDiscord<Gustavo6046> Anyway I'm of to bed now
06:30:29FromDiscord<Gustavo6046> Cya!
06:30:38FromDiscord<Elegantbeef> Depends what you're doing Nim passes by reference for large objects
06:30:52FromDiscord<Elegantbeef> Nim doesnt do copy on write for variable assignment though
06:31:20FromDiscord<Gustavo6046> ah
06:31:47FromDiscord<Elegantbeef> you can also annotate the typedef with `{.byCopy.}` or `{.byRef.}` to force it to always be one
06:57:14madpropshow can I raise with a simple message?
06:57:20madpropsdo I have to specify an exception type?
06:58:20madpropsoh I think not
06:58:33FromDiscord<Rika> you can use a generic `CatchableError` for your exception type
06:58:41FromDiscord<Rika> i think its called catchable error, i forget
07:00:21madpropsthanks that works
07:12:21madpropsis doAssertRaises a way to check if a call "succesfully" raises and exception on integration tests?
07:14:30madpropsI just want to check some cases where the proc is supposed to raise an exception, or is that silly?
07:15:03FromDiscord<Elegantbeef> That's what `doAssertRaises` is for
07:15:34madpropsdon't think I understand it though..
07:16:03madpropstried something like https://dpaste.org/tooa
07:16:39FromDiscord<Elegantbeef> Yea that block doesnt raise `CatchableError`
07:18:23FromDiscord<Elegantbeef> Something like this is proper https://play.nim-lang.org/#ix=3wZJ
07:18:44FromDiscord<Elegantbeef> Imagine the raise is done by giving incorrect data instead of the bool
07:20:04madpropsah I see, thanks
07:24:56madpropswhat's the purpose of: Warning: No nimblemeta.json file found in ...[path] on every compilation ?
07:25:06madpropsit's from a program unrelated to the current project
07:25:11madpropswhich I installed with nimble
07:26:50madpropsactually only happens on `nimble test`
07:28:17madpropscan't remove the package
07:28:44madpropsError: unhandled exception: cannot read from file: thepackage/nimblemeta.json [IOError]
07:29:34madpropswhen I removed it manually
07:29:47madpropswell*
07:32:33*Vladar joined #nim
07:54:01*max22- joined #nim
07:56:42PMunchI've seen some errors recently with regards to the playground. Turns out it OOMed when the log file from a container got too large (whoops). I've tweaked the server to truncate logs now, and also done some changes to the OOM policy on the server, so the playground should be much more stable and resilient to malicious code now :)
07:59:21FromDiscord<Elegantbeef> Nice, i'll try not to crash it so much
07:59:34FromDiscord<Yardanico> there are also some alternatives (not saying that playground is bad :P)
07:59:36FromDiscord<Yardanico> e.g. wandbox.org
07:59:46FromDiscord<Yardanico> replit.com (they finally updated to 1.4.8)
07:59:55FromDiscord<Yardanico> wandbox.org even has a devel version
08:00:42FromDiscord<Elegantbeef> Pmunch following behind 😛
08:00:49FromDiscord<Elegantbeef> "falling" is the proper verb, my brain is dumb
08:01:03PMunchYeah I know, still nice to have the official playground a bit more stable :P
08:01:06FromDiscord<Yardanico> apparently in replit you even get access to a shell https://media.discordapp.net/attachments/371759389889003532/880361197390680064/unknown.png
08:01:29FromDiscord<Yardanico> (the dir name is the default random name of the repl session)
08:02:21PMunchI'd like to build devel images on the playground as well, but it's not the most powerful of things so I fear it might make it pretty slow or fill up the disk..
08:02:49FromDiscord<Elegantbeef> Could get nightlies
08:03:08FromDiscord<Elegantbeef> Not the best but hey some devel
08:03:47PMunchYeah that is what I was thinking
08:04:18PMunchHmm, I guess it wouldn't have to build them from scratch. Could just grab the latest nightly in a container
08:05:00*Vladar quit (Quit: Leaving)
08:06:37FromDiscord<Elegantbeef> I may take a look at adding some stuff tomorrow, mostly the local storing of files and ability to give the parameters to the compiler directly
08:07:12FromDiscord<Elegantbeef> The local storing is front end only so easier t odo
08:08:25PMunchThe frontend should really get a touch-up as well
08:09:59FromDiscord<Yardanico> also a really small nitpick which can probably be fixed with a really small fix - reverse ordering in the version selection dropdown
08:10:05FromDiscord<Yardanico> so it sorts from v1 to v0 and not the other way
08:12:06PMunchI just sorted it lazily that way so latest would be on top and the default :P
08:12:24PMunchBut yeah, that'd be an easy fix as well
08:18:43*jjido joined #nim
08:45:03PMunchHmm, not sure if Nim in general has just gotten better or if my standards have dropped. But I feel like lately that stuff increasingly "just works" when I program in Nim
08:45:30PMunchJust downloaded 16 month old bindings for libclang and they work perfectly
08:46:53FromDiscord<Rika> You’re probably doing less sketchy stuff
08:51:27PMunchHmm, maybe.. But somehow I doubt it :P
08:58:08FromDiscord<Varriount> Anyone want to guess how long writing this comment took? https://github.com/nim-lang/RFCs/issues/411#issuecomment-906221395
09:00:00FromDiscord<hugogranstrom> 3 days? :P
09:00:13FromDiscord<Elegantbeef> Rumour has it he's still writing
09:00:29FromDiscord<hugogranstrom> xD
09:02:27FromDiscord<xflywind> In reply to @Varriount "Anyone want to guess": links are broken
09:03:02FromDiscord<xflywind> > nim-lang/Nim#17898 had a perfectly viable solution without modifying how initRand works.↵> nim-lang/Nim#18729 has a miniscule amount of overhead - amortized over time, it's a single boolean check. Overhead must always be considered in the context it occurs in.
09:03:31FromDiscord<Varriount> Gosh darn it
09:03:46FromDiscord<Elegantbeef> Now for the joke of "clearly not enough time spent writing"
09:04:01FromDiscord<Varriount> 4 hours
09:08:38FromDiscord<enthus1ast> I also have this impression, thanks to stable releases and back porting effort I guess↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>)
09:12:28FromDiscord<Varriount> In reply to @Elegantbeef "Now for the joke": You try digging through Intel's instruction set documentation and Linux's source code for 4 hours, and see if your head doesn't spin.
09:13:50FromDiscord<Varriount> Though, actually, Intel's documentation was rather well organized.
09:14:03PMunchGiven a table from something to a sequence, is there an easy way to add something to that sequence given a key, creating a new sequence to add to if the key doesn't exist in the table?
09:14:47FromDiscord<Varriount> getOrDefault?
09:14:52FromDiscord<Elegantbeef> It's not lazily evaluated but `hasKeyOrPut`
09:15:19FromDiscord<Neko~Neko~ni> sent a long message, see http://ix.io/3x08
09:15:55PMunchmgetOrPut seems like what I need
09:15:57FromDiscord<Elegantbeef> well you have an unscoped global variable
09:16:01*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
09:16:03FromDiscord<Elegantbeef> Nim's variables have sensible scope
09:16:22FromDiscord<Elegantbeef> you can do `var someVar {.global.} = 100` inside a procedure to make it global but scoped to the function
09:17:12FromDiscord<Elegantbeef> Uncertain what the code looks like so cannot say much to what's best
09:18:13FromDiscord<Neko~Neko~ni> In reply to @Elegantbeef "you can do `var": Sorry but what do you exactly mean by that?
09:19:30FromDiscord<Elegantbeef> For instance
09:19:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3x0a
09:20:45FromDiscord<Neko~Neko~ni> i see,thanks
09:21:17FromDiscord<Elegantbeef> If that doesnt help feel free to write a minimal example and i'll suggest something else
09:45:37*jjido joined #nim
09:52:22*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
10:09:05*Pyautogui joined #nim
10:11:01*Pyautogui quit (Client Quit)
10:38:58*xet7 quit (Remote host closed the connection)
10:41:31*xet7 joined #nim
10:42:58*Vladar joined #nim
10:53:03*auxym_ joined #nim
10:59:09FromDiscord<gogolxdong (liuxiaodong)> How to get the home dir of current user, like windows is C\:/Users/admin
11:00:54FromDiscord<Yardanico> https://nim-lang.org/docs/os.html#getHomeDir
11:01:10FromDiscord<Yardanico> you can just search "home" in the search bar in docs
11:04:32FromDiscord<gogolxdong (liuxiaodong)> ok, thanks
11:05:50*jjido joined #nim
11:13:41*max22- quit (Quit: Leaving)
11:15:45*auxym_ quit (Ping timeout: 248 seconds)
11:41:36*stkrdknmibalz quit (Quit: WeeChat 3.0.1)
12:06:02*supakeen quit (Quit: WeeChat 3.2)
12:06:31*supakeen joined #nim
12:10:11*arkurious joined #nim
12:17:07*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
12:31:59*flynn quit (Read error: Connection reset by peer)
12:33:07*flynn joined #nim
12:56:56*jjido joined #nim
13:14:30FromDiscord<gerwy> umm i know its maybe a stupid thing to ask
13:15:06FromDiscord<gerwy> but how would i remove certain characters from string? i don't see any remove function that would remove one character from string in manual
13:15:37FromDiscord<enthus1ast> replace?
13:15:49FromDiscord<enthus1ast> https://nim-lang.org/docs/strutils.html#replace%2Cstring%2Cstring%2Cstring
13:16:06PMunchYeah, just replace with an empty string works
13:16:10FromDiscord<Recruit_main707> replace("someting", "")
13:16:25FromDiscord<gerwy> aah so that way
13:16:39FromDiscord<gerwy> Thanks!
13:17:19FromDiscord<gerwy> and i see there is multiReplace which is good because i need to get rid of quiet a few characters
13:19:51FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3x12
13:22:15FromDiscord<gerwy> too much work i think, replace should do the work
13:27:39*jfinkhaeuser joined #nim
13:30:03*rockcavera joined #nim
13:30:03*rockcavera quit (Changing host)
13:30:03*rockcavera joined #nim
13:33:04*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
13:59:27PMunchHmm, trying to use libclang to parse C header files and generate the corresponding Nim bindings. Seems promising so far
14:00:44*PMunch quit (Quit: Leaving)
14:01:42FromDiscord<macaroni> hey there, I was wondering, how can I pass command line arguments to a nim executable? For example running from the terminal ./main arg1 arg2
14:02:14FromDiscord<gerwy> paramStr([index of the argument])↵i think
14:02:22FromDiscord<gerwy> in os module
14:03:01FromDiscord<Rika> https://nim-lang.org/docs/os.html#paramStr%2Cint
14:03:13FromDiscord<Rika> or commandLineParams
14:03:50FromDiscord<macaroni> @gerwy @Rika thank you both!
14:22:27*vsantana joined #nim
14:22:57*pch_ joined #nim
14:23:00*pch quit (Read error: Connection reset by peer)
14:32:07*def- quit (Quit: -)
14:32:18*def- joined #nim
14:35:45*vsantana quit (Quit: Client closed)
14:36:14*auxym_ joined #nim
14:49:38FromDiscord<enthus1ast> @macaroni\: for more sophisticated command line handling also have a look at\: https://github.com/c-blake/cligen
14:49:40nrds<R2D299> itHub: 7"Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs At"
15:25:04FromDiscord<Yardanico> or docopt
15:43:23arkanoidPMunch, is it better than tree-sitter?
15:43:27arkanoidoh, he left
15:57:06FromDiscord<haxscramper> liblcang vs tree sitter?↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
16:00:33FromDiscord<Recruit_main707> sent a code paste, see https://play.nim-lang.org/#ix=3x1Y
16:02:23FromDiscord<Rika> whats the issue?
16:02:42FromDiscord<Rika> oh
16:02:48FromDiscord<Rika> eh? no other changes?
16:02:49FromDiscord<Rika> are you sure
16:02:55FromDiscord<Recruit_main707> yes
16:03:05FromDiscord<Rika> so offset just suddenly changes?
16:03:10FromDiscord<Recruit_main707> apparently
16:03:24FromDiscord<Rika> can you reproduce with another example
16:03:29FromDiscord<Recruit_main707> ill try
16:04:40*auxym_ quit (Ping timeout: 240 seconds)
16:10:06FromDiscord<Recruit_main707> after that i call `GetVal[T](addr seq)` which casts a seq of bytes to something (float32 in this case),↵removing it makes the error disappear
16:10:18FromDiscord<Recruit_main707> 🥴
16:11:12FromDiscord<Yardanico> you can't do a cast like that
16:11:21FromDiscord<Yardanico> you need `addr seq[0]` not `addr seq`
16:11:29FromDiscord<Yardanico> because seq has a header with capacity and other internal stuff at the start
16:11:33FromDiscord<Recruit_main707> i handle it inside the function
16:11:38FromDiscord<Yardanico> how
16:11:44FromDiscord<Yardanico> `addr seq` doesn't look very safe :P
16:13:01FromDiscord<Recruit_main707> basically dereference it and then get the address of the 0th element, but thats besides the point isnt it
16:13:34FromDiscord<Yardanico> well a lot of funny things can happen, like this seq being destroyed by the GC
16:14:18FromDiscord<Recruit_main707> still that cannot cause my issue
16:46:32*flynn quit (Read error: Connection reset by peer)
16:47:39*flynn joined #nim
16:59:34*xet7 quit (Remote host closed the connection)
17:03:20*auxym_ joined #nim
17:07:18*xet7 joined #nim
17:08:49*auxym_ quit (Ping timeout: 248 seconds)
17:22:17*auxym_ joined #nim
17:33:50*perro quit (Read error: Connection reset by peer)
17:38:00*perro joined #nim
17:43:28*tiorock joined #nim
17:43:28*tiorock quit (Changing host)
17:43:28*tiorock joined #nim
17:43:28*rockcavera quit (Killed (tungsten.libera.chat (Nickname regained by services)))
17:43:28*tiorock is now known as rockcavera
17:45:02*rockcavera is now known as Guest9186
17:45:02*tiorock joined #nim
17:45:02*Guest9186 quit (Killed (cadmium.libera.chat (Nickname regained by services)))
17:45:02*tiorock is now known as rockcavera
17:50:13*andinus joined #nim
17:54:21*jjido joined #nim
17:59:47auxym_Anyone have an idea what is going here? https://play.nim-lang.org/#ix=3x2D It won't run on playground, possibly because of unsafeAddr, so run it locally if possible...
18:00:51FromDiscord<Recruit_main707> unsafeAddr does work on playground so that cant be the reason afaik
18:01:08*nrds quit (Remote host closed the connection)
18:01:20FromDiscord<Recruit_main707> what are you trying to do?
18:01:29auxym_I'm trying to use the raw pointer of a `ref object` as a hash value for tables, but getting weird behavior. Seems to work OK when adding using []=, but doing the same in a proc call results in the same key apparently getting added to the table twice
18:01:37*nrds joined #nim
18:01:48FromDiscord<haxscramper> https://wandbox.org/permlink/oCPMOzRpmJuwMiqe
18:02:05FromDiscord<haxscramper> same code, but at least not "killed"
18:02:44auxym_thanks. Same behavior I get locally. As you can see from the last 3 lines, my table has 2 keys with the same hash ??
18:05:04auxym_Is using `unsafeAddr.hash` as a hash value a bad idea for object refs? Any other suggestions? I want a table/hashset that can hold instances of ref objects that are identical in fields but are actually different instances
18:05:21FromDiscord<Recruit_main707> > I'm trying to use the raw pointer of a ref object as a hash value↵you are not doing it correctly though, thats getting the address of the argument isnt it?
18:05:48FromDiscord<Recruit_main707> it should be something like cast[pointer](x).hash i guess
18:06:07auxym_My understanding is that unsafeAddr returns a `pointer` and then `hash[pointer
18:06:32auxym_ and then `hash[pointer]` for the hashes module uses the address to create a `Hash`
18:06:43FromDiscord<dom96> auxym_: what is your goal?
18:06:49FromDiscord<Recruit_main707> returns the pointer of what you pass, but you are already passing the pointer (reference), so thats the pointer to a pointer
18:06:50FromDiscord<dom96> hashing refs like this seems like a really bad idea
18:07:35auxym_dom96: I want a table/hashset that can hold instances of ref objects that are identical in fields but are actually different instances. Similar to default behavior to python object instances IIRC
18:08:07auxym_Recruit_main707: ah... makes sense. Using the cast sounds like a bad idea though.
18:08:38FromDiscord<dom96> what's the even higher-level goal here? 🙂
18:10:21auxym_creating a simple graph structure that's basically a `type Graph[T] = Table[T, HashSet[T]]`. And can hold identical but separate instances of ref objects
18:12:46*byanka quit (Ping timeout: 268 seconds)
18:13:51FromDiscord<dom96> why do you need it to hold identical but separate instances of ref objects?
18:14:01FromDiscord<s_tmux> var chicken = good↵echo chicken↵↵what am i doing wrong here?
18:16:22auxym_dom96: Good point. I could live without it. At worst add a uuid field to my objects to differentiate them. I guess my python background is showing.
18:17:26*supakeen quit (Remote host closed the connection)
18:17:50*supakeen joined #nim
18:18:55auxym_s_tmux: `var chicken = "good"` ? (the quotes?)
18:19:13FromDiscord<dom96> yes, that would be much better than having to rely on `unsafeAddr` and other unsafe mechanisms
18:19:40auxym_yeah. Thanks. I'll get something like that going.
18:20:16FromDiscord<s_tmux> oh right thanks
18:22:06FromDiscord<haxscramper> if you really want you can do `cas[int](Rf)`
18:24:57*Gustavo6046 quit (Ping timeout: 250 seconds)
18:25:06auxym_Yeah. I guess. I don't like the idea, sounds sort of unsafe and dependant on Nim's implementation of refs
18:25:37auxym_Which is probably not guaranteed to be stable across GCs, etc.
18:28:45FromDiscord<Zachary Carter> `unpackVarargs` is nice
18:29:07FromDiscord<Zachary Carter> sent a code paste, see https://paste.rs/LE0
18:31:48*Gustavo6046 joined #nim
18:32:08FromDiscord<s_tmux> sent a code paste, see https://play.nim-lang.org/#ix=3x2V
18:32:16FromDiscord<Zachary Carter> `echo repr response`
18:32:20FromDiscord<Zachary Carter> if `response` is a `ref object`
18:32:32FromDiscord<Zachary Carter> otherwise if it's a plain `object` or `tuple` you can just `echo response`
18:32:54FromDiscord<talaing> Hello, how can I send `application/x-www-form-urlencoded` data using `httpclient` module?
18:33:01FromDiscord<Zachary Carter> google
18:33:04FromDiscord<Zachary Carter> is how
18:33:14FromDiscord<Zachary Carter> and stdlib docs
18:33:22FromDiscord<dom96> In reply to @Zachary Carter "if `response` is a": you can also just `echo response[]` if it's a ref
18:33:32FromDiscord<Zachary Carter> or yeah - dereference the ref
18:33:34FromDiscord<Zachary Carter> that works too
18:36:59FromDiscord<Zachary Carter> In reply to @talaing "Hello, how can I": honestly the best thing to do is just learn to use github search
18:37:04FromDiscord<Zachary Carter> it's basically how I learned Nim
18:37:21FromDiscord<Zachary Carter> reading other people's source code, regardless of what language you're trying to learn, is an invaluable resource
18:37:27*max22- joined #nim
18:37:48FromDiscord<Zachary Carter> I bet if you do a search on github for `application/x-www-form-urlencoded` and `httpclient` and set the language filter to `Nim` you'll find what you're looking for 😉
18:38:05FromDiscord<dom96> Elite Tip right there
18:38:34FromDiscord<talaing> I don't use GitHub search very often, usually I just google the issue
18:38:40FromDiscord<talaing> thank you for your tip 🙂
18:38:44FromDiscord<Zachary Carter> Yeah, no problem!
18:39:55FromDiscord<talaing> Found it in less than 1 minute
18:40:06FromDiscord<talaing> I'm gonna use GH search more often
18:40:10FromDiscord<talaing> Thank you 😄
18:40:15FromDiscord<Zachary Carter> 😄
18:40:21FromDiscord<Zachary Carter> You're very welcome 🙂
18:40:24FromDiscord<Zachary Carter> (edit) "welcome 🙂" => "welcome!"
18:41:30FromDiscord<dom96> This makes me wonder, are there any services for companies that crawl their code bases and index them into a nice search engine? I feel like that'd be a pretty nice SaaS opportunity
18:44:52*SebastianM joined #nim
18:44:56FromDiscord<s_tmux> what is a proc? https://nim-lang.org/docs/httpclient.html#12
18:46:13FromDiscord<dom96> a different name for a function
18:46:14FromDiscord<dom96> https://en.wikipedia.org/wiki/Subroutine
18:47:19FromDiscord<s_tmux> thanks dom
18:47:56FromDiscord<s_tmux> sent a code paste, see https://play.nim-lang.org/#ix=3x2X
18:50:12FromDiscord<dom96> In reply to @dom96 "This makes me wonder,": of course, all good ideas have already been implemented by somebody else: https://about.sourcegraph.com/ 🙂
18:50:40*byanka joined #nim
18:51:57FromDiscord<s_tmux> i was gonna start inventorying wirless networks in my local area, had a plan for it and everything.. then yesterday i found wigle.net
18:58:41FromDiscord<Cark> I'm trying to do multithreading, but it's quite the rabbit hole ... This heap per thread business is frightening. For instance i'm trying to access a global (for now) seq from a withLock call... what happens if the seq allocates memory when adding to it from the thread ? will this memory possibly be allocated on the wrong heap ?
19:00:25FromDiscord<Cark> Maybe I'm supposed to only use Channels forgoing any sharing ? but doesn't orc fix some of this ?
19:01:20FromDiscord<Cark> i've been scouring the web and reading for hours, but i feel like some of the things i find are outdated, i'm not quite sure what is safe and what isn't
19:02:52FromDiscord<Cark> I think i could go full C in nim, but i like those seqs and strings
19:03:17FromDiscord<Cark> and the standard library at large
19:05:17FromDiscord<dom96> Step back a bit, why are you going after multithreading?
19:05:22FromDiscord<Recruit_main707> yeah, i dont like how you work with threads in nim
19:05:35FromDiscord<Recruit_main707> i hope it improves i the future
19:05:44FromDiscord<Cark> @dom96 I have to, i'm doing a windows service
19:06:03FromDiscord<Cark> also any software needs those these days
19:06:16FromDiscord<s_tmux> is there a argv client or something i can use to write command line app?
19:06:59FromDiscord<dom96> In reply to @Cark "<@!132595483838251008> I have to,": why does a windows service require it?
19:07:42FromDiscord<Cark> you need to do a blocking call and do the work in a thread
19:09:04FromDiscord<dom96> interesting
19:09:38FromDiscord<Cark> well i shouldn't have mentioned it, because virtually all the program is in this thread and there is no real communication
19:10:11FromDiscord<Cark> but i'm afraid diving very deep in nim if i can't get multithreading right
19:10:32FromDiscord<Cark> when i can do it in C in a straightforward manner
19:10:55FromDiscord<dom96> Maybe the simplest approach would be to write a quick wrapper in C/C++ that spawns a new thread and calls the Nim program in it
19:11:17FromDiscord<dom96> That way you can pretend that there is just a single thread in Nim
19:11:53FromDiscord<Cark> that makes sense
19:12:27FromDiscord<dom96> alternatively you can also do your best to avoid global vars
19:12:41FromDiscord<Cark> right, but how do you do sharing ?
19:12:43FromDiscord<dom96> which is a good practice anyway
19:12:56FromDiscord<dom96> just pass data around via function args
19:13:09FromDiscord<Cark> i'm using global just for testing, because it seems enclosing the shared stuff is even more hairy
19:13:29FromDiscord<dom96> what stuff do you need to share?
19:13:49FromDiscord<dom96> what I typically have is a `State` object that contains the common things everything in the app needs
19:14:10FromDiscord<Cark> ok right now as an exercise i'm doing some logging
19:14:27FromDiscord<Cark> so you have the consol logger and maybe a rotating file logger
19:14:34FromDiscord<Cark> which you could add to that seq
19:14:43FromDiscord<Cark> i'll never touch those really
19:14:53FromDiscord<Cark> but i want to be able to as an exercise
19:15:01FromDiscord<Cark> add them from the main thread
19:15:14FromDiscord<Cark> and have the logging thread use them
19:15:45FromDiscord<dom96> do the logging from the main thread, why have a separate thread for it?
19:16:03FromDiscord<Cark> in order to exercise multithreading with nim =)
19:16:59FromDiscord<Cark> also
19:17:12FromDiscord<Cark> in my service i'll want logging from the main thread and from the work thread
19:17:30FromDiscord<Cark> it makes sense to have a logging thread
19:17:37FromDiscord<dom96> meh, you're just making the code more complex than it needs to be 🙂
19:18:30FromDiscord<Cark> well that the point ! i really don't even need to make a service =)
19:18:42FromDiscord<dom96> lol
19:18:50FromDiscord<Cark> i could wrap a command line program in that automatic service thingie i forgot the name of
19:19:02FromDiscord<Cark> but then i would learn nothing =)
19:19:47FromDiscord<dom96> if you want to learn multithreading then consider picking a use case that requires it, for example utilising all your CPU's cores
19:20:00FromDiscord<dom96> one example is parsing which I used in my book's chapter on parallelism 😉
19:20:27FromDiscord<Cark> i think it's a common use case, delegating IO to a dedicated thread
19:21:19FromDiscord<Cark> there are timing constraints on windows srvices (which i probably could meet in a single thread but hum yeah)
19:26:55*auxym_ quit (Ping timeout: 250 seconds)
19:28:03*auxym_ joined #nim
19:31:09FromDiscord<enthus1ast> I've done some work on an windows service in nim, maybe you can build on this code\: https://github.com/enthus1ast/nimWindowsService
19:31:12nrds<R2D299> itHub: 7"[WIP] a simple windows service in nim-lang"
19:31:40FromDiscord<Cark> oh i think i indeed di have a look at it !
19:31:44FromDiscord<Cark> (edit) "di" => "did"
19:31:53FromDiscord<enthus1ast> and if you make it better please PR ;)
19:35:09FromDiscord<enthus1ast> oh windows service should use threads
19:35:40FromDiscord<Cark> well i'm no authority on the subject, that was my understanding
19:36:04*neurocyte830 joined #nim
19:36:20*neurocyte830 is now known as neurocyte
19:40:34FromDiscord<s_tmux> sent a code paste, see https://play.nim-lang.org/#ix=3x3h
19:43:13*SebastianM quit (Quit: Bye)
20:02:01FromDiscord<ajusa> Anyone know why↵` output = socket.recv(3, timeout = 5000)` returns data inside of output but↵` output = socket.recv(1000, timeout = 5000)` doesn't? I was expecting that the second would read up to 1000 bytes, and if there aren't that many, after the timeout it would return all it read
20:02:04*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
20:11:08*flynn quit (Read error: Connection reset by peer)
20:11:34*jjido joined #nim
20:12:14*flynn joined #nim
20:16:28FromDiscord<RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3x3x
20:19:17*Vladar quit (Quit: Leaving)
20:26:36*auxym_ quit (Ping timeout: 250 seconds)
20:43:11FromDiscord<dom96> In reply to @ajusa "Anyone know why `": I believe those are the semantics but check the docs
20:50:52FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3x3F
20:52:06FromDiscord<Cark> you could wrap it in an object variant
20:52:28FromDiscord<Cark> https://nim-lang.org/docs/manual.html#types-object-variants
20:55:26FromDiscord<Ayy Lmao> In reply to @Cark "you could wrap it": I will have to experiment with that.
20:56:55*Gustavo6046 quit (Ping timeout: 252 seconds)
20:57:07FromDiscord<Zachary Carter> @Cark you need to understand quite a bit about Nim's memory model before diving into multithreaded code IMHO
20:57:18FromDiscord<Zachary Carter> hint: ARC/ORC will get you a long way
20:57:31FromDiscord<Cark> @Zachary Carter that's the thing exactly
20:57:52FromDiscord<Cark> and my first question is all about that... but i'd like to find an authoritative resource
20:57:54FromDiscord<Zachary Carter> thread local heaps aren't too much of an issue, unless you're loading symbols from shared library or doing stuff where you have multiple Nim GC's
20:58:03FromDiscord<Zachary Carter> I mean I write quite a bit of multithreaded Nim code
20:58:08*Gustavo6046 joined #nim
20:58:20FromDiscord<Zachary Carter> I don't know if I qualify as an authoritative source
20:58:28FromDiscord<Zachary Carter> but what specific question(s) do you have?
20:59:07*mal``` joined #nim
20:59:17FromDiscord<Cark> so i don't need to worry when using a seq (inside a lock), it won't allocate memory from a thread specific heap ?
20:59:30FromDiscord<treeform> also if you use arc no more thread local heaps
20:59:32FromDiscord<Zachary Carter> it depends on what garbage collector you're using
20:59:43FromDiscord<Cark> i'm ready to use arc or orc
21:00:01FromDiscord<treeform> then you should be able to use locks and stuff like in C/C++
21:00:12FromDiscord<Zachary Carter> with ARC/ORC there are still thread local heaps
21:00:20FromDiscord<Cark> allright that's some pretty good news
21:00:24FromDiscord<Zachary Carter> it's just by default Nim will allocate ref objects on the shared heap
21:00:38FromDiscord<Zachary Carter> if you're manually allocating memory, you still need to call `createShared/allocShared`
21:00:52FromDiscord<Cark> ah so i need to have everything that's croos thread a ref ?
21:01:03FromDiscord<Zachary Carter> no
21:01:05FromDiscord<Cark> (edit) "croos" => "cross"
21:01:27FromDiscord<Zachary Carter> you need to allocate memory you want to share between threads on the shared heap
21:01:29*happycorsair[m]1 joined #nim
21:01:32FromDiscord<Zachary Carter> and pass pointers to it
21:01:36FromDiscord<Zachary Carter> or you can use refs
21:01:43*mal`` quit (Read error: Connection reset by peer)
21:01:43*happycorsair[m] quit (Ping timeout: 276 seconds)
21:01:52FromDiscord<Cark> allright, so ptr and ref does it
21:01:57FromDiscord<Zachary Carter> it's pretty much the same as with the normal GC
21:02:18FromDiscord<Zachary Carter> it's just the GC isn't going to be operating only on the thread local heap
21:02:30FromDiscord<Zachary Carter> there is no GC really, it's reference counting with move semantics, which you can consider a form of GC
21:02:54FromDiscord<Zachary Carter> the shared heap is only available when you compile with `threads:on`
21:03:04FromDiscord<Zachary Carter> which is kind of a duh thing
21:03:15FromDiscord<Cark> yes that part at least i got right =)
21:03:31FromDiscord<Zachary Carter> but yes you still need to use locks
21:03:36FromDiscord<Zachary Carter> if you want to access shared memory
21:03:42FromDiscord<Zachary Carter> or atomics or whatever concurrency primitive you want to employ
21:03:56FromDiscord<Zachary Carter> or you can try to write your program in a way where you don't have any shared memory
21:04:13FromDiscord<Zachary Carter> but this often times requires some careful planning and thinking ahead of time and isn't always possible
21:04:53FromDiscord<Cark> ok then, now let's say i have an object that is a ref, and it has a field that is a non ref object. will i have some copying going on behind the scene when passing it through a channel ?
21:05:01FromDiscord<ajusa> In reply to @dom96 "I believe those are": I did check the docs, but is there any way to get as much as a socket can read before it times out using net?
21:05:04FromDiscord<Zachary Carter> well objects aren't refs you have refs to objects
21:05:09FromDiscord<Cark> right
21:05:24FromDiscord<treeform> threading is hard its best to avoid, low performance threading (locks/polling) is easier then high performance threading...
21:05:26FromDiscord<Zachary Carter> I don't use channels with ARC/ORC
21:05:36FromDiscord<Zachary Carter> so I can't really comment
21:05:46FromDiscord<Cark> ok i can live without those
21:06:05FromDiscord<Zachary Carter> if you have a non-ref object that was allocated on the stack, my guess is that yes it would be copied
21:06:07FromDiscord<Cark> performance (to me) isn't an issue if the calls a coarse
21:06:28FromDiscord<Cark> ok that makes sense
21:06:35FromDiscord<Zachary Carter> it should be easy enough to test
21:07:00FromDiscord<Cark> ah but i worry about leaving heisenbugs due to my poor understanding
21:07:11FromDiscord<Zachary Carter> start simple
21:07:42FromDiscord<Zachary Carter> just write a program that starts a thread and write a thread proc that echos something you pass into it
21:07:49FromDiscord<Zachary Carter> go from there and experiment / play around
21:08:00FromDiscord<Zachary Carter> make sure you're setting the GC to ARC/ORC, and compiling with `threads:on`
21:08:05FromDiscord<Zachary Carter> what OS are you using?
21:08:12FromDiscord<Cark> i'm stricktly on windows =)
21:08:16FromDiscord<Cark> (edit) "stricktly" => "stricctly"
21:08:19FromDiscord<Cark> (edit) "stricctly" => "strictly"
21:08:34FromDiscord<Zachary Carter> Okay nevermind then, there is some thread local storage emulation that is enabled by default for macOS which can mess things up
21:08:43FromDiscord<Zachary Carter> for Windows everything should be fine
21:08:58FromDiscord<Zachary Carter> I have a bunch of multithreaded code you can stare at if you want to
21:09:01FromDiscord<Zachary Carter> I'm not sure if it will help at all
21:09:07FromDiscord<Cark> allright you aleviated my fear about using refs cross thread, and that was my main issue
21:09:12FromDiscord<Zachary Carter> it's for a fiber based job system
21:09:15FromDiscord<Zachary Carter> also I don't really use refs
21:09:19FromDiscord<Zachary Carter> I use `ptr`
21:09:31FromDiscord<Zachary Carter> I don't really like mixing threads with Nim's GC tbh
21:09:41FromDiscord<Cark> but aren't there issues having refs inside ptrs ?
21:09:44FromDiscord<Zachary Carter> and with custom destructors, it's easy enough not to have to
21:09:52FromDiscord<Zachary Carter> I just don't use refs...
21:10:04FromDiscord<Zachary Carter> if I'm passing things around between threads anyway
21:10:06FromDiscord<Cark> allright, but then what about strings and seqs ?
21:10:10FromDiscord<Zachary Carter> cstring
21:10:17FromDiscord<Zachary Carter> unchecked array
21:10:17FromDiscord<Cark> eeek
21:10:26FromDiscord<Zachary Carter> I also interop with a lot of C code too
21:10:39FromDiscord<Zachary Carter> I write games / game tech with Nim so...
21:10:51FromDiscord<Zachary Carter> memory safety isn't really a big concern of mine
21:10:59FromDiscord<Cark> can i search your name and find your stuff on github ?
21:11:07FromDiscord<Zachary Carter> yes my name is the same as my github profile
21:11:18FromDiscord<Cark> i can live without memory safety, but i like the nim facilities =)
21:11:45FromDiscord<RattleyCooper> In reply to @ajusa "I did check the": What are you trying to do? Are you able to send a header with the length of the message first, then recv that amount of data?
21:11:48FromDiscord<Zachary Carter> I feel you - but I don't really miss Nim's GC all that much. I still use it for stuff that stays in Nim land
21:12:31FromDiscord<Zachary Carter> but so much of the time I'm crossing the Nim/C|C++ boundary that I don't end up using the GC as much as I'm sure most Nim users do
21:12:49FromDiscord<Cark> allright, so your advice is use ptr cross thread, and i guess there is nothing bad about using strings and seqs in a contained manner
21:12:56FromDiscord<Zachary Carter> you can try refs
21:13:01FromDiscord<Zachary Carter> I just don't have much experience using them across threads
21:13:11FromDiscord<Zachary Carter> the problem with using refs across threads is this
21:13:31FromDiscord<ajusa> In reply to @RattleyCooper "What are you trying": This is exactly what I'm trying to do, and no I am not able to send a header. This is for generic internet scanning, I just want to open a random tcp connection and recv as much data in 10 seconds as I can
21:14:49FromDiscord<Zachary Carter> if you pass a managed ref to an object across a thread boundary, I'm not sure how the GC is going to behave
21:14:58*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
21:15:26FromDiscord<Zachary Carter> I'm not sure if the ref counting is going to work correctly and if the object pointed to will be collected at the right time
21:15:46*flynn quit (Read error: Connection reset by peer)
21:16:04FromDiscord<Cark> from what i read, ref counting isn't atomic, but that's no issue with locks so i guess it all good
21:16:11FromDiscord<Zachary Carter> When I did this across DLL boundaries in Nim it was hugely problematic for me because each Nim DLL had its own GC
21:16:29FromDiscord<Zachary Carter> and they aren't aware of one another - so passing GC'd memory across DLL boundaries caused big issues
21:16:35FromDiscord<Zachary Carter> with threads - maybe with ARC/ORC it's been figured out
21:16:49FromDiscord<Cark> but isn't arc a program transformation rather than an actual garbage collector ?
21:16:52*flynn joined #nim
21:17:12FromDiscord<Zachary Carter> it is - when I say collected I really mean destroyed
21:17:38FromDiscord<Cark> allright, you gave me confidence to keep experimenting
21:17:47FromDiscord<Cark> thanks a bunch !
21:17:51FromDiscord<Zachary Carter> yeah, no problem!
21:18:07FromDiscord<Cark> i'll be sure to plunder your code too =D
21:18:10FromDiscord<Zachary Carter> sorry I can't be more helpful on the ref situation, I just don't have much experience using them
21:18:28FromDiscord<Zachary Carter> yeah - feel free! if you have any specific questions about anything related to threading just lmk
21:18:42FromDiscord<Cark> i will
21:19:35*Guest38 joined #nim
21:20:41FromDiscord<RattleyCooper> In reply to @ajusa "This is exactly what": If it's TCP can't you loop and do multiple `recv`s? (since packets should be ordered, etc)
21:21:04FromDiscord<RattleyCooper> (edit) "`recv`s?" => "`recv`s with smaller packet size?"
21:21:16FromDiscord<RattleyCooper> (edit) "etc)" => "etc you should be able to put things back together)"
21:21:24FromDiscord<enthus1ast> you read from a stream, not packages
21:22:47FromDiscord<enthus1ast> so yes, you can do multiple recv in smaller chunks
21:25:22*Guest38 quit (Ping timeout: 246 seconds)
21:25:54FromDiscord<dom96> In reply to @ajusa "I did check the": that's usually an anti-pattern, what are you trying to do?
21:26:16FromDiscord<dom96> oh, I see above
21:26:57FromDiscord<enthus1ast> sure if you know the size of your entity before the read, you can read everything
21:26:57FromDiscord<dom96> I think you just want to recv 1 char at a time, the socket is buffered so you can do this efficiently
21:27:17FromDiscord<RattleyCooper> What does `<//>` do in nim?
21:27:40FromDiscord<RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3x3O
21:29:45FromDiscord<enthus1ast> https://github.com/nim-lang/Nim/blob/version-1-4/lib/system.nim#L873
21:29:58FromDiscord<enthus1ast> " # This is only required to make 0.20 compile with the 0.19 line."
21:30:22FromDiscord<dom96> sounds like we should get rid of it
21:30:45FromDiscord<dom96> (honestly this should have been called `legacyV019` or something instead of the cryptic `<//>`
21:30:48FromDiscord<dom96> (edit) "`<//>`" => "`<//>`)"
21:31:23FromDiscord<RattleyCooper> Ahhh, thanks!
21:33:24FromDiscord<ajusa> In reply to @dom96 "I think you just": ah, I think I get what you mean. Keep reading a single byte with the 10 second timeout - the only (minor) issue is that this could technically last longer than 10 seconds, as if a server gives me a byte every 9 seconds the timeout will reset
21:34:14FromDiscord<RattleyCooper> In reply to @ajusa "ah, I think I": If you want a minimum amount of bytes you could timeout if the minimum bytes you require have been received, else keep receiving
21:34:38FromDiscord<dom96> @ajusa I don't think you need the timeout, are you using async?
21:34:51FromDiscord<ajusa> nope, just normal sync `net`
21:35:09FromDiscord<dom96> it would be much easier with async 🙂
21:35:43FromDiscord<enthus1ast> then you could eg, peek on the socket
21:35:49FromDiscord<ajusa> async doesn't run everywhere IIRC - for example I heard it doesn't work on AWS lambda so I'd like to avoid it a bit. A `net` only solution should be a lot less work
21:35:57FromDiscord<enthus1ast> and to other stuff when not enough data is there
21:36:41FromDiscord<dom96> well, here is a secret: the timeouts are implemented using select() IIRC
21:36:51FromDiscord<dom96> so you're using a poor man's async already 🙂
21:37:09FromDiscord<dom96> I don't see why async specifically wouldn't work on lambda
21:37:59FromDiscord<ajusa> No clue, I'm basing it off of this reddit post (couple of years old though, maybe something has changed): https://www.reddit.com/r/nim/comments/9kgqwl/use_nim_on_aws_lambda/
21:39:05FromDiscord<ajusa> I think what I'll do is the following - ↵1. Read a byte in a loop with a 10 second timeout↵2. Keep track of the time elapsed outside of the loop and ensure that if it is longer than 10 seconds, I exit and return. ↵That should solve all of my problems. Thanks everyone for the help!
21:39:14FromDiscord<dom96> can't you write up a quick test and see if it works?
21:39:25FromDiscord<dom96> async doesn't use a threadpool so that person's theory is at least invalid
21:39:50FromDiscord<ajusa> In reply to @dom96 "can't you write up": Yeah, I will do that eventually ™️
22:00:25FromDiscord<RattleyCooper> Anybody know `osproc` well enough to give me some guidance on how I might convert my taskkillable ffmpeg launcher to be pure nim? Right now I'm relying on a python dll to handle launching the process and sending the "q" to the ffmpeg process to shut it down cleanly...
22:01:20FromDiscord<RattleyCooper> Last time I attempted it I failed miserably, but maybe this time it'll be different... Figure I'd check to see if anybody had any advice before I try again.
22:05:05*byanka quit (Read error: Connection reset by peer)
22:05:48*byanka joined #nim
22:10:31FromDiscord<dom96> where did you fail?
22:11:22madpropsis it possible to modify the index in an interator loop?
22:11:26madpropslike var i
22:12:42FromDiscord<treeform> In reply to @RattleyCooper "Anybody know `osproc` well": I find that I can do nearly everything with osproc. You probably need to start a process and poll it.
22:12:48FromDiscord<RattleyCooper> In reply to @dom96 "where did you fail?": Communicating with the process
22:12:50FromDiscord<treeform> And send it keyboard inputs at right times.
22:12:59FromDiscord<RattleyCooper> I need to send "q" to the processes's stdin
22:13:52FromDiscord<treeform> startProcess(..) then send q to its stdin?
22:14:24FromDiscord<treeform> p.inputHandle().write("q")
22:15:37FromDiscord<treeform> if you need to "talk" it to more you can outputHandle().read in while p.running:
22:17:37FromDiscord<RattleyCooper> Oh wow, yeah. I had first tried this I was writing basically nothing but python but now that's flipped lol. I was reading through the docs and it seems a lot more obvious now. Feel kinda silly asking. I'm gonna give the `inputHandle().write("q"` a shot, looks like it's exactly what I need. Thanks for the help everyone!
22:18:01FromDiscord<RattleyCooper> (edit) "`inputHandle().write("q"`" => "`inputHandle().write("q")`"
22:31:05madpropshow can I "return" to an if result here? https://play.nim-lang.org/#ix=3x42
22:37:04madpropsguess i need an intermediary variable instead of returning from an if/else
22:38:50FromDiscord<RattleyCooper> In reply to @madprops "guess i need an": Yeah, the code I've seen usually has some kind of `var res` that gets assigned to and returned at the end
22:38:57FromDiscord<RattleyCooper> (edit) "returned" => ""returned""
22:42:34madpropsis ther an `else` after loops?
22:42:51madpropsI found an old discussion
22:42:57madpropsbut don't know if it was implemented
22:45:32*byanka quit (Read error: Connection reset by peer)
22:45:55*byanka joined #nim
22:47:55FromDiscord<RattleyCooper> In reply to @treeform "p.inputHandle().write("q")": How do I get the `File` from the `FileHandle` returned by `inputHandle`? Come to think of it, I think this is actually where I got stuck last time
22:49:11*max22- quit (Remote host closed the connection)
22:49:36FromDiscord<RattleyCooper> Should I use `inputStream`?
22:54:13FromDiscord<RattleyCooper> Very confusing
22:54:57FromDiscord<RattleyCooper> `inputHandle` docs say "Returns p's input file handle for writing to.". In `io` there doesn't appear to be any `write` method for `FileHandle`s
22:56:13FromDiscord<RattleyCooper> in `io` there is an `open` proc that takes a `var File` but can't figure out how to create that `File`
22:56:25FromDiscord<Recruit_main707> is there any symbol for `and` (like `|` for `or`)
22:57:04FromDiscord<ynfle (ynfle)> In what context? `&`?
22:57:15FromDiscord<ynfle (ynfle)> @RattlyCooper, var f\: File
22:57:19FromDiscord<RattleyCooper> (edit) "File`" => "File`(says "Creates a File from a filehandle with given mode")" | "File`(says "Creates a File from a filehandle with given mode")but ... can'tto" added "I" | "butIcan't figure out how to create that `File` ... " added "to give to the `open` proc"
22:57:29FromDiscord<Recruit_main707> `[T: int and float]` for example
22:57:44FromDiscord<ynfle (ynfle)> Does that make sense?
22:57:50FromDiscord<ynfle (ynfle)> How could it be both types?
22:58:00FromDiscord<Recruit_main707> its a generic
22:59:02FromDiscord<ynfle (ynfle)> How could `T` be both?
22:59:03FromDiscord<Ayy Lmao> a generic in that case still uses either a float or an int, not both at the same time
22:59:47FromDiscord<Ayy Lmao> `or` does what you think `and` should do I think
22:59:54FromDiscord<Recruit_main707> uhhh, forget me, my brain is shutting down
23:00:12FromDiscord<Recruit_main707> thanks xd
23:01:21FromDiscord<Ayy Lmao> don't worry, generics can be hard on the brain sometimes
23:01:48FromDiscord<Recruit_main707> actually, im not that dumb, i do want that, because im doing:↵`not SomeFloat and not string`
23:03:16FromDiscord<Ayy Lmao> I'm not sure if generics can be done with exclusive logic like that. Maybe someone who knows more about it can say.
23:03:30FromDiscord<ynfle (ynfle)> Have you tried it?
23:04:02FromDiscord<Recruit_main707> that does compile yeah
23:04:46FromDiscord<ynfle (ynfle)> Great
23:04:58FromDiscord<Recruit_main707> but i am wondering if there is a symbol to do express and, i could swear there was
23:05:40FromDiscord<ynfle (ynfle)> ?
23:05:53FromDiscord<ynfle (ynfle)> This https://play.nim-lang.org/#ix=3x4d shouldn't compile though
23:06:07FromDiscord<Rika> In reply to @madprops "how can I "return"": You can “force return” if you use result with return result
23:06:14FromDiscord<Rika> It’s kinda funky though
23:06:22FromDiscord<Ayy Lmao> In reply to @Recruit_main707 "but i am wondering": I would think that it would be `&` but I haven't tried
23:06:31FromDiscord<Rika> In reply to @madprops "is ther an `else`": No
23:07:28FromDiscord<treeform> In reply to @RattleyCooper "How do I get": this works for me: https://gist.github.com/treeform/6697b0bba77fb111a3b32fb127ecadf2
23:07:34FromDiscord<Recruit_main707> In reply to @ynfle (ynfle) "This https://play.nim-lang.org/#ix=3x4d shouldn't c": i handle the arguments diferently depending on T
23:07:49FromDiscord<Ayy Lmao> In reply to @ynfle (ynfle) "This https://play.nim-lang.org/#ix=3x4d shouldn't c": It doesn't compile if you try to use it with anything
23:07:53FromDiscord<Recruit_main707> when T is X:↵...↵else:↵...
23:07:56FromDiscord<Rika> In reply to @RattleyCooper "How do I get": Why can’t you use the stream version
23:08:19FromDiscord<Recruit_main707> In reply to @Ayy Lmao "I would think that": thats what i thought but it isnt apparently
23:08:49FromDiscord<Rika> In reply to @Recruit_main707 "thats what i thought": Not implemented for type descriptions
23:08:53FromDiscord<Rika> Use “and”
23:09:15FromDiscord<Rika> I’m not even sure if “and” is implemented
23:09:34FromDiscord<Recruit_main707> yes it is apparently
23:10:33FromDiscord<Ayy Lmao> In reply to @Recruit_main707 "yes it is apparently": Have you looked into concepts? Maybe they suit your use case.
23:10:34FromDiscord<RattleyCooper> In reply to @Rika "Why can’t you use": I probably can (it compiles). I'm just curious if there is a way to write to `inputHandle` (docs in osproc make is sound like you can).
23:11:36FromDiscord<Ayy Lmao> (edit) "In reply to @Recruit_main707 "yes it is apparently": Have you looked into concepts? Maybe they suit your use case. ... " added "https://nim-lang.org/docs/manual_experimental.html#concepts"
23:11:53FromDiscord<ynfle (ynfle)> you open
23:12:16FromDiscord<ynfle (ynfle)> https://nim-lang.org/docs/io.html#open%2Cstring%2CFileMode%2Cint
23:12:18FromDiscord<ynfle (ynfle)> \use open
23:13:02FromDiscord<RattleyCooper> In reply to @ynfle (ynfle) "you open": Yeah, I saw that but am not sure which `File` to give as the first parameter, or how to create that `File`
23:13:17FromDiscord<ynfle (ynfle)> var f\: File
23:13:30FromDiscord<RattleyCooper> Oml, wow
23:13:48FromDiscord<RattleyCooper> I didn't even think of that. So obvious XD. Thanks
23:14:12FromDiscord<ynfle (ynfle)> \:thumbsup\:
23:14:17FromDiscord<ynfle (ynfle)> Can be confusing sometimes
23:14:35FromDiscord<RattleyCooper> Yeah, I feel like I should know that by now but it's ok.
23:18:50madpropsRika when you say `result` wouldnt' tha mean the global proc result and not the if/else ?
23:19:24FromDiscord<Rika> oh you only want to create a result for either?
23:19:30FromDiscord<Rika> then sure use a variable
23:19:51FromDiscord<Rika> wait let me read the code again
23:20:14FromDiscord<Rika> eh thats not possible
23:20:23FromDiscord<Rika> missing the values on else
23:20:51FromDiscord<Rika> provide a value on else because its needed
23:24:19madpropsthe problem is if there are many else values to default to
23:24:31madpropsincluding repetitions
23:24:37madpropsso yeah a variable is better
23:25:39*flynn quit (Read error: Connection reset by peer)
23:26:45*flynn joined #nim
23:46:16*auxym_ joined #nim
23:57:27*auxym_ quit (Ping timeout: 240 seconds)
23:57:39FromDiscord<rb3.nim> sent a code paste, see https://play.nim-lang.org/#ix=3x4i
23:58:58FromDiscord<rb3.nim> (edit) "https://play.nim-lang.org/#ix=3x4i" => "https://play.nim-lang.org/#ix=3x4j"