<< 19-12-2023 >>

00:28:16*lucasta joined #nim
00:58:42FromDiscord<.bobbbob> how do I make nim c output the binary to a specific directory/name?
00:59:58FromDiscord<.bobbbob> nvmd found it, -o
01:00:22FromDiscord<griffith1deadly> as i recall you cannot set outdir and binary name at same time
01:01:33FromDiscord<.bobbbob> yeah looks like you need --output and -o
01:09:36FromDiscord<christofur> has anyone been able to compile x86_64 win binaries on a mac system with m2?
01:11:38FromDiscord<Elegantbeef> What compiler are you using?
01:11:52FromDiscord<Elegantbeef> For the easiest path you probably want to use zigcc
01:44:14FromDiscord<christofur> clang, but ill try that
01:44:20FromDiscord<christofur> clang: error: linker command failed with exit code 1 (use -v to see invocation)↵Error: execution of an external program failed: 'clang
01:44:28FromDiscord<christofur> i guess i gotta specify it explicitly when i instal
01:44:35FromDiscord<christofur> (edit) removed "when i instal"
01:46:46FromDiscord<Elegantbeef> Eh cross compilation is always fun
01:46:59FromDiscord<christofur> nim.cfg(197, 3) Error: unknown C compiler: 'zig'. Available options are: gcc, switch_gcc, llvm_gcc, clang, bcc, vcc, tcc, env, icl, icc, clang_cl
01:47:01FromDiscord<christofur> dont think i can use it
01:47:02FromDiscord<Elegantbeef> Zig's compilation work on top of clang/llvm is very nice
01:47:05FromDiscord<christofur> do i have to alias this or
01:47:11FromDiscord<Elegantbeef> https://github.com/enthus1ast/zigcc
01:47:15FromDiscord<Elegantbeef> You do technically need to alias it
01:48:02FromDiscord<Elegantbeef> It's not officially supported but it's a good CC path
01:53:39FromDiscord<christofur> `/bin/sh: zigcc: command not found` hmm
01:53:41FromDiscord<christofur> i aliased it
01:53:45FromDiscord<christofur> in .bashrc, even though i use zsh
01:56:12FromDiscord<christofur> sent a code paste, see https://paste.rs/ChQMo
01:59:47FromDiscord<Elegantbeef> Well it's going to `sh` so your alias must work for that shell
02:03:17*krux02 quit (Remote host closed the connection)
02:32:41FromDiscord<nasuray> The aforementioned zigcc nimble package is creating a shim around zig. So if you install that there is no aliasing... Is the compiler zig on your path?
02:42:35*lucasta quit (Quit: Leaving)
02:45:05FromDiscord<christofur> In reply to @Elegantbeef "Well it's going to": i did..
02:45:13FromDiscord<christofur> @nasuray yes.
02:45:21FromDiscord<christofur> can i just make it use zsh instead of sh
02:46:44FromDiscord<nasuray> Why does the shell matter at all?
02:47:08FromDiscord<christofur> i dont know.. considering i can run zigcc just fine in terminal
02:47:16FromDiscord<christofur> https://media.discordapp.net/attachments/371759389889003532/1186499964218646619/image.png?ex=65937933&is=65810433&hm=cddcfd479f053e2d34f5be5261732bc9c75395c77a6de47fbee709745ca1137c&
02:47:34FromDiscord<christofur> i dont really know whats going on here
02:48:20FromDiscord<christofur> like i said i aliased in bashrc.. so
02:48:29FromDiscord<christofur> and zshrc
02:48:35FromDiscord<nasuray> Aliased what exactly?
02:48:54FromDiscord<christofur> https://media.discordapp.net/attachments/371759389889003532/1186500377902841927/image.png?ex=65937996&is=65810496&hm=31286dbe36a2aff28bdb7945f79501104b38457e40e8bdcd3559f1400790a3fa&
02:48:57FromDiscord<christofur> i did this, not sure what else its expecting.
02:50:15FromDiscord<nasuray> Two other options then create an exe on your path for zigcc or just use the above nimble package
02:50:29FromDiscord<nasuray> https://github.com/enthus1ast/zigcc
02:50:42FromDiscord<christofur> i installed that package
02:50:47FromDiscord<christofur> https://stackoverflow.com/questions/73345643/how-to-use-the-zig-compiler-in-order-to-compile-nim-code
02:50:49FromDiscord<christofur> they link to this
02:50:57FromDiscord<christofur> i dont really see the difference between this and aliasing but ill try
02:51:23FromDiscord<nasuray> The subprocess needs to have sourced the right rc files
02:51:42FromDiscord<nasuray> Assuming /bin/sh is even bash or zsh to begin with
02:53:27FromDiscord<Elegantbeef> no `sh` should be `sh`
02:54:27FromDiscord<christofur> ya im googling to find out what i edit for that
02:55:23FromDiscord<nasuray> @Phil didn't use an alias for that stackoverflow answer either
02:55:57FromDiscord<christofur> yes im seeing that
02:56:30FromDiscord<nasuray> I do the same thing as `zigcc` for my `zig` wrapper https://github.com/daylinmorgan/forge
03:00:10FromDiscord<christofur> eh, ill just stick to windows i guess
03:00:17FromDiscord<christofur> really would rather develop on my air but this is too much
03:00:36FromDiscord<Elegantbeef> I mean you're using `.bashrc` to register aliases
03:00:50FromDiscord<Elegantbeef> That's explicitly for `bash` and only used by a few other shells
03:00:58FromDiscord<Elegantbeef> I think `.profile` is loaded first
03:01:01FromDiscord<Elegantbeef> I do not recall though
03:01:09FromDiscord<christofur> MachO Flush... error(link): unsupported cpu architecture 0x0↵error: UnsupportedCpuArchitecture↵Error: execution of an external program failed: 'zigcc -o
03:01:14FromDiscord<christofur> oh im passed that now
03:01:24FromDiscord<Elegantbeef> `--cpu:amd64`?
03:01:42FromDiscord<Elegantbeef> Or does zig no support amd64 from arm
03:01:44FromDiscord<Elegantbeef> ..... hmmmm
03:02:10FromDiscord<christofur> tried to prefix it with arch -x86_64
03:02:12FromDiscord<christofur> which should run rosetta
03:02:48FromDiscord<christofur> In reply to @Elegantbeef "`--cpu:amd64`?": tried with that, same message
03:03:43FromDiscord<Elegantbeef> Zig might not do arm -\> amd64... I assume it does but idk
03:05:18FromDiscord<nasuray> https://ziglang.org/download/0.11.0/release-notes.html#Support-Table
03:07:27FromDiscord<nasuray> I can't recall if `zig targets` just includes everything LLVM supports or if it filters based on the running compiler
03:09:45FromDiscord<nasuray> with `forge` I do my best to match the triples to the appropriate `cpu` and `os` on `nim`. But there are plenty of things that don't cross-compile easily because of missing shared libraries
03:17:26*edr quit (Quit: Leaving)
03:58:42*derpydoo quit (Ping timeout: 252 seconds)
04:03:43*dtomato quit (Ping timeout: 246 seconds)
04:16:23*dtomato joined #nim
04:51:46FromDiscord<.bobbbob> sent a code paste, see https://paste.rs/oElrQ
05:05:51ormiretthings after a ? aren't part of the path, they're "query parameters" Can grab them from Context: https://planety.github.io/prologue/context/#getqueryparamsoption
05:09:48FromDiscord<albassort> i've returned i suppose
05:09:59FromDiscord<albassort> hey guys whats the best flow path control mechanisms
05:10:04FromDiscord<albassort> (edit) "hey guys whats the best flow path control mechanisms ... " added "in your opinions"
05:10:14FromDiscord<albassort> im rewriting old shitty cold, its one giant uncomprehensible loop
05:10:42FromDiscord<albassort> https://gitlab.com/CAlbassort/universalime/-/blob/main/src/libs/nim/keyboardWriter.nim?ref_type=heads
05:10:48FromDiscord<albassort> im thinking about putting it into blocks
05:11:18FromDiscord<albassort> a nim goto statement would be helpful here too
05:14:21NimEventerNew thread by khaledh-nim: Ref types and the align pragma, see https://forum.nim-lang.org/t/10783
05:18:55FromDiscord<albassort> https://github.com/sls1005/nim-goto
05:19:02FromDiscord<albassort> is this a good idea?
05:19:03FromDiscord<albassort> maybe not
05:23:18FromDiscord<m4ul3r> I've used it before, but it's not really the best way to handle it.↵It works as a goto
05:23:25FromDiscord<albassort> i trust Araq over myself and am goign to just structure it
05:23:35FromDiscord<albassort> (edit) "goign" => "going"
05:23:52FromDiscord<albassort> In reply to @m4ul3r "I've used it before,": yeah but read the code i posted, it is basically the only situation where a goto make sense
05:24:01FromDiscord<albassort> many paths that lead to other paths that accsess the same memory
05:28:56FromDiscord<Elegantbeef> Nim actually has goto built in
05:29:16FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/8963#58594
05:29:28FromDiscord<albassort> I've heard rumblings of goto in nim but its not fresh in my memory
05:30:59FromDiscord<albassort> In reply to @Elegantbeef "Nim actually has goto": that seeems a little jank of syntax and maybe should have its own keyword but yeah that seems good
05:31:18FromDiscord<Elegantbeef> Good thing goto is jank
05:31:41FromDiscord<albassort> you think if you could be like ↵goto state:↵ of a ...↵it would be over used
05:31:49FromDiscord<albassort> (edit) "over used" => "overused"
05:31:52FromDiscord<albassort> its obscurity is a power
05:31:57FromDiscord<Elegantbeef> I mean you can make a macro over it
05:32:05FromDiscord<albassort> yeah but you know what i mean
05:32:11FromDiscord<Elegantbeef> No I do not
05:32:19FromDiscord<albassort> i mean, less jank in the stdlib
05:32:23FromDiscord<albassort> you can make a macro for anything
05:32:34FromDiscord<Elegantbeef> I mean who really needs goto
05:32:36FromDiscord<Elegantbeef> 2 people and a dog
05:32:54FromDiscord<albassort> beef, i would like your experienced as a slightyly older but more experienced and smarter person
05:33:02FromDiscord<odexine> In reply to @Elegantbeef "2 people and a": Beef since when did you need go to
05:33:03FromDiscord<albassort> In reply to @albassort "https://gitlab.com/CAlbassort/universalime/-/blob/m": would this benefit from goto
05:33:27FromDiscord<albassort> though the code may be too incomprhenensible for you to make a judgement
05:33:31FromDiscord<Elegantbeef> Are you micro optimising call overheads
05:33:39FromDiscord<albassort> no
05:33:48FromDiscord<albassort> well
05:33:49FromDiscord<albassort> i want to
05:34:00FromDiscord<albassort> i want to make the control flow easier to visualize
05:34:02FromDiscord<odexine> In reply to @albassort "would this benefit from": Where do you think it needs go to?
05:34:15FromDiscord<Elegantbeef> https://gitlab.com/CAlbassort/universalime/-/blob/main/src/libs/nim/keyboardWriter.nim?ref_type=heads#L89-110 goto is the least of your concerns
05:34:29FromDiscord<Elegantbeef> This procedure has 20 local variables
05:34:35FromDiscord<albassort> this is messed up
05:34:50FromDiscord<odexine> I cannot read that on mobile lol
05:35:14FromDiscord<albassort> In reply to @Elegantbeef "This procedure has 20": how else do you import user configurable settings
05:35:15FromDiscord<Elegantbeef> If you used procedures instead of nested logic you would not think goto is a good idea
05:35:34FromDiscord<Elegantbeef> Using procs and passing the state along
05:35:45FromDiscord<albassort> that was the other option
05:35:52FromDiscord<albassort> make a state then parse the state on yield
05:35:59FromDiscord<Elegantbeef> your biggest problem here is you're doing 3000 things in a single proc
05:36:17FromDiscord<Elegantbeef> Separate your logic out into procedures, and suddenly you will live a better life
05:36:29FromDiscord<albassort> i think i was burnt out when i wrote this
05:36:37FromDiscord<albassort> sent a code paste, see https://paste.rs/5VDsL
05:37:23FromDiscord<albassort> https://gitlab.com/CAlbassort/universalime/-/blob/main/src/libs/nim/ime.nim?ref_type=heads
05:37:29FromDiscord<albassort> look at the implementation of this
05:38:19FromDiscord<albassort> i have to rewrite that entire thing because idk what the fuck i was thiniing
05:38:21FromDiscord<albassort> (edit) "thiniing" => "thiniking"
05:38:25FromDiscord<albassort> (edit) "thiniking" => "thinkinf"
05:38:29FromDiscord<Elegantbeef> Yea rewrite it then comeback
05:38:29FromDiscord<albassort> (edit) "thinkinf" => "thinking"
05:38:53FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/jdgGB
05:38:57FromDiscord<albassort> i wrote it as a closure itertor with manual memory managment
05:39:01FromDiscord<albassort> for... some reason
05:39:27FromDiscord<albassort> beef this is why im secrative about my code
05:39:35FromDiscord<albassort> (edit) "beef this is why im secrative about my code ... " added "when im writing it"
05:39:42FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/om8QN
05:40:02FromDiscord<Elegantbeef> Cause people give helpful insight 😄
05:43:14FromDiscord<Elegantbeef> https://gitlab.com/CAlbassort/universalime/-/blob/main/src/libs/nim/ime.nim?ref_type=heads#L41-49 I do have to say this is interesting, a generic iterator that only works on `seq[string]`
05:44:21FromDiscord<albassort> i dont remember being on drugs
05:44:25FromDiscord<albassort> (edit) "i dont remember being on drugs ... " added "while i wrote this"
05:44:31FromDiscord<albassort> maybe i was stressed
05:44:58FromDiscord<albassort> from all of the x11 learning
05:45:35FromDiscord<Elegantbeef> Learning X11 has killed people I'm sure of it
05:45:46FromDiscord<Elegantbeef> At least it broke me writing a window manager
05:46:20FromDiscord<albassort> its well documented but it doesn't help
05:46:26FromDiscord<albassort> (edit) removed ""
05:46:43FromDiscord<albassort> mostly because its documentation is split in 3 different places
05:46:43FromDiscord<Elegantbeef> You obviously have not tried to write a window manager
05:47:03FromDiscord<albassort> well, the functions are there beef
05:47:12FromDiscord<Elegantbeef> They are there
05:47:17FromDiscord<albassort> in the docs
05:47:27FromDiscord<albassort> the struts have no explanation and are named randomly
05:47:28FromDiscord<Elegantbeef> But the correct way of doing things and making things work is certainly not
05:47:32FromDiscord<albassort> and are sometimes the same as other struts
05:47:48FromDiscord<albassort> and the order is just "fuck it figure it out"
05:48:04FromDiscord<albassort> and every time you fuck it up your computer breaks and you gotta kill the process
05:48:24FromDiscord<Elegantbeef> Nah I used Xephyr to test with
05:48:28FromDiscord<Elegantbeef> So it did not require a restart
05:51:32FromDiscord<albassort> i have no interest in interacting with X11 again
05:51:42FromDiscord<albassort> i imagine wayland is somehow worse
05:51:55FromDiscord<Elegantbeef> Wayland can be nicer but yea it's also a whole thing
05:52:05FromDiscord<Elegantbeef> I do wonder if futhark can wrap wayland/wlroots now
05:52:20FromDiscord<albassort> futhark the language or futhark the nim thing
05:52:39FromDiscord<albassort> or the other nim thing
05:53:50FromDiscord<albassort> i think combining goto and state management would make the most sense
05:54:18FromDiscord<albassort> because then it isn't relooping and then checking the state, you can clearly see the branch it is now going down
05:54:30FromDiscord<albassort> (edit) "down" => "down, and it can loop through paths freely"
05:54:40FromDiscord<Elegantbeef> The Nim C wrapper
05:55:00FromDiscord<Elegantbeef> Meh the goto isnot that important
05:55:37FromDiscord<Elegantbeef> No point writing with a goto and making the code impossible to follow if the performance is not benefited significantly
05:57:04FromDiscord<albassort> in which situations is goto faster than thigns
05:57:07FromDiscord<albassort> (edit) "thigns" => "things"
05:57:20FromDiscord<Elegantbeef> When you're aimlessly micro optimising
05:57:43FromDiscord<ichigo> `goto ohgodhowdidwegethere`
05:58:08FromDiscord<albassort> some dude said "yo what if i plant these hard things in the ground then come back next year"
05:58:17FromDiscord<albassort> (edit) "plant" => "put"
05:58:44FromDiscord<ichigo> chocolate coins unfortunately do not sprout into chocolate bushes
06:02:02FromDiscord<Elegantbeef> I think that's a myth
06:14:47FromDiscord<ichigo> reject `goto`, use `comefrom`
06:24:04FromDiscord<JJ> oh god that reminds me i should fix my wayland wrappers
06:24:07FromDiscord<JJ> or formally abandon them
06:24:59FromDiscord<JJ> they're long outdated with the advent of futhark...
06:25:19FromDiscord<Elegantbeef> Well futhark had issues with wlroots/wayland iirc
06:32:26FromDiscord<JJ> really, interesting
06:32:37FromDiscord<JJ> hm. anything specific? or was it a style insensitivity issue
06:32:54FromDiscord<Elegantbeef> It was nested anonymous unions iirc
06:33:20FromDiscord<JJ> blugh
06:34:17FromDiscord<Elegantbeef> It might be fixed by now, I do not recall if I made an issue
06:34:26FromDiscord<Elegantbeef> I should've but I'm also a dweeb sometimes
06:36:33FromDiscord<ca_lobo_14153> In reply to @rakgew "<@1164001202451775498> you could get": That is probably the better way of doing things... thanks for pointing it out.
06:59:42*Qaziquza joined #nim
07:01:58*Qaziquza quit (Client Quit)
07:04:57FromDiscord<albassort> Did futhark git gud with 2.0 integration or something
07:05:18FromDiscord<albassort> I cint and uncheckedarray old fashioned
07:05:24FromDiscord<albassort> (edit) "I" => "Are"
07:05:25FromDiscord<Elegantbeef> Nope
07:05:37FromDiscord<albassort> (edit) "uncheckedarray" => "uncheckedarray[ptr int]"
07:05:57FromDiscord<albassort> Then why are we abandoning hand written bindings?
07:06:09FromDiscord<Elegantbeef> Cause large libraries are a pain to wrap?
07:06:21FromDiscord<albassort> (edit) "int]" => "cint]"
07:06:33FromDiscord<albassort> Can you just import things with futhark now?
07:06:44FromDiscord<Elegantbeef> You always could
07:06:53FromDiscord<albassort> I mean and have type checking and the like
07:07:03FromDiscord<Elegantbeef> You always did
07:07:17FromDiscord<albassort> There's something it was missing that I didn't like
07:07:24FromDiscord<albassort> I forget what
07:07:33FromDiscord<Elegantbeef> That it used `ptr T` instead of `ptr Unchecked[T]`?
07:07:45FromDiscord<Elegantbeef> That it generated an unreadable file?
07:07:56FromDiscord<albassort> Probably the latter
07:16:13*advesperacit joined #nim
07:21:23*jmdaemon joined #nim
07:24:16FromDiscord<sOkam! 🫐> Add the "wrapping big libraries" that was already mentioned to the mix, and you probably get the picture
07:25:30FromDiscord<sOkam! 🫐> sent a long message, see https://paste.rs/jLEyB
07:31:55FromDiscord<sOkam! 🫐> sent a long message, see https://paste.rs/eEbiX
07:38:50FromDiscord<Phil> In reply to @christofur "": Afaik aliases just get substituted, so in the end what your CLI command for the compiler gets is 2 words, zig and cc. ↵That is not what you want. What you want is a single command for the compiler to execute. That's why you need either a bash script or enthus1ast's package
07:39:42FromDiscord<Phil> (edit) "single" => "single-word"
07:45:37*PMunch joined #nim
07:47:39FromDiscord<Phil> In reply to @albassort "Probably the latter": Btw. nice to see you again!
07:52:21FromDiscord<pmunch> In reply to @albassort "Probably the latter": It has some switches now that can make the output more readable, with the drawbacks that motivated that design decision in the first place
07:53:31FromDiscord<pmunch> I'm also working on a "project mode" which tries to wrap an entire project into separate files and such. But it's giving me a bit of a hard time.. C imports and declarations are just a bit too foreign for Nim
07:56:19FromDiscord<pmunch> In reply to @heysokam "There is always the": Well I was fed up with the existing tools that didn't work, and which tried to work this way. So when I designed Futhark I tried to do things better. Not quite sure what that script would do, but with a combination of `-d:nodeclguards` and `outputPath` I think you get pretty readable and Git friendly output.
07:57:28FromDiscord<Elegantbeef> Do you carry comments over to the bindings?
07:57:40FromDiscord<pmunch> My main goal was to have something which actually worked without manually having to edit the code after wrapping. Putting things in a file to be checked into a repository promotes editing the code post-wrap.
07:57:59FromDiscord<pmunch> Unfortunately not, I'm not sure libclang exposes comments
07:58:17FromDiscord<Elegantbeef> Though it also promotes distributing Nim libraries that do not require libclang/futhark 😄
07:58:50FromDiscord<Elegantbeef> Ideally you can pin a package to a library version and not have to depend on futhark/libclang
07:59:04FromDiscord<Elegantbeef> Those of course can be a bit of a pain to get working due to distros being silly
08:00:33FromDiscord<pmunch> Sure, which is why I ended up adding the outputPath flag to Futhark and the section on how to create a hybrid of Futhark and non-Futharked wrappers
08:02:44FromDiscord<pmunch> My MAPM bindings for example, they ship the Futharked file and to use Futhark you have to throw a switch
08:03:03FromDiscord<pmunch> I see now though that it does depend on Futhark, guess I should remove that.
08:09:45FromDiscord<Elegantbeef> Oh hey it seems futhark does indeed work on wlroots now
08:10:49FromDiscord<pmunch> Nice
08:10:57FromDiscord<pmunch> It seems to work on most things by now
08:11:18FromDiscord<Elegantbeef> Let me bring back wasmer 😛
08:11:34PMunchJust not embedded stuff, but that's mainly Nim's poor handling of target and host OS..
08:11:47PMunchWasmer doesn't work?
08:12:43FromDiscord<Elegantbeef> Remember it has that `#define own` that is used for annotations that libclang just eats
08:12:53FromDiscord<Elegantbeef> So it defines the procedures incorrectly as `varargs`
08:13:04PMunchOh right, I think I fixed that
08:13:29PMunchIsn't that this thing? https://github.com/PMunch/futhark#pre-ansi-c-function-declarations
08:14:11FromDiscord<Elegantbeef> No it was just a define that marked when a procedure owned resources
08:14:27PMunchThere is no issue in the issue tracker for this, so I have no minimal code repro to test on :(
08:14:32FromDiscord<Elegantbeef> so it was like `own int name()`
08:14:35FromDiscord<Elegantbeef> There was one
08:14:53PMunchHmm, I tried to search for wasmer but it found nothing
08:14:56FromDiscord<Elegantbeef> https://github.com/PMunch/futhark/issues/44
08:15:06FromDiscord<Elegantbeef> You fixed it
08:16:01PMunchAh right, yes it's the same thing as what I linked
08:16:05PMunchOr same root cause
08:17:50PMunchIf it errors out on anything else now just let me know :)
08:21:37FromDiscord<requiresupport> have a widestring created with `newWideCString` would like to compare the chars with another string also created with `newWideCString` but getting error that there is no proc in std that can compare `Utf16Char` with another `Utf16Char`. Help please
08:22:28FromDiscord<Elegantbeef> There are no `[]` or `==` procs
08:23:28FromDiscord<Elegantbeef> You need to define your own `==` for `WideCstring` that compares pointers then walks the string to see if they're the same
08:24:12PMunchOdd thing to leave out if we have newWideCString..
08:24:37FromDiscord<Elegantbeef> They're just glorified windows Cstrings 😄
08:25:09FromDiscord<requiresupport> i hate working with windows 😞
08:51:17PMunchHmm, I need to pass argc/argv on to a C library
08:51:56PMunchIs there a way to get these in Nim or do I have to re-create them manually from the command line options?
08:52:14PMunchI guess I could set up my own main and call NimMain from there..
08:55:44FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-2-0/lib/std/cmdline.nim#L263C1-L265C49 might help
08:56:02FromDiscord<Elegantbeef> Sadly there is no way of getting the raw values that I know of
08:56:29PMunchHmm, that's a shame..
08:56:42FromDiscord<Elegantbeef> Well you can use those for linux atleast 😄
08:57:47PMunchWhich is all that really matters :)
08:59:57PMunchHmm, we don't have strdup anywhere do we?
09:02:37FromDiscord<Elegantbeef> Depends on whether you need to pass it across to C or Nim
09:03:00FromDiscord<Elegantbeef> `$` works as a str dup but is managed by Nim so sharing it is unwise
09:04:01PMunchYeah I need it for interop
09:04:50FromDiscord<Elegantbeef> The only reference to `strdup` in the Nim git repo is inside of linenoise.c 😄
09:05:22FromDiscord<Elegantbeef> so `proc copy(_: cstring): cstring {.importc:"strdup", cdecl.}` your welcome
09:05:58PMunchI just did `proc strdup(x: cstring): cstring {.importc.}`
09:06:13FromDiscord<Elegantbeef> Lame
09:06:50PMunchGah, for some reason Microsoft Tasks just randomly opens up a blank new browser window from time to time when I have it open in the background of my browser
09:06:58FromDiscord<Elegantbeef> I've heavily embraced using `_` myself for when parameter names do not matter
09:07:14PMunchYeah I think I'll nick that idea
09:07:17FromDiscord<Elegantbeef> Such a lovely way of doing it `type X = proc(_: int, _: string): float` is pretty good
09:10:57PMunchWell this is a bit annoying, Nim doesn't auto-convert a `ptr array[N, X]` to `ptr UncheckedArray[X]`
09:11:45FromDiscord<Elegantbeef> Of course not that's loss of information!
09:20:58PMunchNeat! I managed to port the hello_world of FUSE to Nim :)
09:21:14PMunchSo now I have a Nim program which can control a filesystem
09:22:21FromDiscord<ichigo> .. . . . . . .Use a macro to represent the AST of your program as an actual directory tree you can browse and edit while nim is compiling.
09:22:49FromDiscord<Phil> The placement of the dots in that sentence is disturbing the force
09:23:08FromDiscord<ichigo> (edit) ".Use" => "Use"
09:23:13FromDiscord<ichigo> there; fixed
09:24:22PMunchHaha, my idea is actually to map the MQTT devices in my smart-home to a filesystem. So that to turn off the lights I can simply do `echo off > house/living-room/lights`
09:24:45FromDiscord<ichigo> In ~~UNIX~~House, everything is a file.
09:24:46PMunchThat write operation would then get turned into a MQTT message to turn of the lights
09:25:38PMunchTurn off even
09:27:09PMunchBut am considering to write an article on this, in which case I was thinking of creating a JSON "editor" by mounting a JSON object to a path, then allowing edits, and when unmounted it would write out the result
09:33:05FromDiscord<Chronos [She/Her]> In reply to @PMunch "Haha, my idea is": Huh, that sounds fun actually
09:34:26FromDiscord<sOkam! 🫐> In reply to @pmunch "Well I was fed": I didn't know about `outputPath`. That might be what I was searching for but couldn't find 👌
09:39:20PMunchIf anyone else wants to play around with this: https://github.com/PMunch/libfuse-nim
09:41:17FromDiscord<Phil> Actually PMunch, how much multithreading have you done?↵Ever tried running some code in a separate thread that eventually finishes and when it does so sends back a message via Channel, without forcing you to call joinThread?
09:41:38PMunchI've done a fair bit
09:41:52PMunchThat should work fine
09:42:03FromDiscord<Phil> Never got it to work myself, always blew up
09:42:10PMunchThen just wait for a message in the channel instead of using joinThread
09:42:10FromDiscord<Phil> No jointhread meant segfaults for me
09:42:24PMunchHmm, that doesn't sound right
09:42:34FromDiscord<Phil> I explained badly:↵I was in an eventloop and the joinThread was outside of it
09:42:48FromDiscord<Phil> My mainthread was guaranteed to outlive that shorter task-thread
09:43:03FromDiscord<Phil> And in the loop regularly checking for new messages
09:46:58PMunchSomething like this right? https://paste.rs/2OntL.txt
09:47:04PMunchSeems to work fine for me
09:49:13FromDiscord<Phil> Hmmm that gives me a baseline to work off of
09:49:19FromDiscord<Phil> That didn't quite work for me when I tried
09:49:28FromDiscord<Phil> But I also was creating the thread from a proc and so on
09:53:35FromDiscord<Phil> In reply to @PMunch "Something like this right?": Yep, me creating the thread in a proc was the mistake
09:55:48FromDiscord<Phil> Thanks!
09:56:42FromDiscord<Phil> sent a code paste, see https://paste.rs/Smecd
10:07:52PMunchYeah that's just illegal creation of threads
10:10:33FromDiscord<Phil> Can't be illegal, the compiler never stopped me!
10:10:40FromDiscord<Phil> 😄
10:12:15PMunchHaha, usually the Nim compiler is good about this sort of thing
10:13:05PMunchChronos_[She/Her], did a simple test with the JSON thing now, just does a single level of the object, and only shows the string contents of each key as a separate file, but it already works great :)
10:13:49FromDiscord<Elegantbeef> Eh `Thread[T]` does not seem to make any sense
10:14:21PMunchWDYM?
10:14:34FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/10772#71871
10:15:01PMunchHuh?
10:15:27FromDiscord<Phil> Maybe referring to me using generic procs to instantiate threads via createThread?
10:15:38FromDiscord<Phil> (edit) "createThread?" => "createThread and result?"
10:20:36FromDiscord<Elegantbeef> You would imagine you could use `Thread[T]` as a local variable, but seemingly that is 'wrong'
10:21:59FromDiscord<Elegantbeef> Unless I misunderstand araq's message they seem weird
10:22:36PMunchYeah you apparently can't use them as local variables
10:23:25FromDiscord<Clonkk> If I understood the implementation correctly, it's just that Thread[T] should not be treated as a "value". Under the hood, it's a pthread pointer
10:24:19FromDiscord<Elegantbeef> Well `=copy` is disabled so I do not know what implications what you're saying has
10:27:35FromDiscord<Elegantbeef> Like in Phil's example that segfaults there is no obvious reason to me for it to segfault
10:28:55FromDiscord<Phil> I mean, I'll just eat it and refactor my code to not instantiate threads from procs and require the user pass me in a thread-variable
10:29:22FromDiscord<Elegantbeef> Sure you have to do that, but I'm saying there is no sensible reason that I can see for needing to do that
10:29:24FromDiscord<Phil> It appears to be intended design based on Araqs statements so I assume that's a feature not a bug to kick you towards his intended design for using threads
10:30:03FromDiscord<Phil> That or it's in the nature of the beast somehow. I dunno, I'm already writing code at lower levels than I ever have before
10:30:44FromDiscord<Clonkk> I think it just means thread object should live on heap, no ?
10:31:07FromDiscord<Elegantbeef> He says "global"
10:31:22FromDiscord<Elegantbeef> Global to me means static memory accessible by all
10:31:41FromDiscord<pmunch> Bit weird that they can't be local if they're just a pthread pointer
10:32:02FromDiscord<Elegantbeef> Yea, but I need to sleep instead of worry about this wacky world 😄
10:32:08FromDiscord<pmunch> What are they on windows?
11:20:09FromDiscord<Chronos [She/Her]> @odexine reminds me of when someone suggested allowing for passing the allocator explicitly as an argument for stdlib functions lol
11:20:23FromDiscord<odexine> that's what zig does, yes
11:25:26FromDiscord<Chronos [She/Her]> Yeah, thought it was a coincidence that you mentioned this
11:27:09FromDiscord<odexine> i replied to a message, did you read what i replied to?
11:29:40FromDiscord<Chronos [She/Her]> Yeah I did
11:30:02FromDiscord<Chronos [She/Her]> Just funny that it was mentioned
11:30:24FromDiscord<Chronos [She/Her]> Though, ig considering it was about allocators in general, I'm just being a bit silly
12:05:04*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
12:06:05FromDiscord<requiresupport> is there a nim version of https://en.cppreference.com/w/c/string/wide/wcslen ? any pros can give me a quick implementation in nim?
12:07:30PMunchI mean you could just do `proc wcslen(_: cstring): csizet {.importc, header: "wchar.h".}`
12:08:08FromDiscord<requiresupport> that's what I have right now.. but im OCD and i've been trying to implement in nim and failed multiple times :/
12:12:03PMunchWhy would you want to implement it in Nim when you have a perfectly good version in C available for use?
12:13:18FromDiscord<requiresupport> just curious how to do, no real reason why
12:13:24FromDiscord<requiresupport> (edit) "do," => "do it,"
12:13:35PMunchAh, well wide strings are just UTF-16 I believe
12:13:44PMunchSo you'd need to implement that
12:14:00PMunchNot terribly hard, just tedious
12:14:09FromDiscord<requiresupport> I see
12:15:09PMunchBasically `var x = 0; while x < data.len: x += data[x].byteLen`
12:15:36PMunchWhere `byteLen` is a procedure that checks how many UTF bytes this character uses
12:17:36FromDiscord<requiresupport> Thanks ill give it another try
13:28:12PMunchHaha, got the JSON as file-system thing working
13:28:39PMunchActually pretty neat, instead of using jq you can now use find/grep/etc. to navigate JSON
13:28:54PMunchCurrently only read-only though
13:29:01PMunchMaking it RW would be really cool
13:30:04FromDiscord<nnsee> that _does_ sound pretty neat, actually
13:30:14FromDiscord<nnsee> but how do you handle types?
13:30:38FromDiscord<nnsee> say I do `echo 1000 > randomKey`, is that saved as a string or an int
13:30:41PMunchWell, at the moment since it's read-only I just turn everything into strings
13:30:59PMunchObjects are turned into directories with each key being a file or directory
13:31:22PMunchArrays also turns into directories with files/subdirectiories just named 0,1,2,etc.
13:31:58PMunchAnd everything which is not an object or an array just gets turned into a file with the contents as a string
13:32:07FromDiscord<nnsee> so in that case how would i create a new, say, array? `mkdir` is ambiguous since it can mean either an empty object or an empty array
13:32:17FromDiscord<nnsee> I know you haven't gotten around to implementing that lol, just wondering the hypotheticals
13:32:27PMunchMy idea was to basically treat write operations with a large tryParse thing
13:32:33PMunchFalling back to just a string
13:32:37*ehmry joined #nim
13:33:06PMunchWell mkdir by itself would probably create a key with a `null` value
13:33:44PMunchAnd then if a folder only contains a contiguous list of numbered files starting at 0 it would become an array, otherwise it would become an object
13:35:06PMunchOf course handling the case of doing `echo "hello" > something/hello` where the `something` folder is currently a contiguous list of numbered files would either have to convert to an object, or simply throw an error
13:36:10FromDiscord<nnsee> In reply to @PMunch "My idea was to": what about if I want to write a string `"0"`?
13:36:40PMunchThen you're shit out of luck :P
13:37:02PMunchI guess strings could require `""` around them
13:37:21PMunchAnd then just throw an error if you try to write something which isn't a valid thing into a file
13:37:46PMunchThat would probably be the "better" way of doing it
13:37:57FromDiscord<nnsee> so the flow would turn into `echo '"my string"' > key`
13:38:08FromDiscord<nnsee> which is... manageable, but not ideal
13:38:12PMunchYeah if you want to write a string
13:38:43PMunchOf course it could just be required on things which could otherwise be parsed as something else
13:39:03FromDiscord<nnsee> and writing vars would be `echo "\"$myvar\"" > key`, oof
13:39:22PMunchHmm, yeah
13:40:05PMunchI guess the "otherwise be parsed as something else" rule would be better
13:40:15FromDiscord<nnsee> yeah, sounds good to me
13:40:45PMunchSo `echo "hello world" > key` would work fine, but you would need `echo '"0"' > key` to write a string with the content 0 to a key
13:41:11PMunchWould of course mean that for variables you would want to add those escapes anyways, to be safe
13:41:17FromDiscord<nnsee> also that `echo '"hello world"' > key` would still write just `hello world`
13:41:18FromDiscord<nnsee> yearp
13:41:45PMunchThis was really just meant to be a silly experiment though :P
13:51:59*derpydoo joined #nim
14:18:30*edr joined #nim
14:20:48FromDiscord<nnsee> bouncycastle
14:20:53FromDiscord<nnsee> bouncycastle
14:21:04PMunchnnsee, you okay there?
14:21:06FromDiscord<nnsee> whoops, i was wondering why search wasn't working
14:21:16PMunchHaha :P
14:27:48FromDiscord<jviega> @pmunch you can get the true argv and argc
14:28:11FromDiscord<jviega> Just add a constructor, it gets passed them by the system
14:30:02FromDiscord<jviega> `{.pragma: constructor, codegenDecl: "attribute((constructor)) $# $#$#", exportc.}` then your prototype can get argc, argv and envp
14:30:35PMunchIsn't that the same as just overriding main and calling NimMain from there?
14:30:40FromDiscord<jviega> No
14:30:48PMunchOr can C programs have more than one constructor?
14:30:52FromDiscord<jviega> It gets called in addition to NimMain but before your program's entry point
14:30:54FromDiscord<jviega> Yes
14:31:12FromDiscord<jviega> You can in fact set explicit priorities for ordering, etc.
14:31:33PMunchHuh, didn't know that was possible
14:32:11FromDiscord<jviega> Yup, lots of dark corners in C-land 🙂
14:34:36PMunchIndeed
14:36:39PMunchHmm, this is annoying.. JsonNodes are ref objects, so I can get one, change its value, and that changes the node in the object I got it from. But I can't change the type of a node, because that would change the variant object. And just assigning a new object doesn't work, because that breaks the reference..
14:38:18PMunchAha, but I can assign to `node[]`
14:38:19FromDiscord<Clonkk> Isn't std/json generally speaking badly build if you want advanced json handling ?
14:38:55FromDiscord<jviega> "Advanced json handling"?
14:39:51FromDiscord<jviega> It's fine. I think my biggest issues got fixed in 2.0
14:39:52FromDiscord<Clonkk> Well if you need finer control over your Json tree in your program↵(@jviega)
14:40:50FromDiscord<Clonkk> I tend to avoid json but I remember somwhere in the roadmap a goal to rework std/json
14:42:05FromDiscord<Clonkk> Unless that's been done already
14:42:14FromDiscord<jviega> It's all structured as a tree? You can certainly manipulate it just fine. If you wanted to add another layer of indirection, it would make some replacements a little easier, but whether it's better is heavily dependent on you. Tends to be more error prone and a little slower to do that, but a bit easier to do big replacements.
14:42:22PMunchEh, it's fine for most things
14:42:29FromDiscord<jviega> Like I said, it's fine. It's not amazing, but it's fine.
14:42:59PMunch@nnsee, now I can write to files!
14:43:17PMunchOnly existing files though
14:44:24FromDiscord<nnsee> neat
14:46:12PMunchI apparently don't get unmount events though, so it's a bit useless at the moment :P
14:46:35PMunchLike it updates, and the state is kept internally as a JSON object, but it is never written out as one
14:51:28PMunchNice, now it writes out the JSON object on unmount
14:56:42PMunchIf you want to try it out you can find it here: https://github.com/PMunch/libfuse-nim/blob/master/jsonfile.nim
14:56:58PMunchIt's <200 LOC so should be pretty easy to grasp what is going on
14:58:48*jmdaemon quit (Ping timeout: 256 seconds)
14:59:08PMunchI believe adding mkdir and create to the hello_oper definition is all that would be needed to be able to create new keys and objects
14:59:23PMunchBut that has to deal with the logic of doing so
14:59:44PMunchI must say, libfuse is surprisingly easy to work with
15:00:04PMunchShould definitely be possible to do what I had originally planned with it
15:13:05FromDiscord<demotomohiro> In reply to @jviega "<@392962235737047041> you can get": I searched about that feature and this answer says it is platform-dependent.↵https://stackoverflow.com/questions/58999228/picking-up-value-of-attribute-constructor-function-in-main
15:13:56FromDiscord<jviega> Meaning it might not work on Windows. It should work in anything even remotely unixy it’s been around forever
15:14:31PMunchI mean I'm writing a FUSE thing, so Windows is already out of the question
15:16:31FromDiscord<jviega> I’m sure it even works w wsl2
15:17:18PMunchFUSE or constructor?
15:22:42FromDiscord<jviega> Constructor, tho I suspect FUSE would too
15:22:44FromDiscord<bostonboston> The constructor attribute works on windows, I use it in my libs so I don't have to call nimMain
15:23:44FromDiscord<jviega> Yeah I thought it did. It's fairly universal
15:26:53*PMunch quit (Quit: Leaving)
15:39:52FromDiscord<Phil> I think I might not be able to get around the macro bits
15:41:34FromDiscord<Phil> sent a code paste, see https://paste.rs/4GVgn
16:29:39FromDiscord<Phil> Oh hey, you can use a macro in a template here
16:46:25FromDiscord<albassort> I found a 10 year old pmuch insult last night
16:48:21*krux02 joined #nim
17:46:11*antranigv quit (Ping timeout: 264 seconds)
17:59:09FromDiscord<Phil> Wait... crap, if spawning a thread isn't in there, I can either write my own threadpool solution which I'd like to avoid or look if any other solution allows spawning threads without ever awaiting them and instead waiting for them to send channel messages
17:59:36FromDiscord<Phil> (edit) "spawning" => "spawning/creating" | "spawning/creatinga thread ... isn'tpossible" added "from a proc" | "in there," => "possible (because it all requires global variables),"
18:00:11FromDiscord<Phil> I guess Malebolgia is out as it definitely doesn't support unstructured concurrency which I believe this falls under.↵Leaves Weave and taskpool
18:37:28FromDiscord<albassort> In reply to @isofruit "Wait... crap, if spawning/creating": can you pass pointers to channels into there?
18:38:19FromDiscord<albassort> macro into the template and extend it somehow?
18:38:37FromDiscord<Phil> The problem with malebolgia isn't that I can't get a channel in there, it's that I can't spawn a thread without awaiting it
18:38:57FromDiscord<Phil> Which I don't wish to do at all cost. The entire idea is to not give a damn when it returns. It just pings back a channel message when its ready and dies
18:39:00FromDiscord<Phil> That's the idea anyhow
19:14:38NimEventerNew thread by miran: Nim 2.0.2 and 1.6.18 released, see https://forum.nim-lang.org/t/10785
19:19:57*antranigv joined #nim
19:20:07FromDiscord<9ih> does std/streams care about the endianness of the host cpu?
19:21:28*pbsds quit (Quit: Ping timeout (120 seconds))
19:21:57*pbsds joined #nim
19:22:05*casaca quit (Read error: Connection reset by peer)
19:22:30*madprops quit (Remote host closed the connection)
19:22:31*khazakar quit (Read error: Connection reset by peer)
19:22:46*khazakar joined #nim
19:22:46*madprops joined #nim
19:22:46*madprops quit (Changing host)
19:22:46*madprops joined #nim
19:22:53*GreaseMonkey quit (Remote host closed the connection)
19:23:59*greaser|q joined #nim
19:26:42FromDiscord<nasuray> In reply to @isofruit "The problem with malebolgia": I forced it to do this in probably a super unsafe way by having an await that passes around the addr of bool from other threads to stop a while loop another another spawned thread
19:27:17FromDiscord<Phil> That sounds like working around intended limitations and the intended scope of a package
19:27:30FromDiscord<Phil> Which means unsupported territory and "You're on your own if future code changes break your workaround"
19:27:49FromDiscord<Phil> I'd like something a bit more stable, so I opened an issue with weaver in the hopes that what I'm asking for isn't dumb ^^'
19:28:23FromDiscord<Phil> and that I can get an answer from mratsim as the examples there aren't really informing me of how to achieve what I want
19:28:45FromDiscord<nasuray> Ya I basically just wanted to have two separate threads make network calls where one is showing a progress bar and the other is doing work in the background.
19:29:02FromDiscord<Phil> Honestly I just saw ↵> Only support "structured" concurrency.↵And bailed
19:29:13FromDiscord<Phil> In reply to @nasuray "Ya I basically just": So basically 2 long running threads that ping pong messages
19:29:26FromDiscord<Phil> Like a Threadserver↵... may I introduce you to ThreadButler ? 😄
19:31:19FromDiscord<Phil> I mostly just want to have a way to split out tasks from the background thread into "task"-threads that ping messages back and die.↵Otherwise the idea is every long-running thread gets a channel that you can send messages to.↵All channels are united in the hub, if you have the hub you can send messages to any long-running thread out there.↵All of that is type-safe since the channels pass object variants around that I generate for you.
19:32:34FromDiscord<Phil> And threads have associated handlers to deal with their individual messages, one handler per message type (basically requires heavy usage of `distinct` if you need the same kind of data in multiple ways)
19:32:41FromDiscord<nasuray> In reply to @isofruit "Honestly I just saw": My eyes glazed over since I don't really know what I'm doing vis a vis multi threading and did whatever I wanted lol
19:34:04FromDiscord<Phil> Fair.↵I basically see all of these concurrency libs and see scientific notations.↵none of the docs are accessible to me.↵If you don't already have a solid standing in concurrency, you're not going to understand what the heck they want from you when you just want a "webdev-like" setup with a GUI thread and a backend thread
19:34:53FromDiscord<Phil> I have about 50 examples for concurrently working through data in a seq and about none for a thread wanting to split out tasks and never block its own while loop
19:35:08FromDiscord<Phil> (edit) "I have about 50 examples for concurrently working through data in a seq and about none for a thread wanting to split out tasks ... and" added "into short-lived threads"
19:36:43FromDiscord<Phil> (edit) "I have about 50 examples for concurrently working through data in a seq ... and" added "or doing recursive tasks in parallel"
19:49:36FromDiscord<pmunch> In reply to @albassort "I found a 10": Do you keep them in a box?
19:58:43*xet7 quit (Remote host closed the connection)
20:01:31FromDiscord<Zoom> How is that different from a basic threadpool pattern?↵(@Phil)
20:01:49FromDiscord<Zoom> I mean, the long-running part.
20:02:12FromDiscord<Phil> In reply to @Zoom "How is that different": Not all my tasks are uniform and I'm centering everything around the GUI thread (mentally)
20:03:39FromDiscord<Phil> Maybe I want the backend thread to have a connection pool to a database, or whatever.↵The biggest part about multithreading in this place is about syntax though. I can express in words what I want, but I fail to express it in syntax, the examples I see don't go in the direction that I want and I fail to "transform" them into what I want or change my vision so that it fits with the examples
20:05:25FromDiscord<michaelb.eth> @Phil I will get to the review of the thread butler docs, just been a bit busy with holidays fast approach
20:05:31FromDiscord<michaelb.eth> (edit) "approach" => "approaching"
20:05:33FromDiscord<Zoom> I suppose the set of the task kinds is known and bounded, you can dedicate specific threads or even threadpools to them.↵(@Phil)
20:07:37FromDiscord<Phil> sent a long message, see <!doctype html>
20:07:44FromDiscord<pmunch> In reply to @albassort "I found a 10": Wait, did I insult someone, or did someone insult me?
20:09:06FromDiscord<michaelb.eth> I also wanted to note that, I'm starting to think again about `AsyncChannel`. I starting to feel strongly again it's the "right way" to set a foundation for the kind of stuff you're aiming for.↵↵I can't make any guarantees, but I think if we can nail down a solid implementation of `AsyncChannel` then it should be straightforward to build task abstractions on top of it, similar to that earlier work I did on a task runner.
20:09:10FromDiscord<Phil> Which brings me to right now and not knowing what the heck to do.↵I mean, fundamentally I could just generate 50 global thread variables that I use as my own threadpool but that seems predestined to make me run into issues
20:10:00FromDiscord<Phil> In reply to @michaelb.eth "I also wanted to": I mean, I'm happy to implement support for it when it stands, but the difference is kinda beyond me I'll admit.↵I use tryRecv and trySend everywhere anyway, so none of my reads/writes should be blocking, thus what AsyncChannel achieves I'm not entirely sure of
20:10:16FromDiscord<Phil> well, blocking beyond getting the lock
20:11:49FromDiscord<Phil> So currently I just opened an issue with weave so maybe mratsim can tell me if I'm being an idiot or not trying to build what I described with weave as apparently there's nothing (that isn't deprecated) in the std lib to do so
20:12:18FromDiscord<Phil> Well, unless I entirely roll my own on the basis of a set of generated global thread variables that I randomly use
20:12:28FromDiscord<Phil> (edit) "Well, unless I entirely roll my own on the basis of a set of generated global thread variables that I randomly use ... " added "and let die"
20:14:25FromDiscord<nasuray> sent a code paste, see https://play.nim-lang.org/#ix=html>
20:14:40*greaser|q quit (Changing host)
20:14:40*greaser|q joined #nim
20:14:45*greaser|q is now known as GreaseMonkey
20:15:28FromDiscord<Phil> Note, you could use an atomic bool there xP
20:15:42FromDiscord<Phil> At least I think you could, should be possible
20:15:55FromDiscord<Elegantbeef> Phil is a person
20:16:32FromDiscord<Phil> The apple in my Pfp claims otherwise
20:16:49FromDiscord<Elegantbeef> They own glasses though
20:17:00FromDiscord<Phil> Just makes it a smart fruit
20:18:09FromDiscord<JJ> why is it that only case statements are special-cased to be overloadable as a macro?
20:18:27FromDiscord<Elegantbeef> Cause pattern matching
20:18:45FromDiscord<Phil> In reply to @nasuray "This is the salient": I am not entirely sure where one thread talks to the other I'll admit
20:18:46FromDiscord<Elegantbeef> I think the talk was to use `case` instead of `match`
20:19:08FromDiscord<Elegantbeef> Also for loops are overloadable
20:19:13FromDiscord<JJ> yeah but like... i would really like to be able to overload if statements as well 🙁
20:19:17FromDiscord<JJ> oh interesting
20:19:19FromDiscord<Elegantbeef> but it's done `for ... in macro args:...`
20:19:31FromDiscord<Elegantbeef> You do not need to overload them though
20:20:15*val_ joined #nim
20:20:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
20:20:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
20:21:06*val_ quit (Client Quit)
20:21:08FromDiscord<Phil> In reply to @Elegantbeef "Phil is a person": Though for the purposes of clear communication, what did you want to express?
20:21:45FromDiscord<Elegantbeef> I found it funny that you suggested the atomic like ostensibly 3 days after first learning of them 😄
20:22:07FromDiscord<Phil> That's a good quality! Immediately apply what improves your code!
20:22:25FromDiscord<nasuray> In reply to @isofruit "I am not entirely": They both get the pointer `finished` and `showProgress` starts up with `while not finished[]`. That's the extent of their "communication".
20:22:28FromDiscord<Elegantbeef> When all you have is a hammer every problem looks like a nail
20:22:55FromDiscord<Phil> I got a toolbox, that one may be missing screwdrivers though so I make do with the hammer and nail
20:23:23FromDiscord<Elegantbeef> At this point I doubt you even have a hammer and just set nails using your toolbox
20:24:30FromDiscord<Phil> The toolbox contains a fair bit, just not low level stuff like memory allocation and a decent grasp on multithreading related things/concurrency lingo xP
20:24:57FromDiscord<Phil> Which is what I'm working on so I demand some slack xP
20:26:03FromDiscord<Phil (he/him)> Man, imagine the bridge just being dead again
20:26:22FromDiscord<Elegantbeef> Imagine
20:26:23FromDiscord<Phil (he/him)> Or dropping messages apparently.↵↵This was dropped\:↵> Which is what I'm working on so I demand some slack xP
20:26:56FromDiscord<Elegantbeef> Nah this is matrix and discord
20:44:07*xet7 joined #nim
21:06:31*khazakar quit (Quit: Connection closed for inactivity)
21:16:51FromDiscord<summarity> How do I define the target (e.g. "js") in a nim.cfg
21:17:59FromDiscord<intellij_gamer> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:20:29FromDiscord<nnsee> In reply to @isofruit "The apple in my": apple a re people too
21:38:23FromDiscord<goldenlion5648> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:46:17FromDiscord<9ih> are there any neato tools for using with nimble for like monorepo structures? like yarn workspace where I don't need to explicitly increment versions for each package
21:46:41FromDiscord<9ih> (edit) "are there any neato tools for using with nimble for like monorepo structures? like yarn workspace where I don't need to explicitly increment versions for each package ... " added "for use in other packages"
21:48:03FromDiscord<nnsee> In reply to @9ih "are there any neato": atlas might be able to do this, from the sounds of it
21:49:47FromDiscord<graveflo> In reply to @goldenlion5648 "hey I'm relatively new": I don't think so. You can assign a default value and in future versions of nim you can enforce "not nil" types, but I don't know of any way to do that with the default constructor. It is common practice to make a `proc` to construct objects though
21:50:16FromDiscord<graveflo> I like the default constructor a lot though and I wish there were more ways to play with it
21:50:25FromDiscord<goldenlion5648> In reply to @graveflo "I don't think so.": thanks
21:50:34FromDiscord<Phil> In reply to @goldenlion5648 "hey I'm relatively new": The best I can recommend is adopting a pattern of not instantiating types directly but through constructors (like initAnimal), these will force you to set values
21:50:42FromDiscord<Phil> since they're just procs that you pass parameters
21:51:25FromDiscord<goldenlion5648> not really related, but is there a way to create new operators? like say I wanted to make `^&^` an operator (or some other symbol combination)
21:51:37FromDiscord<9ih> In reply to @nnsee "atlas might be able": oki thanks
21:51:50FromDiscord<Phil> In reply to @goldenlion5648 "not really related, but": I mean sure, operators are just procs
21:52:05FromDiscord<Phil> Are you aware to use backticks in those scenarios?
21:53:31FromDiscord<bostonboston> You can make your own operators but I don't think you can give them funny semantics like ``[]``
21:53:31FromDiscord<goldenlion5648> In reply to @isofruit "Are you aware to": I learned about them 5 minutes ago, so not a good grasp yet, but I was kind of trying that, was wondering why this was invalid https://media.discordapp.net/attachments/371759389889003532/1186788429636304926/image.png?ex=659485db&is=658210db&hm=10ad16b5384a1d10f301ea7cdce700e9e5c54d9681601662adb950e0716756d0&
21:54:30FromDiscord<Phil> I will admit that one I never tried. I assume that maybe operators require you to use special characters?↵But I never even had the idea to use a normal word for that since... that's not a valid usecase for it really
21:55:36FromDiscord<goldenlion5648> In reply to @isofruit "I will admit that": oh you were right, thanks this worked https://media.discordapp.net/attachments/371759389889003532/1186788951701336145/image.png?ex=65948657&is=65821157&hm=371b9cfc40ea837c9dbd981c6b644ae4214429e45b6d701ea2166bb8dbbeb265&
21:57:31FromDiscord<nasuray> In reply to @goldenlion5648 "hey I'm relatively new": https://nim-lang.org/docs/manual.html#requiresinit_1 you might want the `requiresInit` pragma
21:58:07FromDiscord<graveflo> I believe only a small symbol set can be used when defining infix operators
21:58:30FromDiscord<graveflo> In reply to @goldenlion5648 "I learned about them": https://nim-lang.org/docs/manual.html#lexical-analysis-operators
21:58:59FromDiscord<goldenlion5648> In reply to @nasuray "https://nim-lang.org/docs/manual.html#requiresinit_": thanks looks like you were correct
22:07:28*advesperacit quit ()
22:08:41FromDiscord<goldenlion5648> I'm trying to make an interpretter in nim, and to take some shortcuts, is there an equivalent to python's eval?
22:08:44FromDiscord<Phil> In reply to @michaelb.eth "<@180601887916163073> I will get": All good, take your time btw.↵I've been trying to figure out how to do add in tasks anyway in a manner that doesn't end up with me creating my own threadpool since std/threadpool is deprecated
22:09:00FromDiscord<Phil> In reply to @goldenlion5648 "I'm trying to make": What does python's eval do?
22:09:16FromDiscord<goldenlion5648> In reply to @isofruit "What does python's eval": run a string as code
22:09:40FromDiscord<Phil> In reply to @goldenlion5648 "run a string as": You can do that, but at compiletime, not at runtime
22:10:00FromDiscord<Phil> So first things first, are you aware of the difference between the two?
22:10:15FromDiscord<goldenlion5648> thanks, all good. I guess eval is pretty unsafe haha
22:10:25FromDiscord<goldenlion5648> In reply to @isofruit "So first things first,": yeah I am
22:10:36FromDiscord<Phil> Check.↵Basically what you'd be doing is macros
22:11:13FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:11:30FromDiscord<Phil> Everything with backticks is a variable whose "string" gets inserted there
22:12:05FromDiscord<Phil> So it's very much a "kinda" at compiletime, but even there only "kinda"
22:12:51FromDiscord<goldenlion5648> In reply to @isofruit "So it's very much": how would that macro be invoked? like what would the arguments be?
22:13:15FromDiscord<Phil> Ah, that was only an excerpt of a proc that is called as part of a macro
22:13:21FromDiscord<Phil> Give me a minute to whip up an example
22:13:55FromDiscord<Elegantbeef> What phil is saying will not help
22:14:00FromDiscord<Elegantbeef> You'd need to use Nim's VM to cheat that way
22:14:23FromDiscord<Elegantbeef> Macros are evaluated at compile time so you cannot provide runtime strings to evaluate code
22:14:38FromDiscord<Phil> Did I miss something? We were talking about compiletime
22:14:52FromDiscord<Phil> Wait, did I not make it clear that this generates actual code and thus goes away after compilation is done?
22:15:00FromDiscord<Elegantbeef> > I'm trying to make an interpretter in nim, and to take some shortcuts,
22:15:16FromDiscord<Elegantbeef> I assume this means they want to just evaluate expressions instead of doing a proper VM to cheat
22:15:33FromDiscord<albassort> In reply to @pmunch "Wait, did I insult": you called someone stupid for something stupid
22:15:36FromDiscord<Phil> Ahh, fair
22:15:50FromDiscord<goldenlion5648> no worries, I'm clear that my original idea wont work
22:16:04FromDiscord<albassort> In reply to @pmunch "Do you keep them": no i keep them on the nim fourms with the rest of the things i dont own
22:16:48FromDiscord<pmunch> Huh, hopefully it was deserved
22:17:03FromDiscord<Elegantbeef> If it was aimed at me, probably
22:21:58FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:23:14FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:23:41FromDiscord<Elegantbeef> It most likely will not help you at all
22:24:06FromDiscord<Phil> I think at this point they just got curious
22:24:16FromDiscord<goldenlion5648> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:24:40FromDiscord<goldenlion5648> In reply to @isofruit "I think at this": yeah I just got curious
22:24:42FromDiscord<Elegantbeef> Phil is silly and did not use `static string`
22:24:43FromDiscord<Phil> In reply to @goldenlion5648 "what is the point": Yes, the issue here is that macros implicitly convert everything they accept into NimNodes
22:25:15FromDiscord<Phil> In this case the nimnode is a "string literal" which you can turn back into a string via `$`
22:25:18FromDiscord<Elegantbeef> `string` means it accepts any ast that is of type `string` `static string` means it accepts a constant value and it's accessible as a normal string inside the macro
22:25:47FromDiscord<Phil> Could've used static string but I do not yet have built that habit, instead I just unpack the string value
22:27:12FromDiscord<Elegantbeef> Ah you do not like functioning macros
22:27:12FromDiscord<Elegantbeef> 😛
22:27:14FromDiscord<Elegantbeef> If you're unpacking values you've completely removed any compile time evaluation and constants
22:28:57FromDiscord<Phil> I have in fact not!↵Because I implemented a proc that checks if its a symnode and extracts the value from the impl if so... yes I likely should've used static string
22:29:29FromDiscord<Elegantbeef> What about `"hello" & "world"`?
22:29:43FromDiscord<Phil> I will admit I haven't tried
22:29:58FromDiscord<Elegantbeef> That gives you a `nnkInfix`
22:30:05FromDiscord<Elegantbeef> Shit that's wrong
22:30:29FromDiscord<graveflo> don't rustle beef about macros. He's obsessed with them
22:30:30FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:30:31FromDiscord<Elegantbeef> There we go
22:30:49FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:30:53FromDiscord<Elegantbeef> Lol grave
22:30:57FromDiscord<Elegantbeef> Macros are lovely
22:31:00FromDiscord<Elegantbeef> I just like reusable code
22:31:10FromDiscord<Elegantbeef> Manually unpacking nodes is masochistic behaviour
22:31:32FromDiscord<Phil> Huh, yeah my proc worked for the & operator
22:31:40FromDiscord<Elegantbeef> Yea cause of constant folding
22:31:48FromDiscord<Elegantbeef> `"hello" & "world"` is constant folded
22:32:15FromDiscord<Phil> Okay at this point you're really constructing scenarios.↵Like, I'll fold that static string is better, but the examples are starting to reach
22:32:24FromDiscord<Elegantbeef> throwing in `bleh()` means the code can be evaluated at runtime and is not constant folded at the call site
22:32:49FromDiscord<Phil> Doesn't the macro using string implicitly force the string to be compiletime?
22:32:55FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:32:57FromDiscord<Phil> Because macros don't exist at runtime
22:32:57FromDiscord<Elegantbeef> No it does not
22:33:06FromDiscord<Elegantbeef> You can have a macro that operates on a `let` value
22:33:18FromDiscord<Elegantbeef> The ast has to be known at CT not the data it contains
22:33:36FromDiscord<Phil> You can have a macro operating on the AST that will in the future hold a let value but not the let value itself
22:33:49FromDiscord<Elegantbeef> `s: string` states "This AST must be typed to string" it has no indication of what the data actually is
22:34:08FromDiscord<Phil> I am happy to be proven wrong but I'm having trouble envisioning a compiletime construct acting on data that does not exist by the time it disappears
22:34:13FromDiscord<Elegantbeef> Let's consider `strscans`
22:34:24FromDiscord<Elegantbeef> `line.scanf("$i", myInt)`
22:34:31FromDiscord<Elegantbeef> This scans a unknown string parsing an int
22:34:40FromDiscord<Elegantbeef> Most macros do not know their inputs statically
22:35:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:35:59FromDiscord<Elegantbeef> Ok most is nor accurate, but there are many places where macros do not operate on CT values
22:36:02FromDiscord<Elegantbeef> not\
22:36:16FromDiscord<Phil> I would assuming that whatever represents the exact macro here (I'm not sure what is triggering this) simply reshapes the code that is written there into "normal" code intead of acting on the data inside
22:36:38FromDiscord<Elegantbeef> Right, they're user defined compiler passes that convert one syntax to another
22:37:02FromDiscord<Elegantbeef> But the point is that there are many macros that do not need to know what the data is cause they're just transformers
22:37:20FromDiscord<Phil> I mean, any macro is just a syntax transformer
22:37:28FromDiscord<Phil> As you stated basically
22:37:32FromDiscord<Elegantbeef> That's not true
22:37:35FromDiscord<Elegantbeef> Macros do not have to emit AST
22:37:46FromDiscord<Elegantbeef> You can use macros to just statically call code
22:38:17FromDiscord<Elegantbeef> I'm not a bit confused where the disconnect is 😄
22:38:19FromDiscord<Elegantbeef> now a bit\
22:38:40FromDiscord<Phil> While true, ultimately I've always ultimately used them to generate code.↵There were macros that didn't generate code themselves but were part of a larger mechanism that ultimately spit out code
22:39:47FromDiscord<Phil> In reply to @Elegantbeef "I'm not a bit": Regarding the data stuff?↵Likely because the statement "operates on a let value" indicated to me that somehow the macro code acted on/with the runtime value.↵Which I don't think it can.↵It can just reshape the instructions that will run over that value, like the pipe it'll run through, but it doesn't act on the water later that flows through afterwards because its gone by then.
22:40:43FromDiscord<Elegantbeef> By `let` value I meant a sym that pointed to `let`
22:40:57FromDiscord<Elegantbeef> Not the value held inside a let cause that's only possible if the macro is evaluated at runtime which is not possible
22:41:01FromDiscord<Phil> Ah check, then just a misunderstanding
22:50:10*xet7 quit (Remote host closed the connection)
22:53:44NimEventerNew question by Nino van Hooff: How to call iterator for Chipmunk 7 bindings (Nim), see https://stackoverflow.com/questions/77688407/how-to-call-iterator-for-chipmunk-7-bindings-nim
23:01:37FromDiscord<albassort> One day I'll contribute to nim.
23:02:27FromDiscord<Phil> You can contribute docs anytime 😉
23:10:10FromDiscord<albassort> I can document the hidden go-to
23:10:27FromDiscord<albassort> (edit) "go-to" => "goto statement"
23:19:07FromDiscord<summarity> sent a code paste, see https://play.nim-lang.org/#ix=html>
23:22:54FromDiscord<guttural666> how do initialize a distinct string like Path?
23:23:10FromDiscord<Elegantbeef> `Path"someString"`
23:25:57FromDiscord<guttural666> confused, shouldn't thi work?
23:26:00FromDiscord<guttural666> https://media.discordapp.net/attachments/371759389889003532/1186811698737328229/image.png?ex=65949b86&is=65822686&hm=706ec2a66545ac4c2fc7c186205743d28c011a6ece66dfe3eea1b77ab47b1165&
23:26:01NimEventerNew thread by inv2004: Ccal: Calendar with local holidays via ip location, see https://forum.nim-lang.org/t/10786
23:26:05FromDiscord<guttural666> (edit) "thi" => "this"
23:26:14FromDiscord<Elegantbeef> It will
23:26:24FromDiscord<Elegantbeef> `path.splitFile(path)`...?
23:26:32FromDiscord<guttural666> https://media.discordapp.net/attachments/371759389889003532/1186811833605161010/image.png?ex=65949ba7&is=658226a7&hm=d8007c23c9dc2b7c58ea258c02d5590b70b92862d62b5f536c81326c92ad3040&
23:26:40FromDiscord<guttural666> fuck
23:27:37FromDiscord<guttural666> UFC is error prone and wrong 😄 and I'm stupid
23:46:31FromDiscord<summarity> How can I force Nim to not mangle object property names in JS? Here's a minimal example: https://gist.github.com/turbo/627e1fb4762dcf96c78a261df882f74f
23:50:57FromDiscord<Elegantbeef> `{.exportc.}`
23:53:48FromDiscord<summarity> Ah, on the prop itself. Yes, `{.exportc: "['$1']".}` worked