<< 13-12-2023 >>

00:01:25FromDiscord<Phil> hmm fair, the reason I fit them in there is that there's a bunch of procs that you can't get docs on because they get generated via macro
00:02:03FromDiscord<Phil> sent a long message, see <!doctype html>
01:21:45FromDiscord<rubythulhu> what's the overall community attitude towards using `result` vs creating a named var?
01:22:23FromDiscord<Elegantbeef> It's generally preferred
01:23:02FromDiscord<rubythulhu> i kinda hated `result` at first because it felt too magic, but came around to it because it ez to just add a debug echo at the end of the function that includes result
01:23:41FromDiscord<Elegantbeef> result is very good for accumulators
01:23:48FromDiscord<Elegantbeef> But I prefer expressions
01:23:56FromDiscord<Elegantbeef> Where possible of course
01:24:20FromDiscord<rubythulhu> i'm asking because i find myself like 50/50 right now
01:24:33FromDiscord<rubythulhu> kinda really like result, but it still feels dirty
01:26:21FromDiscord<Elegantbeef> Well what do your procs look like?
01:26:23FromDiscord<Elegantbeef> Are they accumulators?
01:27:46FromDiscord<rubythulhu> all kinds. i kinda see benefits of either solution in any function w/ a return value
01:28:10FromDiscord<Elegantbeef> I mean if you're using result in code that can be an expression I think you're abusing it
01:28:25FromDiscord<Elegantbeef> I say that though often use `result` inside of macros due to the added debuggabillity
01:28:44FromDiscord<graveflo> like most things if you see value in different ways then use them in different ways
01:28:52FromDiscord<rubythulhu> yeah
01:29:10FromDiscord<rubythulhu> i feel like "as an accumulator" is too specific for me
01:29:26FromDiscord<graveflo> There are good reasons why `result` is preferred though, so it's nice to keep that in mind if `return` is your habbit
01:30:04FromDiscord<rubythulhu> but i'm starting to just treat it as a code readability thing. any proc could go either way, and the end result diff is afaik negligible, so it's just about what feels more readable for any proc?
01:30:06FromDiscord<Elegantbeef> I mean any place a value might be set then changed latter in a statement instead of an expression, use result is my view
01:30:32FromDiscord<rubythulhu> but i grew up in perl, and a lot of things i grew up thinking were cool were shunned by the broader programming community haha
01:33:14FromDiscord<graveflo> yea convenience can certainly go either way in the moment. If you are curious about their differences you can look into it. People care about this topic more then you would think and I'm not just taking about nim's `result`, I mean `return` and `break` and `goto` type stuff in general. Some of that is all fluff. I would say the main point is that breaking control flow willy nilly can make things harder to understand and it also breaks so
01:34:13FromDiscord<graveflo> and if you want to waste some time micro optimizing things for beauty, using `result` where you could have used `return` sometimes leads to things that are better organized. It's nbd though
01:36:20FromDiscord<Elegantbeef> Worth noting you can use them in conjunction, but it's not advisable 😄
01:36:32FromDiscord<Elegantbeef> `result = x; return` is a silly idiom
01:36:34FromDiscord<graveflo> I do this all the time LOL
01:36:35FromDiscord<Elegantbeef> `return x` is more sane
01:36:38FromDiscord<rubythulhu> yeah makes sense. kinda thats what i love about nim. the options of ways to do things w/o any program overhead. like a stricter version of perl's "there's more than one way to do it" philosophy
01:36:50FromDiscord<Elegantbeef> I do not mean using result and returning in some cases
01:36:54FromDiscord<Elegantbeef> I mean setting result then returning
01:37:14FromDiscord<rubythulhu> yeah that's the failure point imo
01:37:21FromDiscord<graveflo> oh well.. I'll start doing that then since I've already committed
01:37:48FromDiscord<Elegantbeef> Just embrace expressions, and be merry!
01:37:52FromDiscord<rubythulhu> when most of a proc is better as result, but you need 1-2 early returns and just want to return an expression
01:39:44FromDiscord<rubythulhu> i legit asked this because i'm at an `if X: result = Y; return` situation in what i was doing at the time, when `return Y` feels better haha
01:40:30FromDiscord<Elegantbeef> Yea without a code example I only speak in generalities
01:41:40FromDiscord<rubythulhu> i'm more interested in the general sense, is why i didn't provide one. when result, when to return, when to do both is a line i'm still learning how to draw
01:44:33FromDiscord<graveflo> sent a long message, see <!doctype html>
01:45:19FromDiscord<Elegantbeef> I do prefer not having early escapes myself as you do not have to think about the anti logic
01:45:43FromDiscord<Elegantbeef> `if someCond: ...` is better than `if not someCond: return; ....` but ymmv
01:59:43FromDiscord<rubythulhu> depends on the circumstance
02:02:15FromDiscord<rubythulhu> a bunch of failure conditions that just result in a `none` for an option type, or whichever other type, easier to get the minor bits out of the way so the complex bits are constrained
02:16:44FromDiscord<rubythulhu> early exit avoids nesting
02:42:29*tiorock joined #nim
02:42:29*rockcavera is now known as Guest3642
02:42:29*Guest3642 quit (Killed (silver.libera.chat (Nickname regained by services)))
02:42:29*tiorock is now known as rockcavera
03:01:33NimEventerNew thread by stbalbach: Cannot open: /dev/stderr, see https://forum.nim-lang.org/t/10761
03:15:39*edr quit (Quit: Leaving)
05:22:11FromDiscord<michaelb.eth> In reply to @rubythulhu "what's the overall community": there are also some downsides to `result`, see Cons in https://status-im.github.io/nim-style-guide/language.result.html
05:24:09FromDiscord<tomexmachina> sent a long message, see <!doctype html>
05:29:45FromDiscord<michaelb.eth> In reply to @tomexmachina "What has the state": Don’t worry about that kind of stuff too much, it’s not particularly to writing code for fun and/or profit.↵↵Dragons abound and the compiler continues to evolve (cf. NIR) but you can happily use Nim 2.0 to write solid, production-ready code, just don’t forget to pass `-d:release`
05:29:58FromDiscord<michaelb.eth> (edit) "In reply to @tomexmachina "What has the state": Don’t worry about that kind of stuff too much, it’s not particularly ... to" added "conducive"
05:34:04*krux02_ quit (Remote host closed the connection)
05:40:40FromDiscord<zectbumo> how do I pass a define through nimble install? I'm trying `nimble install -d:GLFW_USE_X11 staticglfw` but I think the `-d` is being taken as an install `debug` flag not a defined symbol
05:41:30FromDiscord<Elegantbeef> You do not need it likely when installing
05:41:37FromDiscord<zectbumo> problem being that when I `nim r mygl` I get `No supported window creation API selected`
05:42:12FromDiscord<Elegantbeef> what about `nim r -d:GLFW_USE_X11 mygl`?
05:42:44FromDiscord<zectbumo> same. maybe I'm defining the wrong symbol
05:43:39FromDiscord<zectbumo> I'm following https://www.glfw.org/docs/3.3/compile_guide.html
05:43:58FromDiscord<zectbumo> it says "By default GLFW will use X11 on Linux" but doesn't seem to be true
05:44:13FromDiscord<michaelb.eth> you can pass flags, I’ve done that plenty of times with `nimble [nimble_flatgs test [nim_flags]` but I don’t know if/how well the install command supports them
05:44:34FromDiscord<michaelb.eth> (edit) "[nimble_flatgs" => "[nimble_flags]"
05:44:42FromDiscord<Elegantbeef> you want `--passL:"-d...."`
05:51:18FromDiscord<Elegantbeef> sorry should be `nim r --passL:"-DGLFW_USE_X11" mygl`
05:51:23FromDiscord<zectbumo> thx `nim r --passC:-D_GLFW_X11` got me further along. now wants X11 libs
05:53:54FromDiscord<glomdom.> it cant find them or do you not have them installed
05:54:57*disso-peach joined #nim
05:55:17*rockcavera quit (Remote host closed the connection)
05:55:33FromDiscord<zectbumo> I left the glfw instructions and trying to follow the staticglfw flags instead found here https://github.com/treeform/staticglfw/blob/master/src/staticglfw/CMakeLists.txt
05:59:28FromDiscord<zectbumo> it's looking for the X11 libs so I have to now pass the include dir using -I
06:00:52FromDiscord<zectbumo> got passed that and now I errored on `free(_glfw.null.clipboardString);` ↵`staticglfw-4.1.3/staticglfw/null_init.c:49:16: error: no member named 'null' in 'struct _GLFWlibrary'`
06:01:07FromDiscord<zectbumo> bummer
06:02:47FromDiscord<zectbumo> https://github.com/treeform/staticglfw/blob/master/src/staticglfw/null_init.c#L49C18-L49C18
06:03:33FromDiscord<zectbumo> (edit) "https://github.com/treeform/staticglfw/blob/master/src/staticglfw/null_init.c#L49C18-L49C18" => "https://github.com/treeform/staticglfw/blob/master/src/staticglfw/null_init.c#L49"
06:08:35FromDiscord<zectbumo> why is code rot so strong?
06:13:28FromDiscord<rubythulhu> In reply to @michaelb.eth "there are also some": oh thanks, this was exactly the kind of reply i was looking for!
06:13:28FromDiscord<zectbumo> maybe I need define `_GLFW_OSMESA`
06:19:38FromDiscord<zectbumo> okay, that's actually compiling now with mesa. but now it wants to link libGL and it wants `libGL.so.1` but I have `libGL.so.18.0` now I have to remember how to map 1 to 18 in some ld config file. it's been too many years. maybe I just sym link it
06:23:58FromDiscord<alireza0x0> hey there
06:24:09FromDiscord<alireza0x0> how should i get current refrence count of a ref?
06:24:20FromDiscord<alireza0x0> python had something like system.rc function or whatever
06:30:44FromDiscord<Elegantbeef> Nim does not have a API for that but you can always make one
06:31:23FromDiscord<Elegantbeef> https://github.com/nim-works/arc
06:42:48FromDiscord<zectbumo> I got the demo to compile, dynamically link, and run. the program runs for .01s and exits with 0. I'm trying to run demo.nim but I guess it was discontinued for a reason↵https://github.com/treeform/pixie/blob/3.1.2/src/pixie/demo.nim
06:46:34FromDiscord<Elegantbeef> Just use sdl2 😄
06:47:09FromDiscord<zectbumo> I'm poking around nimble.directory. is there some live demo I can check out that uses sdl2?
06:47:43FromDiscord<Elegantbeef> https://github.com/Vladar4/sdl2_nim/tree/master/examples
06:48:31FromDiscord<alireza0x0> do you think arc will do anything outside of the lock block to global? https://media.discordapp.net/attachments/371759389889003532/1184386351433523252/image.png?ex=658bc8bf&is=657953bf&hm=2fd01f8bbd3bf3ed7f205b18378343b9653cc943b5191e7ad5f5360db6002af2&
06:48:34FromDiscord<Elegantbeef> I don't know what you're doing, but sdl2 is quite simple to setup and use
06:48:51FromDiscord<zectbumo> I'm trying to have some fun
06:48:53FromDiscord<Elegantbeef> It'll call the `=destroy` at end of scope
06:49:04FromDiscord<alireza0x0> before the block ends it should reduce rc count of global by 1 because owner2 is destroyed
06:49:11FromDiscord<alireza0x0> but anything else?
06:49:27FromDiscord<Elegantbeef> That assumes it even increments the count and doesn't just make a cursor
06:49:56FromDiscord<alireza0x0> hhmmm?
06:50:20FromDiscord<alireza0x0> if it creates a cursor for owner2
06:50:26FromDiscord<alireza0x0> then it should not destroy it right?
06:50:35FromDiscord<alireza0x0> so the rc is not changed... or am i wrong?
06:50:45FromDiscord<Elegantbeef> Correct it probably will copy the ref incrementing the pointer
06:50:59FromDiscord<Elegantbeef> Cursors never work how I think they do
06:51:09FromDiscord<alireza0x0> 😄
06:51:19FromDiscord<alireza0x0> i don't know how they work either
06:51:24FromDiscord<Elegantbeef> Anyway stop caring about rc
06:51:33FromDiscord<alireza0x0> but they look like something like the {.byaddr.} prgama
06:52:26FromDiscord<alireza0x0> i want to (try at least) share the ref to the threads so im trying to find a secure way...
06:52:39FromDiscord<Elegantbeef> Welcome to Nim threading hell
06:52:47FromDiscord<Elegantbeef> sharing refs across threads never works
06:52:58FromDiscord<Elegantbeef> Unless you use `atomicarc`
06:53:04FromDiscord<alireza0x0> they are just c++ shared ptrs i think
06:53:16FromDiscord<alireza0x0> if you respect the ref and only work with it inside the corresponding lock
06:53:22FromDiscord<alireza0x0> nothing should go wrong...
06:53:34FromDiscord<Elegantbeef> Except that you cannot share refs with single ownership
06:54:02FromDiscord<alireza0x0> for those you have to use move everywhere...
06:54:09FromDiscord<alireza0x0> (edit) "move" => "`move`"
06:54:33FromDiscord<Elegantbeef> Eh it never works as it should in my testing
06:54:40FromDiscord<alireza0x0> a single ownership ref is Isolated[T] right?
06:54:50FromDiscord<Elegantbeef> No
06:54:53FromDiscord<alireza0x0> nim had something like `owned` keyword but thats deprecated right?
06:55:07FromDiscord<Elegantbeef> I mean it does not work with Nim's single ownership
06:55:22FromDiscord<Elegantbeef> One thread must own a thread but there is no way to communicate you are not giving it up
06:55:27FromDiscord<alireza0x0> how you define a single owner ref then?
06:55:39FromDiscord<Elegantbeef> It's easier to just do `ptr YourRef()[]` and use that across threads
06:55:49FromDiscord<Elegantbeef> I mean Nim's refs are single thread owned is my point
06:56:09FromDiscord<Elegantbeef> You cannot share a ref to another thread when both threads attempt to free it
06:57:11FromDiscord<Elegantbeef> Actually I'm being daft the issue was moving refs without using isolated
06:57:19FromDiscord<alireza0x0> if we look at the aspect of sharing a global ref, it will not be destroyed so the rc is always more than 1 and therefore if you manage to have your refrence counting atomic (by using locks i mean not atomic arc) you are good to go...
06:57:33FromDiscord<alireza0x0> i have to right a good test for them and using valgrind ... hard work
06:57:38FromDiscord<Elegantbeef> I mean if you have a global resource you do not need any lock on the rc
06:57:41FromDiscord<alireza0x0> (edit) "right" => "write"
06:57:44FromDiscord<Elegantbeef> i mean any atomic operation on the rc
06:58:07FromDiscord<Elegantbeef> If it's a global resource it gets cleared at the end of the main thread
06:58:20FromDiscord<Elegantbeef> Atleast it should regardless of rc
06:58:25FromDiscord<alireza0x0> the rc value will mess up if
06:58:35FromDiscord<alireza0x0> threads inc or dec it at same time
06:58:40FromDiscord<alireza0x0> something like this example
06:59:02FromDiscord<Elegantbeef> Sure but if it's a global reference the rc should not matter
06:59:08FromDiscord<alireza0x0> sent a code paste, see https://play.nim-lang.org/#ix=html>
06:59:14FromDiscord<Elegantbeef> Since you know at the end of the main thread all global resources need to be cleared
06:59:54FromDiscord<Elegantbeef> I might be lacking some amount of sleep though so I might be very wrong 😄
07:00:23FromDiscord<alireza0x0> no i don't think you are thinking wrong
07:00:28FromDiscord<alireza0x0> i need more thinking ofcourse
07:00:52FromDiscord<alireza0x0> but thats the point where i am right now... valgrind will decide i can do these or not
07:25:48FromDiscord<zectbumo> cool! I got sdl2nim example 211 opengl to run and got a rectangle to toggle using the `q` key. this is starting to get fun. Is there a way to turn up the fun factor?
07:26:32FromDiscord<Elegantbeef> Start using opengl and crying about graphics programming
07:28:57FromDiscord<zectbumo> that bad huh?
07:29:12FromDiscord<Elegantbeef> It's not bad it's fun
07:29:33FromDiscord<zectbumo> oh I'm crying with laughter. 😂
07:36:02*advesperacit joined #nim
07:36:36FromDiscord<zectbumo> this is pretty fun https://nimble.directory/pkg/glbits
08:48:28FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
08:49:50FromDiscord<Phil> And that should be thread-safe (as in multiple threads trying to push messages through it) because the `Channel` is taking care of said thread-safety, correct?
08:51:01FromDiscord<Elegantbeef> Nim has a shared heap now
08:51:15FromDiscord<Elegantbeef> so all of those are stored on the heap and the pointers point to where you need to go
08:51:42FromDiscord<Phil> So there's a single instance of `ChannelHub` that is used by all threads?
08:51:56FromDiscord<Phil> on the shared heap
08:52:51FromDiscord<Elegantbeef> `ref object` is just a fancy pointer to your heap, on the heap there is a `typeof ChannelHub()[]` when you access the `ref`'s fields it goes to the heap and grabs it
08:52:52FromDiscord<Phil (he/him)> Man, you alt tab between the fractal matrix client to read beefs message just that one second faster and discord and matrix just thinks you're tryping =/
08:53:42FromDiscord<Elegantbeef> So if you have a global `ref` it's a single `ChannelHub`
08:54:16FromDiscord<Phil (he/him)> In this case it's not a global ref, but it is shared between the various threads because I pass it to them when spawning them
08:54:38FromDiscord<Elegantbeef> clonkk to respond to your #internals question here, yesn't 😄
08:54:51FromDiscord<Elegantbeef> Right it's shared to all the other thread so still 'global'
08:55:21FromDiscord<Phil (he/him)> Okay, fair
08:55:27FromDiscord<Clonkk> I have cases where ref are nil after being free'd and cases where the memory is still valid (which makes writing test for =destroy harder)
08:55:36FromDiscord<Clonkk> Hence the question ^^
08:55:59FromDiscord<Clonkk> Plus, potential read / write after free are kinda ugly \:p
08:56:03FromDiscord<Elegantbeef> Well `ptr ref` being nil after freeing depends on so much
08:56:19FromDiscord<Clonkk> I'm talking about the ref itself not the pointer
08:56:24FromDiscord<Elegantbeef> I know
08:56:56FromDiscord<Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=html>
08:56:59FromDiscord<Phil (he/him)> And just for safety\: I don't really need to care about thread safety in that setup myself since Channels inherently are thread-safe (Mostly asking because multiple threads may be trying to push a message into a Channel at once)
08:57:00FromDiscord<Elegantbeef> It should be nil after freed, but between freeing and what you're later you could have allocations or stack changes which invalidate that sentiment
08:57:17FromDiscord<Phil (he/him)> \correct?
08:57:55FromDiscord<Elegantbeef> Right I would not trust that idiom Clonkk, it relies on the ref object's stack address not to be reused after freeing
08:58:07FromDiscord<Elegantbeef> Channels are threadsafe queues yes
08:58:22FromDiscord<Elegantbeef> what you're doing later\
08:59:12FromDiscord<Elegantbeef> It sounds like you're trying to give up ownership of GC'd resources?
08:59:26FromDiscord<Elegantbeef> In that case I'd say use `GcRef` and `GcUnref`
09:05:56FromDiscord<Clonkk> I am converting =destroy(x\: var T) to =destroy(x\: T) for object that are `importc`
09:06:22FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
09:06:26FromDiscord<Elegantbeef> Atleast on my machine that demonstrates the issue
09:07:03FromDiscord<Elegantbeef> Right you should write a `=destroy` and `=wasMoved` now
09:07:04FromDiscord<Clonkk> Yep
09:07:06FromDiscord<Elegantbeef> `=destroy` calls destruction, `=wasMoved` nils everything out
09:09:20FromDiscord<Elegantbeef> Do you have a more elaborate example I could look at?
09:09:54FromDiscord<Clonkk> https://github.com/nim-lang/nim-zmq/pull/40
09:09:59FromDiscord<Clonkk> I'll push the latest
09:13:55FromDiscord<Clonkk> Around https://github.com/nim-lang/nim-zmq/blob/2dc38c2ca9820bbf32b54535f9cdcd205b5080b1/zmq/connections.nim#L143 and https://github.com/nim-lang/nim-zmq/blob/2dc38c2ca9820bbf32b54535f9cdcd205b5080b1/zmq/asynczmq.nim#L38 for hooks
09:16:55FromDiscord<Elegantbeef> Ok so what's the issue with the AsyncZPoller destructor?
09:17:20FromDiscord<Elegantbeef> You want to destroy the `cb` but `=destroy` does not work on `seq[T]` in 2.0?
09:19:39FromDiscord<Clonkk> Well it seems to work (apart from issues on async behavior but that's unrelated) I just wanted to write the tests to prove it works, kinda ?
09:20:01FromDiscord<Elegantbeef> Ah I'd suggest just using valgrind with `-d:useMalloc` to test it
09:20:14FromDiscord<Elegantbeef> But you do need to call `=destroy(obj.cb)`
09:21:07FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/10642 forum post related to the aforementioned thing I mentioned
09:21:51FromDiscord<Elegantbeef> You need to call `=destroy` on all fields that can own memory
09:22:26FromDiscord<shirleyquirk> What c, c++ standards are required by the compiler? basically, if i'm trying to write 'portable' nim that has an 'emit', what features can i rely on? (C11 _Static_assert?)
09:23:34FromDiscord<Elegantbeef> That's an open ended question you can use any feature that you have a C/C++ compiler for
09:23:57FromDiscord<Elegantbeef> If you want to know what Nim targets for C/C++ I think it's C99 and C++11, but I might be wrong about the C++
09:24:08FromDiscord<Clonkk> Yeah that's always a possibility but I tends to avoid valgrind as much as i can, it's too verbose
09:24:36FromDiscord<Elegantbeef> > ==106386== All heap blocks were freed -- no leaks are possible
09:24:41FromDiscord<Elegantbeef> That's all you have to check for
09:25:17FromDiscord<Elegantbeef> a simple strscans iteration of the output is enough 😄
09:26:21FromDiscord<Phil> Hmm decent colors to represent thread A vs thread B vs. a shared resource
09:26:43FromDiscord<Elegantbeef> First they coloured our functions now they colour our threads
09:26:56FromDiscord<Elegantbeef> blue, green, yellow
09:27:12FromDiscord<Phil> I'm mostly working on a sequence diagram on how the message passing works in mermaidjs, thus the question
09:28:07FromDiscord<Phil> That is on you beef: https://media.discordapp.net/attachments/371759389889003532/1184426514259922955/image.png?ex=658bee26&is=65797926&hm=13468ecd4a85b602cc91ee965231d7ffb4242b4e104be321c45205676e179fbe&
09:28:25FromDiscord<Elegantbeef> Oh nice valgrind has a `--error-exitcode` so you do not even needs to use strscans
09:28:28FromDiscord<Phil> Okay the green works but blue and yellow lead to terrible text contrast
09:29:40FromDiscord<Elegantbeef> as simple as `let (output, err) = execCmdEx("valgrind --error-exitcode=1 bleh"); check err == 0` 😄
09:30:04FromDiscord<Phil> Hmm Green and... "Brown" seems alright. I hesitate to call this shade of red brown: https://media.discordapp.net/attachments/371759389889003532/1184427005509386240/image.png?ex=658bee9b&is=6579799b&hm=896fcfb50ea5d2124ea244ac9eed7c87b488ba072ab92b4e93035e5620ddab19&
09:30:33FromDiscord<Elegantbeef> I do like how bad you are at picking colours
09:30:35FromDiscord<Elegantbeef> Full saturation
09:30:45FromDiscord<Elegantbeef> There is no such thing as "some saturation" in Phil's world
09:30:58FromDiscord<Clonkk> Yeah but in my experience, working with sharedl ibrary in Nim always ends up with "still reachable" so you do actually need to check that you only get those as errors
09:31:01FromDiscord<Elegantbeef> He turns it to 11 11/10 times
09:31:02FromDiscord<Phil> You missunderstand, this is a mermaidjs block in obsidian
09:31:04FromDiscord<Clonkk> Also std/unittest seems to have error
09:31:08FromDiscord<Phil> I don't choose the colors, I get words to pick from
09:31:29FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
09:31:47FromDiscord<shirleyquirk> Cheers @ElegantBeef
09:32:09FromDiscord<Phil> However, unrelated to that you would still be entirely correct in saying I am horrible with picking out colors
09:32:25FromDiscord<Phil> But the entire "saturation way too brutal" I can at least somewhat make out
09:39:05FromDiscord<TӨMΛ ☠> Today I learned that in Python, try/except aren't actually always expensive and picking sophisticated if/else chain isn't good idea for many cases where try/except would not fail most of the times. [Reference](<https://docs.python.org/3/faq/design.html#how-fast-are-exceptions >).↵Out of curiosity, does that transmit to Nim as well? What is the cost of try/except in Nim in general?
09:39:19FromDiscord<TӨMΛ ☠> (edit) "[Reference](<https://docs.python.org/3/faq/design.html#how-fast-are-exceptions >).↵Out" => "[Reference](<https://docs.python.org/3/faq/design.html#how-fast-are-exceptions>).↵Out"
09:39:26FromDiscord<TӨMΛ ☠> (edit) "[Reference](<https://docs.python.org/3/faq/design.html#how-fast-are-exceptions>).↵Out" => "[Reference in docs](<https://docs.python.org/3/faq/design.html#how-fast-are-exceptions>).↵Out"
09:39:29FromDiscord<Elegantbeef> Try except is only really expensive on the fail path
09:39:40FromDiscord<Elegantbeef> It has a mild overhead on the good path
09:40:39FromDiscord<TӨMΛ ☠> So it's more universal, I see. That's amazing to know ❤️
09:45:40*PMunch joined #nim
09:49:04PMunchYeah that's a pretty general thing
09:49:20PMunchThe expensive part of an exception is gathering the stacktrace
09:56:49FromDiscord<nnsee> is the stacktrace gathered if the exception is caught?
09:58:53PMunchPhil: https://mermaid.js.org/config/theming.html you can change the colours manually ;)
09:59:16PMunchnnsee, I think the stacktrace is gathered when it is raised
10:00:15PMunchI mean you can catch an exception and then call `getStackTrace` on it
10:00:52FromDiscord<nnsee> so using the try/except pattern in general still averages out to having somewhat of a performance penalty
10:01:23FromDiscord<nnsee> (edit) "so using the try/except pattern ... in" added "for execution flow"
10:04:04PMunchYeah, they aren't really made for execution flow
10:06:55FromDiscord<nnsee> that doesn't stop people from using it for that :p also, the raises pragma somewhat encourages this pattern
10:08:13FromDiscord<Phil> In reply to @PMunch "Yeah, they aren't really": Which is why I use them for shutting down threads, because nothing screams solid design more than throwing an exception to break a while-loop in outer scope!
10:09:21FromDiscord<Phil> I mean, I jest, but raising a "KillError" was by a wide margin the most convenient method of shutting down a thread I had, at least in terms of overhead introduced.↵And it's not like I need to optimize for the scenario of shutting down a thread
10:09:58FromDiscord<Phil> (edit) "I mean, I jest, but raising a "KillError" ... was" added "and catching it in the loop in a try-except to break the loop"
10:10:24FromDiscord<nnsee> wait, why couldn't you just catch SIGTERM?
10:10:53FromDiscord<Phil> I don't want to kill the thread, I want to break the while-loop, then execute a couple shutdown events and then join the thread with the main thread
10:11:00FromDiscord<Phil> (edit) "I don't want to kill the thread, I want to break the while-loop, then execute a couple shutdown events and then join the thread with the main thread ... " added "- which then kills the thread"
10:11:09FromDiscord<Phil> (edit) "thread," => "thread immediately,"
10:13:57FromDiscord<nnsee> i suppose a nim exception is also more portable
11:03:00PMunchExceptions have their uses of course, and if you want to escape from deep within a call stack then they are a valid option. Otherwise I'd use a named block and break statement to get out of a while loop
11:04:08PMunchIt would be nice to have a control-flow-exception which wasn't made for error handling and could drop the whole thing of collecting a stack trace and keeping an error message
11:08:04FromDiscord<Phil> Honestly it's not even that deep in the stacktrace, the problem is simply that the code-block which could register that this is a message for shutting down the server is one proc deep within the while-loop
11:08:43FromDiscord<Phil> And within generated code.↵The alternative would be to check every message first if they're for killing the server but that seems very meh when the control-flow already has a step that registers what kind of message a given message is and what the appropriate action to take is
11:13:13PMunchHmm, I wonder if it would be possible to implement exceptions in Nim outside the existing exceptions
11:13:55PMunchI guess not, because of how the GC analysis works
11:20:56NimEventerNew thread by jmgomez: Nim Tooling Roadmap, see https://forum.nim-lang.org/t/10762
11:30:26FromDiscord<Clonkk> Anyone knows if it's "normal" that valgrind detect memory leak using asyncdispatch ?
11:31:11FromDiscord<Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=html>
11:33:22PMunchDo you compile with -d:useMalloc?
11:33:30FromDiscord<Clonkk> yes
11:33:39PMunchhmm, then it shouldn't leak
11:33:44FromDiscord<Clonkk> `nim cpp -d:useMalloc`
11:33:53FromDiscord<Clonkk> mm\:orc threads\:on by default
11:36:04FromDiscord<Clonkk> Yeah i thought so too, i just wanted to check↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>)
11:36:10FromDiscord<Clonkk> Welp https://github.com/nim-lang/Nim/issues/23066
11:40:32FromDiscord<Clonkk> So apparently it's normal \:)
11:42:31FromDiscord<Phil> TFW you validate your incoming NimNodes everywhere so aggressively you're approaching something resembling static type checking
12:33:26NimEventerNew thread by vanyle: Nim program crashes when using recursivity and openarray, see https://forum.nim-lang.org/t/10763
12:43:23FromDiscord<Phil> ... is there a way to store a bunch of strings at compiletime and use that at runtime as a const?
12:43:55Amun-Rasure
12:46:05FromDiscord<Phil> In global scope
12:46:10FromDiscord<nnsee> In reply to @isofruit "... is there a": am i misunderstanding? isn't that just const?
12:46:23Amun-Rayou can have them iirc as a const seq
12:46:26Amun-Raor const array
12:46:29FromDiscord<odexine> phil isnt really explaining it in enough detail
12:46:48Amun-Raor generate each const string with compiletime func
12:46:52Amun-Ratrue
12:48:13FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
12:48:50Amun-Rawe don't have access to playnim links on irc
12:49:01FromDiscord<Phil> myNames is only dynamic in the sense that I as a library writer will not know how many times you call doStuff
12:49:09FromDiscord<Phil> That's not a playnim link, I tend to just post the code directly
12:49:23Amun-RaPhil | sent a code paste, see https://play.nim-lang.org/#ix=html>
12:49:29Amun-Rathat's how we see it
12:49:31FromDiscord<nnsee> what
12:49:47FromDiscord<nnsee> well that's broken
12:49:49FromDiscord<Phil> That makes no sense... wtf?
12:50:02FromDiscord<Phil> Wait, does the irc bridge just auto-share code to play.nim-lang?
12:50:13FromDiscord<nnsee> maybe it tries to
12:50:19FromDiscord<nnsee> clearly it isn't doing it very successfully
12:50:23FromDiscord<Phil> https://media.discordapp.net/attachments/371759389889003532/1184477418203922452/image.png?ex=658c1d8f&is=6579a88f&hm=3e54d4406611fa7f778cb7f065ef09de10809f1b60a10dc38121d7f4fc039aeb&
12:50:28Amun-Rayes, it did with long messages
12:50:40FromDiscord<Phil> I mean the fact that ix is buring has been known for a while
12:50:45FromDiscord<nnsee> oh right
12:50:48FromDiscord<nnsee> ix is down
12:50:57FromDiscord<Phil> It's a question of can we even swap to another service, does it make sense to or not
12:51:27PMunchnnsee, how's the Nim paste solution going? :P
12:51:55Amun-RaPhil: I use something like this: https://dpaste.com/AN3CRX62K
12:52:00PMunchAnd yeah, the bridge tries to do code as playground link pastes. It's not terribly great at it, but it's trying
12:52:06FromDiscord<nnsee> 😬
12:52:21FromDiscord<nnsee> i started with it
12:52:27FromDiscord<nnsee> but got sidetracked with IRL stuff and work
12:52:33FromDiscord<nnsee> will try to finish it this week
12:52:39PMunchNice
12:52:54FromDiscord<Phil> In reply to @Amun-Ra "<@180601887916163073>: I use something": The problem I run into here is that I already have a pretty elaborate pipeline of storing stuff in Cachetables. I just also want some of that metadata to also be available at runtime
12:53:08FromDiscord<Phil> So I don't get the luxury of defining things like that
12:53:14*rockcavera joined #nim
12:53:16Amun-Rahmm
12:55:39FromDiscord<Phil> At least I don't see how.↵Basically from within a proc called by a macro I want to push information to somewhere that I can access at runtime
12:55:50FromDiscord<Phil> Specifically: strings
12:57:24FromDiscord<Phil> The only reason I need to really is that I'm in a scenario where the order of compiler-evaluations is not in my favour 😅
12:57:50FromDiscord<Phil> It's executing all the macros for registering types that would give me these strings after it would execute a compileTime proc of mine
13:01:10*edr joined #nim
13:08:18FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=html>
13:13:39FromDiscord<Phil> Argh, pragmas go before typedef, yeah the "var" -variable declaration with compiletime pragma did it
13:16:10FromDiscord<Phil> ... never mind, that blows up in my face as well somehow.↵Eh, was only for pre-defining some startup/shutdown events for convenience, users can do that themselves
13:18:02FromDiscord<graveflo> yea I think the macro would need to be more complicated if it were more then just literals in there, plus sometimes it better to just focus on core functionality and add bits like that later
13:18:35FromDiscord<Phil> Not even that, the syntax is fine, but I get the weirdest compiler errors
13:19:19FromDiscord<Phil> Something about the linker blowing up on me, which is the kind of problem that is juuuuuuust not worth the time for non-core functionality ^^
14:05:37PMunchHmm, is there a way to get the path to the currently compiling module in Nim?
14:07:53FromDiscord<_goel_> Apparently i made an account for the Nim-Forum in september 2021, but i never confirmed the email so i can't post anything. Looking at the setting page it just tells me the email is not confirmed but how do i re-send the confirmation email?
14:08:53FromDiscord<nnsee> it's pretty easy, just hack into the administrator interface and confirm your account
14:09:03FromDiscord<zuhaibullahbaig> Hey hello, so i am a python developer, i just recently came to know about Nim. I think its kinda of an interesting language, how good is it for building security tools and for web development? is it easy to pick? how can i get started...
14:09:05FromDiscord<_goel_> (edit) "email?" => "email?↵Everything is greyed out, except for delete account"
14:09:24FromDiscord<nnsee> "security tools"?
14:09:57FromDiscord<zuhaibullahbaig> In reply to @nnsee ""security tools"?": oh like exploits and stuff. i am planning to learn cyber security in the future
14:11:22FromDiscord<nnsee> exploits for what?
14:12:55FromDiscord<nnsee> Nim is a general purpose language. There's nothing about it that makes it better than other languages for "building security tools". You can do web development in Nim, see frameworks like happyx and karax
14:13:38PMunch_goel_, what is your account name?
14:19:47PMunchRight, so currentSourcePath is what I need. But how do I root a dotted path at this position?
14:20:00FromDiscord<jviega> thisDir()
14:20:08PMunchthisDir?
14:20:21FromDiscord<jviega> Works better when you end up getting moved around by nimble
14:20:31FromDiscord<Phil> Hmmmm
14:20:34FromDiscord<jviega> Don't remember the difference but I ended up at thisDir() and there was a reason
14:20:49PMunchHmm, that's in the nimscript module though
14:20:58FromDiscord<jviega> Yes, which runs when you compile
14:21:03FromDiscord<jviega> So why not use it
14:21:10PMunchFair enough
14:21:24FromDiscord<jviega> It def was the more accurate option
14:21:36FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
14:21:40FromDiscord<nnsee> In reply to @zuhaibullahbaig "oh like exploits and": i think i scared them off, they left
14:22:06PMunchStrange, the docs says that it just calls currentSourcePath, but doesn't resolve symlinks
14:22:49PMunchPhil, well it raises a warning with some tracing information
14:22:56PMunchOr am I missing something?
14:23:19FromDiscord<Phil> Well yeah but that's inside of the threading package which uses std/isolation and typically I don't get compiler warnings for std/lib code
14:23:25FromDiscord<Phil> So I assume it has to do with my proc
14:23:29FromDiscord<jviega> So my memory is this:
14:24:09FromDiscord<jviega> If you're building package A and package B is required, package B using currentSourcePath() gives the wrong answer but thisDir() does not
14:25:06FromDiscord<jviega> I think it thinks it's relative to package A? Or else it might only be when nimble is first installing a package and is using a temporary directory. I don't remember which problem that was
14:28:38FromDiscord<mratsim> In reply to @jviega "Works better when you": nimble is so annoying with this
14:29:26FromDiscord<jviega> Yes, it's like package management was left to a house full of cats
14:38:29*G3ngh1s_ joined #nim
14:43:35PMunchHmm, thisDir seems to return an empty string for me
14:44:04FromDiscord<jviega> Weird, maybe you're somehow not running in the js runtime??
14:44:45PMunchWell I'm definitely not running in the JS runtime :P
14:44:51PMunchBut I assume you meant Nim runtime
14:45:28FromDiscord<jviega> Yes nimble, macros, etc. are all run at compile time using the JS backend, are they not?
14:46:01PMunchWhat?
14:46:31FromDiscord<jviega> They definitely seem to be in our world
14:46:55PMunchI'm confused..
14:47:15PMunchWhy would nimble, macros, etc. run in a JavaScript backend?
14:47:29FromDiscord<jviega> Because of the lack of FFI
14:47:40PMunchBut JavaScript..
14:48:13FromDiscord<jviega> Yeah, maybe not, I think I probably misunderstood at some point long ago
14:48:24PMunchThey should be running in the Nim VM
14:49:14FromDiscord<jviega> Sorry for confusing you 🙂
14:49:28FromDiscord<jviega> "Senior moment"
14:54:48PMunchNo worries
14:59:18FromDiscord<piqueiras> best way of counting how many different elements are in a seq?
14:59:28FromDiscord<jviega> `.len()`
14:59:35FromDiscord<piqueiras> sorry, 2 seqs
14:59:37FromDiscord<piqueiras> like
14:59:49FromDiscord<piqueiras> @[true,true,false] and @[true,false,false]
14:59:58FromDiscord<piqueiras> theres one different element (considering order)
15:00:16FromDiscord<piqueiras> could do some custom func I guess
15:00:57FromDiscord<jviega> Yeah I think if you are trying to avoid dupes just throw them in a set but if not, prob write your own counting that does a linear scan
15:01:53FromDiscord<piqueiras> I could zip them maybe?
15:01:54FromDiscord<mratsim> In reply to @piqueiras "best way of counting": a for loop with xor
15:02:22FromDiscord<jviega> Only if it's always boolean
15:02:58FromDiscord<mratsim> In reply to @piqueiras "I could zip them": if you want to be functional, sure, or use zero-functional or loop-fusion↵↵- https://github.com/zero-functional/zero-functional↵- https://github.com/mratsim/loop-fusion
15:03:34FromDiscord<piqueiras> I mean it was just for a small thing no need for purity or performance
15:03:43FromDiscord<piqueiras> just asked if there was some lib function for that
15:04:20*rockcavera quit (Read error: Connection reset by peer)
15:04:39*rockcavera joined #nim
15:04:39*rockcavera quit (Changing host)
15:04:39*rockcavera joined #nim
15:05:17FromDiscord<nnsee> In reply to @piqueiras "best way of counting": `toHashSet(yourseq).card`
15:05:31FromDiscord<nnsee> not performant but easy to write and remember
15:05:38FromDiscord<jviega> That's not what he's looking for
15:05:47FromDiscord<jviega> He's looking to compare elements in two different arrays
15:05:51FromDiscord<jviega> by position
15:05:53FromDiscord<piqueiras> https://media.discordapp.net/attachments/371759389889003532/1184511516553256980/image.png?ex=658c3d50&is=6579c850&hm=887387ab69cf86c1bacbe895ba184929b4b35cde7eddbe60439fd7d1c659f40c&
15:06:02FromDiscord<piqueiras> hm
15:06:03FromDiscord<nnsee> ah, didn't read further, lol
15:06:26FromDiscord<nnsee> my bad
15:08:17FromDiscord<mratsim> In reply to @piqueiras "": for readability/dependencies, it definitely wins.↵↵For efficieny, it needs an extra alloc for zip, and extra loop over the data as well, then 1 alloc for countIt and 1 extra loop as well
15:08:28*PMunch quit (Quit: Leaving)
15:08:49FromDiscord<piqueiras> yea
16:01:58FromDiscord<Phil> Hmmm... anyone here worked with the channels in threading/channels?
16:02:04FromDiscord<Phil> I'm not sure if I'm running into a bug here or not
16:07:52FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
16:11:14FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
16:38:57*disso-peach quit (Quit: Leaving)
17:22:14FromDiscord<Phil> Okay I made a much more minimal example in which this works as normal... maybe threading channels just don't like object variants or sth?
17:30:43*nils` quit (Quit: nils`)
17:32:49FromDiscord<Clonkk> I use them to pass a ref around between threads. Not much else↵(@Phil)
18:34:23FromDiscord<Phil> In reply to @Clonkk "I use them to": Did you ever "stress-test" them? Like sending a hundred thousand messages at once or so?
18:34:43FromDiscord<Phil> Because I'm seeing weird behaviour (documented in https://github.com/nim-lang/threading/issues/52)
18:35:18FromDiscord<Phil> I mean, doesn't even have to be a hundred thousand, I'm seeing weird behaviour with 200
18:39:25FromDiscord<_goel_> In reply to @PMunch "<@312201286567198720>, what is your": I just changed the email in the format with another email address and then activated↵I think i could simply press "enter" on that email format to re-send it i suppose, even if its not written that it works like that
18:40:07FromDiscord<_goel_> (edit) "on" => "with" | "withthat ... email" added "old"
18:48:48FromDiscord<Phil> Man I wonder if olliNiinivara is in the discord, I'd be curious to chat with him regarding his HTTP based multi-threading approach
18:48:58FromDiscord<Phil> Seems like we both had the same idea, I'm just doing it using channels, he using HTTP
19:21:42FromDiscord<alwaysoutofrange> sent a code paste, see https://play.nim-lang.org/#ix=html>
19:25:37FromDiscord<Phil> That... seems suspicious, could you provide a fuller minimal example?
19:26:03FromDiscord<Phil> Because somewhere you're either assigning to a const, or you're in a static block, or in a proc that is using the {.compileTime.} pragma
19:27:31FromDiscord<Phil> Basically the issue you're running into is that you're trying to do something at compiletime that calls out to C-code.↵That is not doable. There are utilities for reading at compiletime, but given the fact that you're being blindsided by this I assume you want to read the file in at runtime, (so when somebody runs the binary, not when you create the binary) correct?
19:27:44FromDiscord<Phil> ( @alwaysoutofrange )
19:28:12FromDiscord<Phil> (edit) "C-code.↵That" => "C-code (because that's usually the way file-reading is done at runtime).↵That"
19:28:22FromDiscord<Phil> (edit) "Basically the issue you're running into is that you're trying to do something at compiletime that calls out to C-code (because that's usually the way file-reading is done at runtime).↵That is not doable. There are ... utilities" added "special"
19:30:14FromDiscord<alwaysoutofrange> correct but a question is it possible to get this error when you selected in `nimble init` hybrid as project type?
19:30:44FromDiscord<Phil> I... don't understand
19:30:59FromDiscord<Phil> Oh, when setting up the project
19:31:23FromDiscord<alwaysoutofrange> yes
19:31:25FromDiscord<Phil> Beats me tbh, it's not like that does all that much,
19:32:18FromDiscord<Phil> So that really is unlikely to be the problem.↵Basically show your code 😛
19:32:50FromDiscord<Phil> Or rather the elements interacting with what you posted, because one of those is in a compile-time context
19:34:00FromDiscord<alwaysoutofrange> thats all my code nothing more nothing less https://media.discordapp.net/attachments/371759389889003532/1184578989575114812/image.png?ex=658c7c27&is=657a0727&hm=a065e0bac42d07c55ce919074c88554bc352a81f97201c150a4ee2ed227c3872&
19:34:45FromDiscord<Phil> What's screwing you is const replay = readReplayFile()
19:35:01FromDiscord<alwaysoutofrange> oh you right
19:35:05FromDiscord<alwaysoutofrange> its not knows at compile time
19:35:07FromDiscord<alwaysoutofrange> thats mate
19:35:14FromDiscord<Phil> `const` turns leads to everything on the right hand side to be run at compiletime
19:35:19FromDiscord<Phil> (edit) removed "turns"
19:35:29FromDiscord<Phil> (edit) "`const` leads to everything on the right hand side ... to" added "of the const-assignment"
19:35:30FromDiscord<alwaysoutofrange> (edit) "thats" => "thanks"
19:35:48FromDiscord<Phil> That means it'll try to run readReplayFile at compiletime, which isn't possible with the procs you're using
19:35:59FromDiscord<Phil> If you really want to read those in at compiletime you can use staticRead
20:58:03FromDiscord<Elegantbeef> It's a good day when I open my chat and do not see a notification from Phil 😄
20:58:52FromDiscord<Phil> Lets change that!↵Beef, have you played around with threading/channels and what were your experiences 😛
20:59:16FromDiscord<Elegantbeef> I have, my code worked
20:59:39FromDiscord<Phil> Because by now I've seen clogged channels, silently dropped messages and somehow slower speeds than system.channels in my more common scenarios with threadbutler
20:59:53FromDiscord<nnsee> In reply to @Elegantbeef "I have, my code": my deepest fantasy
21:00:09FromDiscord<Elegantbeef> "clogged channels"?
21:00:25FromDiscord<Elegantbeef> How are you dequing messages?
21:00:29FromDiscord<Phil> That was me bombarding a channel with 200 messages in a couple ms, it filled up at 30 and when trying to send the 31st the thread just got blocked
21:01:43FromDiscord<Elegantbeef> Send should not clog up
21:02:21FromDiscord<Phil> tryRecv, but the setup was first send 200ms from Thread A to Thread B through channel1 where ThreadB was waiting and reading them and sending response messages back through channel2.↵After sending all the messages I then start a while-loop that reads messages from channel2, but that channel has been filled up already at that point (apparently there's a capacity of 30 or sth?) and ThreadB is hanging
21:02:29FromDiscord<Phil> or dropping messages if you're using trySend
21:02:51FromDiscord<Elegantbeef> I mean trysend drops intentionally
21:03:00FromDiscord<Phil> (edit) "channel2," => "channel2 on Thread A," | "channel2 on Thread A,but that channel has been filled up already at that point ... (apparently" added "by Thread B"
21:03:02FromDiscord<Elegantbeef> The entire point is that if you cannot send you don't send
21:03:22FromDiscord<Phil> Yeah but I never have that capacity problem with system.Channels! xP
21:03:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:04:13FromDiscord<Elegantbeef> I mean you're using trysend and complaining about dropped data
21:05:00FromDiscord<Elegantbeef> Try send is like a kid dropping food, it'll look at it and start crying, you need to handle that dropped food
21:05:09FromDiscord<Phil> More like I'm complaining about the stuck send
21:05:19FromDiscord<Phil> Which translates to dropped messages with trySend
21:05:30FromDiscord<Elegantbeef> If trysend is "stuck" there is a bug in the code
21:05:32FromDiscord<Phil> And is the result of channels-clogging
21:05:57FromDiscord<Elegantbeef> Give me an example that I can run instead of speaking in weird analogous talk 😄
21:06:53FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:07:20FromDiscord<Phil> This is a cut-down version of me playing around with both versions of channels
21:08:03FromDiscord<Phil> Cut out the code for #test1 which was the bits setting up and playing with Channel instead of threading/channel
21:20:30FromDiscord<Elegantbeef> `threading/channels` is a fixed size queue
21:20:59FromDiscord<Elegantbeef> `newChan[T](100)`
21:21:28FromDiscord<Phil> That... would've been nice to see somewhere... Oh that's what the "elements" parameter means!
21:21:37FromDiscord<Elegantbeef> Yes
21:22:09FromDiscord<graveflo> elements must be where you put the elements right?
21:22:11FromDiscord<Elegantbeef> I intially thought it was just a preallocation, but nope it's fixed size
21:22:22FromDiscord<Elegantbeef> It has no growth logic
21:23:13FromDiscord<Phil> In reply to @graveflo "elements must be where": I'd need to actually understand what channels are to make that inferrence.↵I see them right now as a more native version of websockets:↵I push things through them to another thread.
21:23:36FromDiscord<Elegantbeef> Channels are just a thread safe queue
21:24:06FromDiscord<cy_tek> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:24:33FromDiscord<graveflo> In reply to @isofruit "I'd need to actually": I was joking. I think that is a poor name if it was supposed to be the number of elements or a buffer size or something
21:26:06FromDiscord<nervecenter> In reply to @cy_tek "Hi all 🙂 I'm": My guess is that the SDL libraries have a specific set of functions for shutdown and deallocation which are not friendly to the Nim `destroy` hook.
21:26:06FromDiscord<Phil> So what I'm getting out of this is since I now understand channels way better than ever before I should make yet another documentation PR
21:26:11FromDiscord<Phil> My arch nemesis
21:26:21FromDiscord<Elegantbeef> Or a change that makes them growable
21:26:23FromDiscord<Elegantbeef> Either one works 😄
21:26:23FromDiscord<Phil> Because there's definitely a decent amount of info missing in these docs
21:26:33FromDiscord<Phil> I'm not fucking with actual implementation, Araq can do that
21:26:46FromDiscord<nervecenter> (edit) "In reply to @cy_tek "Hi all 🙂 I'm": My guess is that the SDL libraries have a specific set of functions for shutdown and deallocation which are not friendly to the Nim `destroy` hook. ... " added "I'm not experienced in 3D engines but I've toyed with them in the past and they all seem to have a specific spin-down process."
21:26:53FromDiscord<Elegantbeef> Well an issue perhaps to see if they should be growable
21:27:03FromDiscord<nervecenter> (edit) "In reply to @cy_tek "Hi all 🙂 I'm": My guess is that the SDL ... libraries" added "and OpenGL"
21:27:08FromDiscord<Phil> I've made one, but didn't understand it was a grow-issue
21:27:17FromDiscord<Phil> The code I gave you stems from said issue
21:27:55FromDiscord<Elegantbeef> Sure but now you know the actual issue so can specify what the actual issue is 😄
21:28:08FromDiscord<Phil> Yeh, already typing away
21:28:13FromDiscord<cy_tek> In reply to @nervecenter "My guess is that": Ahh, yeah, that makes sense. I've definitely seen that before too, guess I was just expecting the bindings to be just bindings not a wrapper that might do something weird like that haha. Or maybe to problem is that it's only a binding haha. I'll take a look at the source code around that and see if I can find something in that area. Thanks for the pointer 🙂
21:30:27FromDiscord<Elegantbeef> Will say it's weird to test a graphic program in WSL
21:30:41FromDiscord<Elegantbeef> Like yes they work, but it's not really a representation of a real system
21:30:50FromDiscord<nnsee> try an actual vm
21:30:54FromDiscord<nnsee> super easy to set up
21:30:56FromDiscord<Elegantbeef> Not to say I do not use wine occasionally to test windows binaries
21:31:08FromDiscord<Elegantbeef> Just purge winblows it's even easier!
21:31:28FromDiscord<nnsee> it might just be wsl fuckery
21:31:29FromDiscord<Elegantbeef> Put linsux on your PC today!
21:33:59FromDiscord<Phil> https://github.com/nim-lang/threading/issues/52#issuecomment-1854731685 There you go, with honorable mention 😛
21:34:22FromDiscord<Elegantbeef> I'm so popular my name is put twice
21:34:31FromDiscord<cy_tek> I'll try a vm then haha. And unfortunately some of the graphics applications I use rely on windows, and I've had a ton of problems with my laptop's internet chip with linux. I've tried many times to use linux and always come away a bit dissapointed honestly haha. There are things I love, but a lot of headaches too.
21:34:37FromDiscord<Phil> Just means there's double demand for you
21:34:55FromDiscord<nnsee> In reply to @Elegantbeef "I'm so popular my": the first elegantbeef is just a description
22:06:41FromDiscord<Phil> Okay, I am now mildly proud that the entire "chess engine runs parallel in second thread" problem which requires 2 thread permanently running side by side is apparently not a super trivial problem for those skilled in concurrency
22:06:50FromDiscord<Phil> I shall proceed with patting myself on the back
22:07:07FromDiscord<Phil> (See recent #internals chat)
23:04:44*jmdaemon joined #nim
23:12:20*zgasma joined #nim
23:32:12FromDiscord<inv2004> Hi, Are there any easy way to extract object fields in macro?
23:32:27FromDiscord<inv2004> (edit) "Hi, Are there any easy way ... to" added "(not very complicate)"
23:35:36FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:35:50FromDiscord<Phil> Or do you mean in a proc inside a macro?
23:36:08FromDiscord<Phil> In which case no super easy way, you'll need to write yourself utilities
23:37:00FromDiscord<Phil> You could write yourself a "get node of kind" that recursively traverses an AST and fetches lists of a specific kind
23:37:13FromDiscord<Phil> Then fetch an nnkRecList node and that's your list of fields, you can iterate over that
23:37:38FromDiscord<inv2004> I think it is more proc inside macro. I want to extract all fields from object I pass into macro ... but to build ast after it
23:38:09FromDiscord<Phil> In that case, I can hand you a proc I wrote for myself, one sec
23:38:12FromDiscord<inv2004> maybe it is even a bit more complicate with object with kind case
23:38:39FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:38:59FromDiscord<Phil> ignore procBody as a param name, that should work for any nimnode
23:39:14*advesperacit quit ()
23:39:16FromDiscord<Phil> Use that to look for the nnkRecList node and then you can iterate over all child-nodes of nnkreclist, that contains the identifiers you seek
23:39:23FromDiscord<inv2004> let me highlight it is a bit - all I need is pretty simple: I want to have ability to change kind of the object (it is possible), but switch of the kind should support default values
23:39:52FromDiscord<Phil> In reply to @inv2004 "maybe it is even": Oh lord, you want to do stuff on an object variant?
23:40:11FromDiscord<inv2004> so, the only way I suppose is to create new object and pass all kinds from the prev object, except the last kind I want to change
23:40:20FromDiscord<Phil> Given I wrote mapster, which deals with mapping including to and from object variants I have utils for this, let me see if I can find then
23:40:59FromDiscord<inv2004> from non-macro it is not hard to generate it with fieldPairs, but I wanted to make it from macro
23:41:00FromDiscord<gogolxdong666> Is there any way to get the most inner json field like "input"
23:41:49FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:42:03FromDiscord<inv2004> oh, thx. let me check the code
23:42:36FromDiscord<Phil> Actually the expectKind proc I posted may be unnecessary, just ignore those nimnode checks or substitute with your own
23:42:53FromDiscord<double_spiral> can someone explain why this doesnt work? Im having trouble comprehending these error messages https://media.discordapp.net/attachments/371759389889003532/1184641626296041472/image.png?ex=658cb67d&is=657a417d&hm=010c0b1c6fb9c8e895508f8548c062d862103aa3bd837a3a06571c4c9159449e&
23:43:21FromDiscord<Phil> In reply to @gogolxdong666 "Is there any way": Define "inner most field"
23:44:22FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:44:43FromDiscord<Elegantbeef> @double_spiral in Nim `ref` means a Nim allocated resource that lives on the heap
23:44:47FromDiscord<Elegantbeef> so `addr T` returns `ptr`
23:45:28FromDiscord<double_spiral> Is there a way i can get what nim expects from my variable? when i remove the addr it doesnt work either
23:45:31FromDiscord<Phil> Note: ref is traced so it can be used for garbage collection, there's ref counters and everything - pointers completely side-step that
23:45:53FromDiscord<Elegantbeef> Compile the code and look at the compiler output
23:46:11FromDiscord<gogolxdong666> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:46:16FromDiscord<double_spiral> In reply to @Elegantbeef "Compile the code and": i still dont understand the errors tho
23:46:18FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:46:25FromDiscord<Elegantbeef> What does the compiler say?
23:47:21FromDiscord<Phil> Also to expand on beefs advice:↵The compiler is the ultimate source of truth, particularly given nim's highly malleable syntax.↵Nimsuggest has in more difficult cases like this a non-zero chance of just being wrong or misleading in its messaging.
23:47:50FromDiscord<Elegantbeef> moreover the compiler stops at a single error so you do not have noise
23:47:52FromDiscord<Phil> That's why its better to look at compiler errors rather than nimsuggest messages
23:48:15FromDiscord<Elegantbeef> If you use `nim check --errorMax:10` you get in a similar boat of noise
23:48:17FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:48:29FromDiscord<gogolxdong666> the input field
23:48:38FromDiscord<Phil> There's like 2, you want both?
23:48:47FromDiscord<inv2004> @Phil is it `zero_functional` or sequtils?
23:48:50FromDiscord<graveflo> whats with the `ref ptr ...` anyway
23:48:52FromDiscord<double_spiral> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:49:05*casaca quit (Changing host)
23:49:05*casaca joined #nim
23:49:16FromDiscord<Elegantbeef> people assume `ref` is a pointer often
23:49:18FromDiscord<Phil> In reply to @inv2004 "<@180601887916163073> is it `zero_functional`": sequtils. I haven't used zerofunctional
23:49:25FromDiscord<gogolxdong666> sent a long message, see <!doctype html>
23:49:33FromDiscord<Phil> But if you can replace mapIt etc. with stuff from zerofunctional that should do it as well
23:50:34FromDiscord<Phil> In reply to @double_spiral "thx phil youre the": insert goat bleating
23:50:56FromDiscord<inv2004> @Phil I see flatten I cannot detect it from
23:50:56FromDiscord<Phil> In reply to @gogolxdong666 "def item_generator(json_input, lookup_key): ": So... both?
23:51:02FromDiscord<Phil> Let me check
23:51:21FromDiscord<Phil> Oh, wups
23:51:28FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:51:32FromDiscord<inv2004> thx!
23:51:53FromDiscord<Phil> That's how you see how well I remember my own code, my own utilities confuse me xD
23:53:27FromDiscord<Phil> @gogolxdong666 Just for reference, I currently am still not sure what entirely you want.↵If you want a proc that recursively traverses your JsonNodes and fetches you all JsonNodes with the name "input" that's pretty doable
23:53:46FromDiscord<gogolxdong666> the deepth is unknown in advance
23:54:52FromDiscord<Phil> Sure, just store a `tuple[depth: int, node: JsonNode]` , keep track of the depth as you recursively go through the Nodes and always compare any input-node against the depth you already have recorded
23:55:05FromDiscord<Phil> (edit) "Sure, just store a `tuple[depth: int, node: JsonNode]` , keep track of the depth as you recursively go through the Nodes and always compare ... any" added "the depth of"
23:55:12FromDiscord<Phil> (edit) "Sure, just store a `tuple[depth: int, node: JsonNode]` , keep track of the depth as you recursively go through the Nodes and always compare the depth of any input-node ... against" added "you find"
23:56:54FromDiscord<Phil> One sec, are you solid with doing a recursion over a Json-tree like that?
23:58:58FromDiscord<Phil> In reply to @double_spiral "thx phil youre the": Just for reference:↵new always does a heap allocation and passes you the ref to that heap.↵Then you just fill the memory that ref points to with a value (`[]` is unreffing in nim), done
23:59:10FromDiscord<Phil> (edit) "heap.↵Then" => "heap you just allocated.↵Then"
23:59:14FromDiscord<Elegantbeef> "unreffing"
23:59:27FromDiscord<Elegantbeef> The colloquial term is "dereferencing"
23:59:32FromDiscord<Phil> too long
23:59:39FromDiscord<Elegantbeef> tldr
23:59:45FromDiscord<Phil> Be happy I'm not typing unrfing
23:59:54FromDiscord<Elegantbeef> unrfng