00:01:25 | FromDiscord | <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:03 | FromDiscord | <Phil> sent a long message, see <!doctype html> |
01:21:45 | FromDiscord | <rubythulhu> what's the overall community attitude towards using `result` vs creating a named var? |
01:22:23 | FromDiscord | <Elegantbeef> It's generally preferred |
01:23:02 | FromDiscord | <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:41 | FromDiscord | <Elegantbeef> result is very good for accumulators |
01:23:48 | FromDiscord | <Elegantbeef> But I prefer expressions |
01:23:56 | FromDiscord | <Elegantbeef> Where possible of course |
01:24:20 | FromDiscord | <rubythulhu> i'm asking because i find myself like 50/50 right now |
01:24:33 | FromDiscord | <rubythulhu> kinda really like result, but it still feels dirty |
01:26:21 | FromDiscord | <Elegantbeef> Well what do your procs look like? |
01:26:23 | FromDiscord | <Elegantbeef> Are they accumulators? |
01:27:46 | FromDiscord | <rubythulhu> all kinds. i kinda see benefits of either solution in any function w/ a return value |
01:28:10 | FromDiscord | <Elegantbeef> I mean if you're using result in code that can be an expression I think you're abusing it |
01:28:25 | FromDiscord | <Elegantbeef> I say that though often use `result` inside of macros due to the added debuggabillity |
01:28:44 | FromDiscord | <graveflo> like most things if you see value in different ways then use them in different ways |
01:28:52 | FromDiscord | <rubythulhu> yeah |
01:29:10 | FromDiscord | <rubythulhu> i feel like "as an accumulator" is too specific for me |
01:29:26 | FromDiscord | <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:04 | FromDiscord | <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:06 | FromDiscord | <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:32 | FromDiscord | <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:14 | FromDiscord | <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:13 | FromDiscord | <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:20 | FromDiscord | <Elegantbeef> Worth noting you can use them in conjunction, but it's not advisable 😄 |
01:36:32 | FromDiscord | <Elegantbeef> `result = x; return` is a silly idiom |
01:36:34 | FromDiscord | <graveflo> I do this all the time LOL |
01:36:35 | FromDiscord | <Elegantbeef> `return x` is more sane |
01:36:38 | FromDiscord | <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:50 | FromDiscord | <Elegantbeef> I do not mean using result and returning in some cases |
01:36:54 | FromDiscord | <Elegantbeef> I mean setting result then returning |
01:37:14 | FromDiscord | <rubythulhu> yeah that's the failure point imo |
01:37:21 | FromDiscord | <graveflo> oh well.. I'll start doing that then since I've already committed |
01:37:48 | FromDiscord | <Elegantbeef> Just embrace expressions, and be merry! |
01:37:52 | FromDiscord | <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:44 | FromDiscord | <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:30 | FromDiscord | <Elegantbeef> Yea without a code example I only speak in generalities |
01:41:40 | FromDiscord | <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:33 | FromDiscord | <graveflo> sent a long message, see <!doctype html> |
01:45:19 | FromDiscord | <Elegantbeef> I do prefer not having early escapes myself as you do not have to think about the anti logic |
01:45:43 | FromDiscord | <Elegantbeef> `if someCond: ...` is better than `if not someCond: return; ....` but ymmv |
01:59:43 | FromDiscord | <rubythulhu> depends on the circumstance |
02:02:15 | FromDiscord | <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:44 | FromDiscord | <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:33 | NimEventer | New thread by stbalbach: Cannot open: /dev/stderr, see https://forum.nim-lang.org/t/10761 |
03:15:39 | * | edr quit (Quit: Leaving) |
05:22:11 | FromDiscord | <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:09 | FromDiscord | <tomexmachina> sent a long message, see <!doctype html> |
05:29:45 | FromDiscord | <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:58 | FromDiscord | <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:40 | FromDiscord | <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:30 | FromDiscord | <Elegantbeef> You do not need it likely when installing |
05:41:37 | FromDiscord | <zectbumo> problem being that when I `nim r mygl` I get `No supported window creation API selected` |
05:42:12 | FromDiscord | <Elegantbeef> what about `nim r -d:GLFW_USE_X11 mygl`? |
05:42:44 | FromDiscord | <zectbumo> same. maybe I'm defining the wrong symbol |
05:43:39 | FromDiscord | <zectbumo> I'm following https://www.glfw.org/docs/3.3/compile_guide.html |
05:43:58 | FromDiscord | <zectbumo> it says "By default GLFW will use X11 on Linux" but doesn't seem to be true |
05:44:13 | FromDiscord | <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:34 | FromDiscord | <michaelb.eth> (edit) "[nimble_flatgs" => "[nimble_flags]" |
05:44:42 | FromDiscord | <Elegantbeef> you want `--passL:"-d...."` |
05:51:18 | FromDiscord | <Elegantbeef> sorry should be `nim r --passL:"-DGLFW_USE_X11" mygl` |
05:51:23 | FromDiscord | <zectbumo> thx `nim r --passC:-D_GLFW_X11` got me further along. now wants X11 libs |
05:53:54 | FromDiscord | <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:33 | FromDiscord | <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:28 | FromDiscord | <zectbumo> it's looking for the X11 libs so I have to now pass the include dir using -I |
06:00:52 | FromDiscord | <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:07 | FromDiscord | <zectbumo> bummer |
06:02:47 | FromDiscord | <zectbumo> https://github.com/treeform/staticglfw/blob/master/src/staticglfw/null_init.c#L49C18-L49C18 |
06:03:33 | FromDiscord | <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:35 | FromDiscord | <zectbumo> why is code rot so strong? |
06:13:28 | FromDiscord | <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:28 | FromDiscord | <zectbumo> maybe I need define `_GLFW_OSMESA` |
06:19:38 | FromDiscord | <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:58 | FromDiscord | <alireza0x0> hey there |
06:24:09 | FromDiscord | <alireza0x0> how should i get current refrence count of a ref? |
06:24:20 | FromDiscord | <alireza0x0> python had something like system.rc function or whatever |
06:30:44 | FromDiscord | <Elegantbeef> Nim does not have a API for that but you can always make one |
06:31:23 | FromDiscord | <Elegantbeef> https://github.com/nim-works/arc |
06:42:48 | FromDiscord | <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:34 | FromDiscord | <Elegantbeef> Just use sdl2 😄 |
06:47:09 | FromDiscord | <zectbumo> I'm poking around nimble.directory. is there some live demo I can check out that uses sdl2? |
06:47:43 | FromDiscord | <Elegantbeef> https://github.com/Vladar4/sdl2_nim/tree/master/examples |
06:48:31 | FromDiscord | <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:34 | FromDiscord | <Elegantbeef> I don't know what you're doing, but sdl2 is quite simple to setup and use |
06:48:51 | FromDiscord | <zectbumo> I'm trying to have some fun |
06:48:53 | FromDiscord | <Elegantbeef> It'll call the `=destroy` at end of scope |
06:49:04 | FromDiscord | <alireza0x0> before the block ends it should reduce rc count of global by 1 because owner2 is destroyed |
06:49:11 | FromDiscord | <alireza0x0> but anything else? |
06:49:27 | FromDiscord | <Elegantbeef> That assumes it even increments the count and doesn't just make a cursor |
06:49:56 | FromDiscord | <alireza0x0> hhmmm? |
06:50:20 | FromDiscord | <alireza0x0> if it creates a cursor for owner2 |
06:50:26 | FromDiscord | <alireza0x0> then it should not destroy it right? |
06:50:35 | FromDiscord | <alireza0x0> so the rc is not changed... or am i wrong? |
06:50:45 | FromDiscord | <Elegantbeef> Correct it probably will copy the ref incrementing the pointer |
06:50:59 | FromDiscord | <Elegantbeef> Cursors never work how I think they do |
06:51:09 | FromDiscord | <alireza0x0> 😄 |
06:51:19 | FromDiscord | <alireza0x0> i don't know how they work either |
06:51:24 | FromDiscord | <Elegantbeef> Anyway stop caring about rc |
06:51:33 | FromDiscord | <alireza0x0> but they look like something like the {.byaddr.} prgama |
06:52:26 | FromDiscord | <alireza0x0> i want to (try at least) share the ref to the threads so im trying to find a secure way... |
06:52:39 | FromDiscord | <Elegantbeef> Welcome to Nim threading hell |
06:52:47 | FromDiscord | <Elegantbeef> sharing refs across threads never works |
06:52:58 | FromDiscord | <Elegantbeef> Unless you use `atomicarc` |
06:53:04 | FromDiscord | <alireza0x0> they are just c++ shared ptrs i think |
06:53:16 | FromDiscord | <alireza0x0> if you respect the ref and only work with it inside the corresponding lock |
06:53:22 | FromDiscord | <alireza0x0> nothing should go wrong... |
06:53:34 | FromDiscord | <Elegantbeef> Except that you cannot share refs with single ownership |
06:54:02 | FromDiscord | <alireza0x0> for those you have to use move everywhere... |
06:54:09 | FromDiscord | <alireza0x0> (edit) "move" => "`move`" |
06:54:33 | FromDiscord | <Elegantbeef> Eh it never works as it should in my testing |
06:54:40 | FromDiscord | <alireza0x0> a single ownership ref is Isolated[T] right? |
06:54:50 | FromDiscord | <Elegantbeef> No |
06:54:53 | FromDiscord | <alireza0x0> nim had something like `owned` keyword but thats deprecated right? |
06:55:07 | FromDiscord | <Elegantbeef> I mean it does not work with Nim's single ownership |
06:55:22 | FromDiscord | <Elegantbeef> One thread must own a thread but there is no way to communicate you are not giving it up |
06:55:27 | FromDiscord | <alireza0x0> how you define a single owner ref then? |
06:55:39 | FromDiscord | <Elegantbeef> It's easier to just do `ptr YourRef()[]` and use that across threads |
06:55:49 | FromDiscord | <Elegantbeef> I mean Nim's refs are single thread owned is my point |
06:56:09 | FromDiscord | <Elegantbeef> You cannot share a ref to another thread when both threads attempt to free it |
06:57:11 | FromDiscord | <Elegantbeef> Actually I'm being daft the issue was moving refs without using isolated |
06:57:19 | FromDiscord | <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:33 | FromDiscord | <alireza0x0> i have to right a good test for them and using valgrind ... hard work |
06:57:38 | FromDiscord | <Elegantbeef> I mean if you have a global resource you do not need any lock on the rc |
06:57:41 | FromDiscord | <alireza0x0> (edit) "right" => "write" |
06:57:44 | FromDiscord | <Elegantbeef> i mean any atomic operation on the rc |
06:58:07 | FromDiscord | <Elegantbeef> If it's a global resource it gets cleared at the end of the main thread |
06:58:20 | FromDiscord | <Elegantbeef> Atleast it should regardless of rc |
06:58:25 | FromDiscord | <alireza0x0> the rc value will mess up if |
06:58:35 | FromDiscord | <alireza0x0> threads inc or dec it at same time |
06:58:40 | FromDiscord | <alireza0x0> something like this example |
06:59:02 | FromDiscord | <Elegantbeef> Sure but if it's a global reference the rc should not matter |
06:59:08 | FromDiscord | <alireza0x0> sent a code paste, see https://play.nim-lang.org/#ix=html> |
06:59:14 | FromDiscord | <Elegantbeef> Since you know at the end of the main thread all global resources need to be cleared |
06:59:54 | FromDiscord | <Elegantbeef> I might be lacking some amount of sleep though so I might be very wrong 😄 |
07:00:23 | FromDiscord | <alireza0x0> no i don't think you are thinking wrong |
07:00:28 | FromDiscord | <alireza0x0> i need more thinking ofcourse |
07:00:52 | FromDiscord | <alireza0x0> but thats the point where i am right now... valgrind will decide i can do these or not |
07:25:48 | FromDiscord | <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:32 | FromDiscord | <Elegantbeef> Start using opengl and crying about graphics programming |
07:28:57 | FromDiscord | <zectbumo> that bad huh? |
07:29:12 | FromDiscord | <Elegantbeef> It's not bad it's fun |
07:29:33 | FromDiscord | <zectbumo> oh I'm crying with laughter. 😂 |
07:36:02 | * | advesperacit joined #nim |
07:36:36 | FromDiscord | <zectbumo> this is pretty fun https://nimble.directory/pkg/glbits |
08:48:28 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
08:49:50 | FromDiscord | <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:01 | FromDiscord | <Elegantbeef> Nim has a shared heap now |
08:51:15 | FromDiscord | <Elegantbeef> so all of those are stored on the heap and the pointers point to where you need to go |
08:51:42 | FromDiscord | <Phil> So there's a single instance of `ChannelHub` that is used by all threads? |
08:51:56 | FromDiscord | <Phil> on the shared heap |
08:52:51 | FromDiscord | <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:52 | FromDiscord | <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:42 | FromDiscord | <Elegantbeef> So if you have a global `ref` it's a single `ChannelHub` |
08:54:16 | FromDiscord | <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:38 | FromDiscord | <Elegantbeef> clonkk to respond to your #internals question here, yesn't 😄 |
08:54:51 | FromDiscord | <Elegantbeef> Right it's shared to all the other thread so still 'global' |
08:55:21 | FromDiscord | <Phil (he/him)> Okay, fair |
08:55:27 | FromDiscord | <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:36 | FromDiscord | <Clonkk> Hence the question ^^ |
08:55:59 | FromDiscord | <Clonkk> Plus, potential read / write after free are kinda ugly \:p |
08:56:03 | FromDiscord | <Elegantbeef> Well `ptr ref` being nil after freeing depends on so much |
08:56:19 | FromDiscord | <Clonkk> I'm talking about the ref itself not the pointer |
08:56:24 | FromDiscord | <Elegantbeef> I know |
08:56:56 | FromDiscord | <Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=html> |
08:56:59 | FromDiscord | <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:00 | FromDiscord | <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:17 | FromDiscord | <Phil (he/him)> \correct? |
08:57:55 | FromDiscord | <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:07 | FromDiscord | <Elegantbeef> Channels are threadsafe queues yes |
08:58:22 | FromDiscord | <Elegantbeef> what you're doing later\ |
08:59:12 | FromDiscord | <Elegantbeef> It sounds like you're trying to give up ownership of GC'd resources? |
08:59:26 | FromDiscord | <Elegantbeef> In that case I'd say use `GcRef` and `GcUnref` |
09:05:56 | FromDiscord | <Clonkk> I am converting =destroy(x\: var T) to =destroy(x\: T) for object that are `importc` |
09:06:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html> |
09:06:26 | FromDiscord | <Elegantbeef> Atleast on my machine that demonstrates the issue |
09:07:03 | FromDiscord | <Elegantbeef> Right you should write a `=destroy` and `=wasMoved` now |
09:07:04 | FromDiscord | <Clonkk> Yep |
09:07:06 | FromDiscord | <Elegantbeef> `=destroy` calls destruction, `=wasMoved` nils everything out |
09:09:20 | FromDiscord | <Elegantbeef> Do you have a more elaborate example I could look at? |
09:09:54 | FromDiscord | <Clonkk> https://github.com/nim-lang/nim-zmq/pull/40 |
09:09:59 | FromDiscord | <Clonkk> I'll push the latest |
09:13:55 | FromDiscord | <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:55 | FromDiscord | <Elegantbeef> Ok so what's the issue with the AsyncZPoller destructor? |
09:17:20 | FromDiscord | <Elegantbeef> You want to destroy the `cb` but `=destroy` does not work on `seq[T]` in 2.0? |
09:19:39 | FromDiscord | <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:01 | FromDiscord | <Elegantbeef> Ah I'd suggest just using valgrind with `-d:useMalloc` to test it |
09:20:14 | FromDiscord | <Elegantbeef> But you do need to call `=destroy(obj.cb)` |
09:21:07 | FromDiscord | <Elegantbeef> https://forum.nim-lang.org/t/10642 forum post related to the aforementioned thing I mentioned |
09:21:51 | FromDiscord | <Elegantbeef> You need to call `=destroy` on all fields that can own memory |
09:22:26 | FromDiscord | <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:34 | FromDiscord | <Elegantbeef> That's an open ended question you can use any feature that you have a C/C++ compiler for |
09:23:57 | FromDiscord | <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:08 | FromDiscord | <Clonkk> Yeah that's always a possibility but I tends to avoid valgrind as much as i can, it's too verbose |
09:24:36 | FromDiscord | <Elegantbeef> > ==106386== All heap blocks were freed -- no leaks are possible |
09:24:41 | FromDiscord | <Elegantbeef> That's all you have to check for |
09:25:17 | FromDiscord | <Elegantbeef> a simple strscans iteration of the output is enough 😄 |
09:26:21 | FromDiscord | <Phil> Hmm decent colors to represent thread A vs thread B vs. a shared resource |
09:26:43 | FromDiscord | <Elegantbeef> First they coloured our functions now they colour our threads |
09:26:56 | FromDiscord | <Elegantbeef> blue, green, yellow |
09:27:12 | FromDiscord | <Phil> I'm mostly working on a sequence diagram on how the message passing works in mermaidjs, thus the question |
09:28:07 | FromDiscord | <Phil> That is on you beef: https://media.discordapp.net/attachments/371759389889003532/1184426514259922955/image.png?ex=658bee26&is=65797926&hm=13468ecd4a85b602cc91ee965231d7ffb4242b4e104be321c45205676e179fbe& |
09:28:25 | FromDiscord | <Elegantbeef> Oh nice valgrind has a `--error-exitcode` so you do not even needs to use strscans |
09:28:28 | FromDiscord | <Phil> Okay the green works but blue and yellow lead to terrible text contrast |
09:29:40 | FromDiscord | <Elegantbeef> as simple as `let (output, err) = execCmdEx("valgrind --error-exitcode=1 bleh"); check err == 0` 😄 |
09:30:04 | FromDiscord | <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:33 | FromDiscord | <Elegantbeef> I do like how bad you are at picking colours |
09:30:35 | FromDiscord | <Elegantbeef> Full saturation |
09:30:45 | FromDiscord | <Elegantbeef> There is no such thing as "some saturation" in Phil's world |
09:30:58 | FromDiscord | <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:01 | FromDiscord | <Elegantbeef> He turns it to 11 11/10 times |
09:31:02 | FromDiscord | <Phil> You missunderstand, this is a mermaidjs block in obsidian |
09:31:04 | FromDiscord | <Clonkk> Also std/unittest seems to have error |
09:31:08 | FromDiscord | <Phil> I don't choose the colors, I get words to pick from |
09:31:29 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
09:31:47 | FromDiscord | <shirleyquirk> Cheers @ElegantBeef |
09:32:09 | FromDiscord | <Phil> However, unrelated to that you would still be entirely correct in saying I am horrible with picking out colors |
09:32:25 | FromDiscord | <Phil> But the entire "saturation way too brutal" I can at least somewhat make out |
09:39:05 | FromDiscord | <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:19 | FromDiscord | <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:26 | FromDiscord | <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:29 | FromDiscord | <Elegantbeef> Try except is only really expensive on the fail path |
09:39:40 | FromDiscord | <Elegantbeef> It has a mild overhead on the good path |
09:40:39 | FromDiscord | <TӨMΛ ☠> So it's more universal, I see. That's amazing to know ❤️ |
09:45:40 | * | PMunch joined #nim |
09:49:04 | PMunch | Yeah that's a pretty general thing |
09:49:20 | PMunch | The expensive part of an exception is gathering the stacktrace |
09:56:49 | FromDiscord | <nnsee> is the stacktrace gathered if the exception is caught? |
09:58:53 | PMunch | Phil: https://mermaid.js.org/config/theming.html you can change the colours manually ;) |
09:59:16 | PMunch | nnsee, I think the stacktrace is gathered when it is raised |
10:00:15 | PMunch | I mean you can catch an exception and then call `getStackTrace` on it |
10:00:52 | FromDiscord | <nnsee> so using the try/except pattern in general still averages out to having somewhat of a performance penalty |
10:01:23 | FromDiscord | <nnsee> (edit) "so using the try/except pattern ... in" added "for execution flow" |
10:04:04 | PMunch | Yeah, they aren't really made for execution flow |
10:06:55 | FromDiscord | <nnsee> that doesn't stop people from using it for that :p also, the raises pragma somewhat encourages this pattern |
10:08:13 | FromDiscord | <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:21 | FromDiscord | <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:58 | FromDiscord | <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:24 | FromDiscord | <nnsee> wait, why couldn't you just catch SIGTERM? |
10:10:53 | FromDiscord | <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:00 | FromDiscord | <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:09 | FromDiscord | <Phil> (edit) "thread," => "thread immediately," |
10:13:57 | FromDiscord | <nnsee> i suppose a nim exception is also more portable |
11:03:00 | PMunch | Exceptions 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:08 | PMunch | It 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:04 | FromDiscord | <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:43 | FromDiscord | <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:13 | PMunch | Hmm, I wonder if it would be possible to implement exceptions in Nim outside the existing exceptions |
11:13:55 | PMunch | I guess not, because of how the GC analysis works |
11:20:56 | NimEventer | New thread by jmgomez: Nim Tooling Roadmap, see https://forum.nim-lang.org/t/10762 |
11:30:26 | FromDiscord | <Clonkk> Anyone knows if it's "normal" that valgrind detect memory leak using asyncdispatch ? |
11:31:11 | FromDiscord | <Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=html> |
11:33:22 | PMunch | Do you compile with -d:useMalloc? |
11:33:30 | FromDiscord | <Clonkk> yes |
11:33:39 | PMunch | hmm, then it shouldn't leak |
11:33:44 | FromDiscord | <Clonkk> `nim cpp -d:useMalloc` |
11:33:53 | FromDiscord | <Clonkk> mm\:orc threads\:on by default |
11:36:04 | FromDiscord | <Clonkk> Yeah i thought so too, i just wanted to check↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
11:36:10 | FromDiscord | <Clonkk> Welp https://github.com/nim-lang/Nim/issues/23066 |
11:40:32 | FromDiscord | <Clonkk> So apparently it's normal \:) |
11:42:31 | FromDiscord | <Phil> TFW you validate your incoming NimNodes everywhere so aggressively you're approaching something resembling static type checking |
12:33:26 | NimEventer | New thread by vanyle: Nim program crashes when using recursivity and openarray, see https://forum.nim-lang.org/t/10763 |
12:43:23 | FromDiscord | <Phil> ... is there a way to store a bunch of strings at compiletime and use that at runtime as a const? |
12:43:55 | Amun-Ra | sure |
12:46:05 | FromDiscord | <Phil> In global scope |
12:46:10 | FromDiscord | <nnsee> In reply to @isofruit "... is there a": am i misunderstanding? isn't that just const? |
12:46:23 | Amun-Ra | you can have them iirc as a const seq |
12:46:26 | Amun-Ra | or const array |
12:46:29 | FromDiscord | <odexine> phil isnt really explaining it in enough detail |
12:46:48 | Amun-Ra | or generate each const string with compiletime func |
12:46:52 | Amun-Ra | true |
12:48:13 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
12:48:50 | Amun-Ra | we don't have access to playnim links on irc |
12:49:01 | FromDiscord | <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:09 | FromDiscord | <Phil> That's not a playnim link, I tend to just post the code directly |
12:49:23 | Amun-Ra | Phil | sent a code paste, see https://play.nim-lang.org/#ix=html> |
12:49:29 | Amun-Ra | that's how we see it |
12:49:31 | FromDiscord | <nnsee> what |
12:49:47 | FromDiscord | <nnsee> well that's broken |
12:49:49 | FromDiscord | <Phil> That makes no sense... wtf? |
12:50:02 | FromDiscord | <Phil> Wait, does the irc bridge just auto-share code to play.nim-lang? |
12:50:13 | FromDiscord | <nnsee> maybe it tries to |
12:50:19 | FromDiscord | <nnsee> clearly it isn't doing it very successfully |
12:50:23 | FromDiscord | <Phil> https://media.discordapp.net/attachments/371759389889003532/1184477418203922452/image.png?ex=658c1d8f&is=6579a88f&hm=3e54d4406611fa7f778cb7f065ef09de10809f1b60a10dc38121d7f4fc039aeb& |
12:50:28 | Amun-Ra | yes, it did with long messages |
12:50:40 | FromDiscord | <Phil> I mean the fact that ix is buring has been known for a while |
12:50:45 | FromDiscord | <nnsee> oh right |
12:50:48 | FromDiscord | <nnsee> ix is down |
12:50:57 | FromDiscord | <Phil> It's a question of can we even swap to another service, does it make sense to or not |
12:51:27 | PMunch | nnsee, how's the Nim paste solution going? :P |
12:51:55 | Amun-Ra | Phil: I use something like this: https://dpaste.com/AN3CRX62K |
12:52:00 | PMunch | And yeah, the bridge tries to do code as playground link pastes. It's not terribly great at it, but it's trying |
12:52:06 | FromDiscord | <nnsee> 😬 |
12:52:21 | FromDiscord | <nnsee> i started with it |
12:52:27 | FromDiscord | <nnsee> but got sidetracked with IRL stuff and work |
12:52:33 | FromDiscord | <nnsee> will try to finish it this week |
12:52:39 | PMunch | Nice |
12:52:54 | FromDiscord | <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:08 | FromDiscord | <Phil> So I don't get the luxury of defining things like that |
12:53:14 | * | rockcavera joined #nim |
12:53:16 | Amun-Ra | hmm |
12:55:39 | FromDiscord | <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:50 | FromDiscord | <Phil> Specifically: strings |
12:57:24 | FromDiscord | <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:50 | FromDiscord | <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:18 | FromDiscord | <graveflo> sent a code paste, see https://play.nim-lang.org/#ix=html> |
13:13:39 | FromDiscord | <Phil> Argh, pragmas go before typedef, yeah the "var" -variable declaration with compiletime pragma did it |
13:16:10 | FromDiscord | <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:02 | FromDiscord | <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:35 | FromDiscord | <Phil> Not even that, the syntax is fine, but I get the weirdest compiler errors |
13:19:19 | FromDiscord | <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:37 | PMunch | Hmm, is there a way to get the path to the currently compiling module in Nim? |
14:07:53 | FromDiscord | <_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:53 | FromDiscord | <nnsee> it's pretty easy, just hack into the administrator interface and confirm your account |
14:09:03 | FromDiscord | <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:05 | FromDiscord | <_goel_> (edit) "email?" => "email?↵Everything is greyed out, except for delete account" |
14:09:24 | FromDiscord | <nnsee> "security tools"? |
14:09:57 | FromDiscord | <zuhaibullahbaig> In reply to @nnsee ""security tools"?": oh like exploits and stuff. i am planning to learn cyber security in the future |
14:11:22 | FromDiscord | <nnsee> exploits for what? |
14:12:55 | FromDiscord | <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:38 | PMunch | _goel_, what is your account name? |
14:19:47 | PMunch | Right, so currentSourcePath is what I need. But how do I root a dotted path at this position? |
14:20:00 | FromDiscord | <jviega> thisDir() |
14:20:08 | PMunch | thisDir? |
14:20:21 | FromDiscord | <jviega> Works better when you end up getting moved around by nimble |
14:20:31 | FromDiscord | <Phil> Hmmmm |
14:20:34 | FromDiscord | <jviega> Don't remember the difference but I ended up at thisDir() and there was a reason |
14:20:49 | PMunch | Hmm, that's in the nimscript module though |
14:20:58 | FromDiscord | <jviega> Yes, which runs when you compile |
14:21:03 | FromDiscord | <jviega> So why not use it |
14:21:10 | PMunch | Fair enough |
14:21:24 | FromDiscord | <jviega> It def was the more accurate option |
14:21:36 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
14:21:40 | FromDiscord | <nnsee> In reply to @zuhaibullahbaig "oh like exploits and": i think i scared them off, they left |
14:22:06 | PMunch | Strange, the docs says that it just calls currentSourcePath, but doesn't resolve symlinks |
14:22:49 | PMunch | Phil, well it raises a warning with some tracing information |
14:22:56 | PMunch | Or am I missing something? |
14:23:19 | FromDiscord | <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:25 | FromDiscord | <Phil> So I assume it has to do with my proc |
14:23:29 | FromDiscord | <jviega> So my memory is this: |
14:24:09 | FromDiscord | <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:06 | FromDiscord | <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:38 | FromDiscord | <mratsim> In reply to @jviega "Works better when you": nimble is so annoying with this |
14:29:26 | FromDiscord | <jviega> Yes, it's like package management was left to a house full of cats |
14:38:29 | * | G3ngh1s_ joined #nim |
14:43:35 | PMunch | Hmm, thisDir seems to return an empty string for me |
14:44:04 | FromDiscord | <jviega> Weird, maybe you're somehow not running in the js runtime?? |
14:44:45 | PMunch | Well I'm definitely not running in the JS runtime :P |
14:44:51 | PMunch | But I assume you meant Nim runtime |
14:45:28 | FromDiscord | <jviega> Yes nimble, macros, etc. are all run at compile time using the JS backend, are they not? |
14:46:01 | PMunch | What? |
14:46:31 | FromDiscord | <jviega> They definitely seem to be in our world |
14:46:55 | PMunch | I'm confused.. |
14:47:15 | PMunch | Why would nimble, macros, etc. run in a JavaScript backend? |
14:47:29 | FromDiscord | <jviega> Because of the lack of FFI |
14:47:40 | PMunch | But JavaScript.. |
14:48:13 | FromDiscord | <jviega> Yeah, maybe not, I think I probably misunderstood at some point long ago |
14:48:24 | PMunch | They should be running in the Nim VM |
14:49:14 | FromDiscord | <jviega> Sorry for confusing you 🙂 |
14:49:28 | FromDiscord | <jviega> "Senior moment" |
14:54:48 | PMunch | No worries |
14:59:18 | FromDiscord | <piqueiras> best way of counting how many different elements are in a seq? |
14:59:28 | FromDiscord | <jviega> `.len()` |
14:59:35 | FromDiscord | <piqueiras> sorry, 2 seqs |
14:59:37 | FromDiscord | <piqueiras> like |
14:59:49 | FromDiscord | <piqueiras> @[true,true,false] and @[true,false,false] |
14:59:58 | FromDiscord | <piqueiras> theres one different element (considering order) |
15:00:16 | FromDiscord | <piqueiras> could do some custom func I guess |
15:00:57 | FromDiscord | <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:53 | FromDiscord | <piqueiras> I could zip them maybe? |
15:01:54 | FromDiscord | <mratsim> In reply to @piqueiras "best way of counting": a for loop with xor |
15:02:22 | FromDiscord | <jviega> Only if it's always boolean |
15:02:58 | FromDiscord | <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:34 | FromDiscord | <piqueiras> I mean it was just for a small thing no need for purity or performance |
15:03:43 | FromDiscord | <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:17 | FromDiscord | <nnsee> In reply to @piqueiras "best way of counting": `toHashSet(yourseq).card` |
15:05:31 | FromDiscord | <nnsee> not performant but easy to write and remember |
15:05:38 | FromDiscord | <jviega> That's not what he's looking for |
15:05:47 | FromDiscord | <jviega> He's looking to compare elements in two different arrays |
15:05:51 | FromDiscord | <jviega> by position |
15:05:53 | FromDiscord | <piqueiras> https://media.discordapp.net/attachments/371759389889003532/1184511516553256980/image.png?ex=658c3d50&is=6579c850&hm=887387ab69cf86c1bacbe895ba184929b4b35cde7eddbe60439fd7d1c659f40c& |
15:06:02 | FromDiscord | <piqueiras> hm |
15:06:03 | FromDiscord | <nnsee> ah, didn't read further, lol |
15:06:26 | FromDiscord | <nnsee> my bad |
15:08:17 | FromDiscord | <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:49 | FromDiscord | <piqueiras> yea |
16:01:58 | FromDiscord | <Phil> Hmmm... anyone here worked with the channels in threading/channels? |
16:02:04 | FromDiscord | <Phil> I'm not sure if I'm running into a bug here or not |
16:07:52 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
16:11:14 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
16:38:57 | * | disso-peach quit (Quit: Leaving) |
17:22:14 | FromDiscord | <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:49 | FromDiscord | <Clonkk> I use them to pass a ref around between threads. Not much else↵(@Phil) |
18:34:23 | FromDiscord | <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:43 | FromDiscord | <Phil> Because I'm seeing weird behaviour (documented in https://github.com/nim-lang/threading/issues/52) |
18:35:18 | FromDiscord | <Phil> I mean, doesn't even have to be a hundred thousand, I'm seeing weird behaviour with 200 |
18:39:25 | FromDiscord | <_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:07 | FromDiscord | <_goel_> (edit) "on" => "with" | "withthat ... email" added "old" |
18:48:48 | FromDiscord | <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:58 | FromDiscord | <Phil> Seems like we both had the same idea, I'm just doing it using channels, he using HTTP |
19:21:42 | FromDiscord | <alwaysoutofrange> sent a code paste, see https://play.nim-lang.org/#ix=html> |
19:25:37 | FromDiscord | <Phil> That... seems suspicious, could you provide a fuller minimal example? |
19:26:03 | FromDiscord | <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:31 | FromDiscord | <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:44 | FromDiscord | <Phil> ( @alwaysoutofrange ) |
19:28:12 | FromDiscord | <Phil> (edit) "C-code.↵That" => "C-code (because that's usually the way file-reading is done at runtime).↵That" |
19:28:22 | FromDiscord | <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:14 | FromDiscord | <alwaysoutofrange> correct but a question is it possible to get this error when you selected in `nimble init` hybrid as project type? |
19:30:44 | FromDiscord | <Phil> I... don't understand |
19:30:59 | FromDiscord | <Phil> Oh, when setting up the project |
19:31:23 | FromDiscord | <alwaysoutofrange> yes |
19:31:25 | FromDiscord | <Phil> Beats me tbh, it's not like that does all that much, |
19:32:18 | FromDiscord | <Phil> So that really is unlikely to be the problem.↵Basically show your code 😛 |
19:32:50 | FromDiscord | <Phil> Or rather the elements interacting with what you posted, because one of those is in a compile-time context |
19:34:00 | FromDiscord | <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:45 | FromDiscord | <Phil> What's screwing you is const replay = readReplayFile() |
19:35:01 | FromDiscord | <alwaysoutofrange> oh you right |
19:35:05 | FromDiscord | <alwaysoutofrange> its not knows at compile time |
19:35:07 | FromDiscord | <alwaysoutofrange> thats mate |
19:35:14 | FromDiscord | <Phil> `const` turns leads to everything on the right hand side to be run at compiletime |
19:35:19 | FromDiscord | <Phil> (edit) removed "turns" |
19:35:29 | FromDiscord | <Phil> (edit) "`const` leads to everything on the right hand side ... to" added "of the const-assignment" |
19:35:30 | FromDiscord | <alwaysoutofrange> (edit) "thats" => "thanks" |
19:35:48 | FromDiscord | <Phil> That means it'll try to run readReplayFile at compiletime, which isn't possible with the procs you're using |
19:35:59 | FromDiscord | <Phil> If you really want to read those in at compiletime you can use staticRead |
20:58:03 | FromDiscord | <Elegantbeef> It's a good day when I open my chat and do not see a notification from Phil 😄 |
20:58:52 | FromDiscord | <Phil> Lets change that!↵Beef, have you played around with threading/channels and what were your experiences 😛 |
20:59:16 | FromDiscord | <Elegantbeef> I have, my code worked |
20:59:39 | FromDiscord | <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:53 | FromDiscord | <nnsee> In reply to @Elegantbeef "I have, my code": my deepest fantasy |
21:00:09 | FromDiscord | <Elegantbeef> "clogged channels"? |
21:00:25 | FromDiscord | <Elegantbeef> How are you dequing messages? |
21:00:29 | FromDiscord | <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:43 | FromDiscord | <Elegantbeef> Send should not clog up |
21:02:21 | FromDiscord | <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:29 | FromDiscord | <Phil> or dropping messages if you're using trySend |
21:02:51 | FromDiscord | <Elegantbeef> I mean trysend drops intentionally |
21:03:00 | FromDiscord | <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:02 | FromDiscord | <Elegantbeef> The entire point is that if you cannot send you don't send |
21:03:22 | FromDiscord | <Phil> Yeah but I never have that capacity problem with system.Channels! xP |
21:03:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html> |
21:04:13 | FromDiscord | <Elegantbeef> I mean you're using trysend and complaining about dropped data |
21:05:00 | FromDiscord | <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:09 | FromDiscord | <Phil> More like I'm complaining about the stuck send |
21:05:19 | FromDiscord | <Phil> Which translates to dropped messages with trySend |
21:05:30 | FromDiscord | <Elegantbeef> If trysend is "stuck" there is a bug in the code |
21:05:32 | FromDiscord | <Phil> And is the result of channels-clogging |
21:05:57 | FromDiscord | <Elegantbeef> Give me an example that I can run instead of speaking in weird analogous talk 😄 |
21:06:53 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
21:07:20 | FromDiscord | <Phil> This is a cut-down version of me playing around with both versions of channels |
21:08:03 | FromDiscord | <Phil> Cut out the code for #test1 which was the bits setting up and playing with Channel instead of threading/channel |
21:20:30 | FromDiscord | <Elegantbeef> `threading/channels` is a fixed size queue |
21:20:59 | FromDiscord | <Elegantbeef> `newChan[T](100)` |
21:21:28 | FromDiscord | <Phil> That... would've been nice to see somewhere... Oh that's what the "elements" parameter means! |
21:21:37 | FromDiscord | <Elegantbeef> Yes |
21:22:09 | FromDiscord | <graveflo> elements must be where you put the elements right? |
21:22:11 | FromDiscord | <Elegantbeef> I intially thought it was just a preallocation, but nope it's fixed size |
21:22:22 | FromDiscord | <Elegantbeef> It has no growth logic |
21:23:13 | FromDiscord | <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:36 | FromDiscord | <Elegantbeef> Channels are just a thread safe queue |
21:24:06 | FromDiscord | <cy_tek> sent a code paste, see https://play.nim-lang.org/#ix=html> |
21:24:33 | FromDiscord | <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:06 | FromDiscord | <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:06 | FromDiscord | <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:11 | FromDiscord | <Phil> My arch nemesis |
21:26:21 | FromDiscord | <Elegantbeef> Or a change that makes them growable |
21:26:23 | FromDiscord | <Elegantbeef> Either one works 😄 |
21:26:23 | FromDiscord | <Phil> Because there's definitely a decent amount of info missing in these docs |
21:26:33 | FromDiscord | <Phil> I'm not fucking with actual implementation, Araq can do that |
21:26:46 | FromDiscord | <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:53 | FromDiscord | <Elegantbeef> Well an issue perhaps to see if they should be growable |
21:27:03 | FromDiscord | <nervecenter> (edit) "In reply to @cy_tek "Hi all 🙂 I'm": My guess is that the SDL ... libraries" added "and OpenGL" |
21:27:08 | FromDiscord | <Phil> I've made one, but didn't understand it was a grow-issue |
21:27:17 | FromDiscord | <Phil> The code I gave you stems from said issue |
21:27:55 | FromDiscord | <Elegantbeef> Sure but now you know the actual issue so can specify what the actual issue is 😄 |
21:28:08 | FromDiscord | <Phil> Yeh, already typing away |
21:28:13 | FromDiscord | <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:27 | FromDiscord | <Elegantbeef> Will say it's weird to test a graphic program in WSL |
21:30:41 | FromDiscord | <Elegantbeef> Like yes they work, but it's not really a representation of a real system |
21:30:50 | FromDiscord | <nnsee> try an actual vm |
21:30:54 | FromDiscord | <nnsee> super easy to set up |
21:30:56 | FromDiscord | <Elegantbeef> Not to say I do not use wine occasionally to test windows binaries |
21:31:08 | FromDiscord | <Elegantbeef> Just purge winblows it's even easier! |
21:31:28 | FromDiscord | <nnsee> it might just be wsl fuckery |
21:31:29 | FromDiscord | <Elegantbeef> Put linsux on your PC today! |
21:33:59 | FromDiscord | <Phil> https://github.com/nim-lang/threading/issues/52#issuecomment-1854731685 There you go, with honorable mention 😛 |
21:34:22 | FromDiscord | <Elegantbeef> I'm so popular my name is put twice |
21:34:31 | FromDiscord | <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:37 | FromDiscord | <Phil> Just means there's double demand for you |
21:34:55 | FromDiscord | <nnsee> In reply to @Elegantbeef "I'm so popular my": the first elegantbeef is just a description |
22:06:41 | FromDiscord | <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:50 | FromDiscord | <Phil> I shall proceed with patting myself on the back |
22:07:07 | FromDiscord | <Phil> (See recent #internals chat) |
23:04:44 | * | jmdaemon joined #nim |
23:12:20 | * | zgasma joined #nim |
23:32:12 | FromDiscord | <inv2004> Hi, Are there any easy way to extract object fields in macro? |
23:32:27 | FromDiscord | <inv2004> (edit) "Hi, Are there any easy way ... to" added "(not very complicate)" |
23:35:36 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:35:50 | FromDiscord | <Phil> Or do you mean in a proc inside a macro? |
23:36:08 | FromDiscord | <Phil> In which case no super easy way, you'll need to write yourself utilities |
23:37:00 | FromDiscord | <Phil> You could write yourself a "get node of kind" that recursively traverses an AST and fetches lists of a specific kind |
23:37:13 | FromDiscord | <Phil> Then fetch an nnkRecList node and that's your list of fields, you can iterate over that |
23:37:38 | FromDiscord | <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:09 | FromDiscord | <Phil> In that case, I can hand you a proc I wrote for myself, one sec |
23:38:12 | FromDiscord | <inv2004> maybe it is even a bit more complicate with object with kind case |
23:38:39 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:38:59 | FromDiscord | <Phil> ignore procBody as a param name, that should work for any nimnode |
23:39:14 | * | advesperacit quit () |
23:39:16 | FromDiscord | <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:23 | FromDiscord | <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:52 | FromDiscord | <Phil> In reply to @inv2004 "maybe it is even": Oh lord, you want to do stuff on an object variant? |
23:40:11 | FromDiscord | <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:20 | FromDiscord | <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:59 | FromDiscord | <inv2004> from non-macro it is not hard to generate it with fieldPairs, but I wanted to make it from macro |
23:41:00 | FromDiscord | <gogolxdong666> Is there any way to get the most inner json field like "input" |
23:41:49 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:42:03 | FromDiscord | <inv2004> oh, thx. let me check the code |
23:42:36 | FromDiscord | <Phil> Actually the expectKind proc I posted may be unnecessary, just ignore those nimnode checks or substitute with your own |
23:42:53 | FromDiscord | <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:21 | FromDiscord | <Phil> In reply to @gogolxdong666 "Is there any way": Define "inner most field" |
23:44:22 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:44:43 | FromDiscord | <Elegantbeef> @double_spiral in Nim `ref` means a Nim allocated resource that lives on the heap |
23:44:47 | FromDiscord | <Elegantbeef> so `addr T` returns `ptr` |
23:45:28 | FromDiscord | <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:31 | FromDiscord | <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:53 | FromDiscord | <Elegantbeef> Compile the code and look at the compiler output |
23:46:11 | FromDiscord | <gogolxdong666> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:46:16 | FromDiscord | <double_spiral> In reply to @Elegantbeef "Compile the code and": i still dont understand the errors tho |
23:46:18 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:46:25 | FromDiscord | <Elegantbeef> What does the compiler say? |
23:47:21 | FromDiscord | <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:50 | FromDiscord | <Elegantbeef> moreover the compiler stops at a single error so you do not have noise |
23:47:52 | FromDiscord | <Phil> That's why its better to look at compiler errors rather than nimsuggest messages |
23:48:15 | FromDiscord | <Elegantbeef> If you use `nim check --errorMax:10` you get in a similar boat of noise |
23:48:17 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:48:29 | FromDiscord | <gogolxdong666> the input field |
23:48:38 | FromDiscord | <Phil> There's like 2, you want both? |
23:48:47 | FromDiscord | <inv2004> @Phil is it `zero_functional` or sequtils? |
23:48:50 | FromDiscord | <graveflo> whats with the `ref ptr ...` anyway |
23:48:52 | FromDiscord | <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:16 | FromDiscord | <Elegantbeef> people assume `ref` is a pointer often |
23:49:18 | FromDiscord | <Phil> In reply to @inv2004 "<@180601887916163073> is it `zero_functional`": sequtils. I haven't used zerofunctional |
23:49:25 | FromDiscord | <gogolxdong666> sent a long message, see <!doctype html> |
23:49:33 | FromDiscord | <Phil> But if you can replace mapIt etc. with stuff from zerofunctional that should do it as well |
23:50:34 | FromDiscord | <Phil> In reply to @double_spiral "thx phil youre the": insert goat bleating |
23:50:56 | FromDiscord | <inv2004> @Phil I see flatten I cannot detect it from |
23:50:56 | FromDiscord | <Phil> In reply to @gogolxdong666 "def item_generator(json_input, lookup_key): ": So... both? |
23:51:02 | FromDiscord | <Phil> Let me check |
23:51:21 | FromDiscord | <Phil> Oh, wups |
23:51:28 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:51:32 | FromDiscord | <inv2004> thx! |
23:51:53 | FromDiscord | <Phil> That's how you see how well I remember my own code, my own utilities confuse me xD |
23:53:27 | FromDiscord | <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:46 | FromDiscord | <gogolxdong666> the deepth is unknown in advance |
23:54:52 | FromDiscord | <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:05 | FromDiscord | <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:12 | FromDiscord | <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:54 | FromDiscord | <Phil> One sec, are you solid with doing a recursion over a Json-tree like that? |
23:58:58 | FromDiscord | <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:10 | FromDiscord | <Phil> (edit) "heap.↵Then" => "heap you just allocated.↵Then" |
23:59:14 | FromDiscord | <Elegantbeef> "unreffing" |
23:59:27 | FromDiscord | <Elegantbeef> The colloquial term is "dereferencing" |
23:59:32 | FromDiscord | <Phil> too long |
23:59:39 | FromDiscord | <Elegantbeef> tldr |
23:59:45 | FromDiscord | <Phil> Be happy I'm not typing unrfing |
23:59:54 | FromDiscord | <Elegantbeef> unrfng |