<< 20-10-2023 >>

00:05:21FromDiscord<girvo> What about `nimble install --link`? Is that similar in semantics to how nimble develop used to work?
00:08:00FromDiscord<girvo> (Not that it matters, we're using --path now! but my teammate was curious)
00:10:52FromDiscord<Elegantbeef> No clue after nimble develop failed to work I've just moved to atlas
00:23:05*koltrast joined #nim
00:27:03FromDiscord<sOkam! 🫐> same
00:31:08FromDiscord<nasuray> I wished atlas had a more straightforward setup for using a single directory rather than a workspace, but maybe I've just missed that in the docs.
00:35:19FromDiscord<sOkam! 🫐> the directory can be the workspace, afaik
00:35:24FromDiscord<Elegantbeef> you can make a deps folder
00:36:03FromDiscord<Elegantbeef> `atlas init --deps=deps` dumps all your deps inside the `deps` folder
00:39:42FromDiscord<nasuray> Hmmm I think maybe the issue might have been that I used `atlas init --deps` but then followed up with `atlas use` rather than `atlas install`
00:39:51FromDiscord<sOkam! 🫐> what does `cap` represent in `string` and `seq[T]` internal format?↵I know `len` is the count of entries, but what is cap?
00:40:22FromDiscord<leorize> it is the allocated size
00:40:22FromDiscord<Elegantbeef> How big the allocation is
00:40:40FromDiscord<Elegantbeef> How many elements there are presently allocated but it does not mean presently used
00:40:56FromDiscord<Elegantbeef> Nim's seq/string follow most standard strings where you allocate more than you need often
00:53:52FromDiscord<odexine> It stands for “capacity”
00:58:40FromDiscord<girvo> `newStringOfCap` is super useful for reducing uneccesary `realloc0` calls
01:00:45FromDiscord<leorize> and not to mention that nim's realloc is always malloc + copy
01:55:21*lumo_e quit (Quit: Quit)
02:55:28FromDiscord<sOkam! 🫐> why is `var num :float= 1.0'f; inc(num)` not a thing in nim, like it is in C?↵does anybody know the reasoning behind it?
02:56:51FromDiscord<Elegantbeef> I'd argue it's ambiguous
02:57:23FromDiscord<leorize> that one shouldn't be though?
02:57:41FromDiscord<Elegantbeef> Should it be `2` or `1 + epsilon` 😄
02:59:38FromDiscord<demotomohiro> In reply to @heysokam "why is `var num": I guess, because it is not much used and easy to implement yourself.↵Or if float value was large enough, `y = x + 1.0'f; assert x == y`.
03:00:37FromDiscord<sOkam! 🫐> kk
03:09:50*derpydoo quit (Read error: Connection reset by peer)
03:17:39FromDiscord<odexine> Ah yes the 53 bit integer precision problem kinda thing
03:18:01FromDiscord<Elegantbeef> Not an issue with my `inc` implementation
03:18:31FromDiscord<Elegantbeef> In my version `x == y` only works when `x` is inf
03:25:09FromDiscord<odexine> “Your implementation”? Where
03:25:21FromDiscord<Elegantbeef> My hypothetical one
03:25:27FromDiscord<Elegantbeef> Where it increments with epsilon
03:25:50FromDiscord<odexine> Well sure but that’s not really better
03:26:07FromDiscord<odexine> Because now increment isn’t exactly consistent or even useful
03:26:50FromDiscord<Elegantbeef> It's consistent, each gives you the next value 😛
03:35:59FromDiscord<odexine> Okay, then the interval is not numerically equal for all values
03:50:22FromDiscord<Elegantbeef> Hey I'm never helpful
05:29:25FromDiscord<nasuray> sent a long message, see http://ix.io/4JsW
05:31:11FromDiscord<wick3dr0se> Is it possible to listen on specified remote IP with a TCP server? It listens on 127.0.0.1 or my local machine ip with listen() currently
05:31:38FromDiscord<wick3dr0se> But trying to connect via remote IP with a client doesn't work
05:33:19FromDiscord<leorize> you can listen on your public IP
05:33:42FromDiscord<leorize> but check your firewall
05:34:17FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/d2Rrs
05:34:43FromDiscord<leorize> maybe you can try disruptek/nimph↵(@nasuray)
05:46:40FromDiscord<sOkam! 🫐> @nasuray does `.gitignore` not help with removing that subfolder for local, and keeping the library working as if it was with nimble otherwise?
05:47:56FromDiscord<sOkam! 🫐> i haven't tried distributing an atlas workspace, but from what I saw it seemed like a big pain↵when the alternative is just a list of `requires blabla` inside the .nimble file 🤔
05:50:55FromDiscord<wick3dr0se> In reply to @leorize "but check your firewall": I dont have a firewall installed. Maybe router issue then.. 🫠
05:52:09FromDiscord<Elegantbeef> How is atlas any more of a pain over Nimble?
05:56:04FromDiscord<Chronos [She/Her]> In reply to @wick3dr0se "I dont have a": Is the port open? If you're connecting to it from outside the local network that could be an issue
06:00:03FromDiscord<wick3dr0se> In reply to @chronos.vitaqua "Is the port open?": Well my dad is a privacy freak. I'n thinking more than likely he has blocked the ports, including 6667. I'll just have to factory reset the router when they're gone and open the port once I set SSID/pass to the same 😅
06:00:12FromDiscord<wick3dr0se> (edit) "I'n" => "I'm"
06:07:55FromDiscord<sOkam! 🫐> In reply to @Elegantbeef "How is atlas any": having to distribute the atlas workspace/dependencies↵maybe it was some convoluted setup of the person who I read it from (don't remember so cant quote)↵compared to just having a list of requires and that's it
06:10:43FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Jt8
06:10:47FromDiscord<Elegantbeef> That's all that's required for figuro's setup
06:15:05FromDiscord<sOkam! 🫐> how is that easier than a list of requires?
06:15:45FromDiscord<Elegantbeef> 2 commands is hardly painful, but I guess YMMV
06:16:14FromDiscord<sOkam! 🫐> i can see 4-5 without including the atlas installation
06:16:17FromDiscord<Elegantbeef> It does generate the requires for you
06:16:33FromDiscord<sOkam! 🫐> i mean, its still better than nimble develop, which cannot be distributed
06:16:33FromDiscord<Elegantbeef> That's also not distribution I guess
06:16:56FromDiscord<Elegantbeef> Atlas is capable of making your nimble requires you just `include` afaik
06:17:25FromDiscord<sOkam! 🫐> don't know if I understood what that meant
06:17:49FromDiscord<Elegantbeef> Well actually in default setup it just adds `requires "..."` to any urls you `atlas use x`
06:18:16FromDiscord<Elegantbeef> Like it made a `locker.nimble` and added a requires for truss3D from me 'using' it
06:22:42FromDiscord<Elegantbeef> Though I guess it does not tag a version, so that's not ideal
06:23:36*Guest12 joined #nim
06:23:59FromDiscord<nasuray> In reply to @Elegantbeef "<@372579559645773828> cant you just": no because `yourProject` in the situation I'm describing is the project containing a `pkg_name.nimble` meaning I can't `atlas install` it.
06:24:32FromDiscord<Elegantbeef> Why can't you?
06:24:38*Guest12 quit (Client Quit)
06:26:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Jta
06:26:12FromDiscord<Elegantbeef> all I did was `atlas install test.nimble`
06:30:38FromDiscord<Elegantbeef> Well after `atlas init --deps=.deps` of course
06:32:43FromDiscord<nasuray> No totally on me it seems...I had been making dummy directories/projects to test out `atlas` again during this conversation and it wasn't allowing it. But then I tried to make gif to show you my issue and it worked fine. So in my haphazard directory generation alongside `atlas` I must have borked one of the files it's reading to get context. If I can ever reproduce it I'll track down the bug.
06:34:04FromDiscord<Elegantbeef> Always takes falling down stairs and breaking your arm to learn to record it first 😛
06:35:16FromDiscord<nasuray> Granted in the middle I did install from `atlas#head`, so could be that lol
06:36:12FromDiscord<Elegantbeef> Who knows
06:38:14FromDiscord<Chronos [She/Her]> In reply to @wick3dr0se "Well my dad is": If that's an issue, could use something like Hamachi instead? Virtual networks, essentially
06:38:45FromDiscord<Chronos [She/Her]> Or if UPnP is allowed on your router, could use that too, tho I'd advise against it since it's insecure :0
06:38:49FromDiscord<Chronos [She/Her]> (edit) ":0" => ":p"
06:53:13*PMunch joined #nim
06:54:36FromDiscord<JJ> speaking of nimph, does gitnim work with 2.0.0? the `devel` tag has always seemed broken for me and i haven't figured out how to package my own distribution not based on a tag
07:04:58*advesperacit joined #nim
07:13:46*redj quit (Remote host closed the connection)
07:16:37*redj joined #nim
08:01:58FromDiscord<muchamadyja> Is there any channel or server that i can asking about beginner question?
08:02:15PMunchApart from this one?
08:02:24FromDiscord<muchamadyja> Im newbie in here btw
08:02:48PMunchOh right, feel free to ask beginner questions here :)
08:03:09PMunchOf course try to google stuff first though
08:04:08FromDiscord<muchamadyja> wait, I thought you were a bot account 😅
08:04:57PMunchCommon misconception, there's a bot which relays messages from other channels to this one :)
08:10:51FromDiscord<muchamadyja> ok, sorry about it, and thanks btw.↵For now there is no questions, I just bought the book Nim in Action, and I'm start studying it today, maybe in the future I will have difficulty with the concept of Nim language. ↵so I asked it first, I afraid I had the wrong server. 😅
08:16:34FromDiscord<odexine> Nope, this is the right one
08:16:54PMunchYes you've definitely come to the right place :)
08:22:20FromDiscord<muchamadyja>
08:29:07FromDiscord<nnsee> when building with Nimble, it's supposed to pick up flags from nim.cfg in the project's root, right? I feel like that's worked in the past
08:29:21FromDiscord<nnsee> for some reason, it's not doing so anymore
08:29:28FromDiscord<nnsee> and I can't figure out why
08:30:56Amun-Rayes, it should
08:31:29Amun-Rainsert a bogus text into nim.cfg and rerun nimble
08:31:47Amun-Raperhaps something overrides those flags in the other file?
08:42:28FromDiscord<nnsee> thanks
08:42:36FromDiscord<nnsee> turns out i was just being stupid and mistyping a flag
08:43:33PMunchEasy error to make
08:43:42PMunchAlso note that some flags don't work in the nim.cfg file
08:43:51PMunchFor example you can't have `-d:release` in there I believe
08:46:08NimEventerNew thread by oyster: 2 questions on StringStream, see https://forum.nim-lang.org/t/10559
08:48:33FromDiscord<Phil> Stuff like this is why I just do nimble tasks, seems to fit my mental model more
08:49:37FromDiscord<Elegantbeef> Pmunch that's an old issue release flags now work from config files
08:54:22FromDiscord<nnsee> In reply to @PMunch "For example you can't": seemed to work for me:↵Hint: mm: orc; threads: on; opt: speed; options: -d:danger
08:54:39FromDiscord<Elegantbeef> It was an old issue in like 1.2 and before
08:54:43FromDiscord<Elegantbeef> Might even be 1.4 and before
08:57:41PMunchOh, I just assumed it was a feature
08:57:51PMunchBut nice to see that it has been fixed :)
08:58:10PMunchI guess I should update Ratel then to use `-d:danger` by default
09:28:09FromDiscord<nnsee> is it possible to somehow disable echos in an imported (third-party) module? Trying to disable the "Starting N threads" and "Listening on port N" messages on httpbeast startup
09:28:50FromDiscord<nnsee> (because they don't follow my logging spec at all, and my log collector alerts me on malformed log entries 😅)
09:33:13PMunchYup
09:33:37PMunchhttps://github.com/PMunch/echooverride
09:34:26PMunchIt uses term-rewriting macros and the `--import` statement to inject it into every module
09:35:35NimEventerNew thread by ingo: Threaded updates to sequence in objects?, see https://forum.nim-lang.org/t/10560
09:48:03*xet7 joined #nim
09:50:47FromDiscord<ieltan> Hey guys, just wondering: if I have an `x: var T` param, doing `addr(x)` is zero-cost and does give the `ptr T` of the location of `x`, right ?
09:50:53FromDiscord<Chronos [She/Her]> In reply to @NimEventer "New thread by ingo:": I don't understand this hm
09:51:08FromDiscord<Chronos [She/Her]> In reply to @ieltan "Hey guys, just wondering:": I'd imagine so, yeah
09:51:26FromDiscord<ieltan> To be more specific, can I use `var T` as a clever trick to pass pointers to C wrapped procs ?
09:52:06FromDiscord<Chronos [She/Her]> Ah, I'm not sure about that specifically, maybe? But you'd have to worry about memory management freeing the data I'd imagine
09:52:31Amun-Raieltan: I was doing just that on nim 1.x to avoid using usafeaddr; you don't have to do that in nim2
09:52:53FromDiscord<ieltan> Yes I know, I know how to manage C memory don't worry (famous last words innit)
09:53:07Amun-Ra;>
09:54:17FromDiscord<ieltan> In reply to @Amun-Ra "<@256520101015060480>: I was doing": Are you saying Nim does the convertion from `var T` to `ptr T`/`pointer` implicitly ?
09:54:34Amun-Raieltan: no
09:55:07FromDiscord<ieltan> Oh, I see what you're talking about
09:55:16FromDiscord<ieltan> sorry, the `unsafeaddr` part confused me
09:55:24FromDiscord<ieltan> never heard of it
09:55:30FromDiscord<ieltan> what does it do ?
09:56:08Amun-Rait allows convertion from non-var T to ptr T
09:56:14Amun-Raconversion*
09:56:31Amun-Rait's deprecated in nim2
09:57:59FromDiscord<ieltan> i see, welp thanks 🙂
10:04:18Amun-Rahmm, what does that do? https://nim-lang.org/docs/system.html#%7C%2Ctypedesc%2Ctypedesc
10:04:32Amun-Raproc `|`*(a, b: typedesc): typedesc = discard
10:05:27FromDiscord<ieltan> makes a typeclass afaik, the same as `type SomeType = OtherType or NotherType`
10:05:57Amun-Raah, right
10:06:05Amun-RaI use `or`
10:06:29Amun-RaI completely forgot about that alternative
10:16:29*arkanoid quit (Ping timeout: 258 seconds)
10:18:29*arkanoid joined #nim
10:28:44FromDiscord<nnsee> In reply to @PMunch "https://github.com/PMunch/echooverride": thanks!
10:29:39FromDiscord<nnsee> In reply to @PMunch "https://github.com/PMunch/echooverride": > Currently it must be run under Nim devel...↵is this still the case with Nim 2.0.0?
10:30:15PMunchIt appears that Nim devel was 1.9.1 when that was written, so 2.0.0 should work I believe
10:30:50FromDiscord<nnsee> also, does it require refc? seems like it from the nim.cfg
10:31:48PMunchI think that was a bug in that version of devel
10:31:54PMunchBut you can just try it out and see
10:32:54PMunchOh right, it's the ORC httpbeast bug that requires refc I believe
10:45:38PMunchYeah, replacing it with `-d:useStdLib` makes it work as well
10:46:47PMunchThe only reason that sample uses Jester to begin with is because it was the first thing I could think of which wrote stuff to the terminal when running
11:14:34FromDiscord<nnsee> In reply to @PMunch "Oh right, it's the": wait, i'm using httpbeast in my project, this this bug still present and i should be using refc?
11:14:47FromDiscord<nnsee> is this bug
11:18:15PMunchhttps://github.com/dom96/httpbeast/issues/90
11:32:11PMunchIs there a way to have `d:ssl` defined in my library?
11:32:18PMunchI guess a nim.cfg file would do the trick
11:32:33PMunchBut it's a bit annoying to have another file just for this purpose
11:34:17FromDiscord<intellij_gamer> You can have like `{.define: ssl.}` at the top of the file (Like, needs to be done before imports that check if `ssl` is defined)
11:35:41PMunchOoh, I had ssl in quotes and it didn't work
11:35:46PMunchMy bad
12:15:29FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Ju1
12:15:50FromDiscord<yetiwizard> what's the correct way to do it?
12:20:00PMunchThe error is probably just in the expected assembly format
12:35:36FromDiscord<yetiwizard> what's the correct format?
12:52:21PMunchDepends on your compiler
12:58:36FromDiscord<yetiwizard> nim cpp --cpu:i386 using mingw32
13:05:30FromDiscord<yetiwizard> I tried adding --passC-masm=intel but it doesn't work
13:05:40FromDiscord<yetiwizard> (edit) "--passC-masm=intel" => "--passC:-masm=intel"
13:12:25FromDiscord<yetiwizard> now it doesn't like the ↵mov `zone`, eax↵part
13:13:03FromDiscord<Chronos [She/Her]> Maybe do zone without the backticks?
13:13:45PMunchI believe the point of the backticks is to pull in the reference from Nim
13:13:46FromDiscord<yetiwizard> that worked in VS with C++, but here it doesn't compile
13:13:54FromDiscord<Chronos [She/Her]> Also `exportc` the variable
13:14:05FromDiscord<Chronos [She/Her]> In reply to @PMunch "I believe the point": Hm
13:14:22FromDiscord<Chronos [She/Her]> Then no idea
13:14:30FromDiscord<Chronos [She/Her]> You could emit the c++ code directly tbf
13:15:02PMunchHaha, that's a bit of a hack
13:15:16PMunchIt should be possible with Nim directly
13:15:23FromDiscord<Chronos [She/Her]> Trye
13:15:31FromDiscord<Chronos [She/Her]> But if you need to get it working asap
13:17:30FromDiscord<yetiwizard> In reply to @chronos.vitaqua "Also `exportc` the variable": you mean like `var zone {.exportc.}: pointer = nil`?
13:18:15FromDiscord<Chronos [She/Her]> Yeah
13:18:21FromDiscord<Chronos [She/Her]> But it probably won't do anything
13:19:36FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jug
13:19:38FromDiscord<yetiwizard> maybe NIM_NIL is the problem
13:27:45FromDiscord<Chronos [She/Her]> Ah that may be it
13:28:25FromDiscord<Chronos [She/Her]> Not sure, could you find what `NIM_NIL` is assigned to?
13:31:28FromDiscord<yetiwizard> there is no assignment to NIM_NIL in the generated code. Or is it in some other file?
13:33:48FromDiscord<Chronos [She/Her]> It may be in `nimbase.h`
13:34:59FromDiscord<Chronos [She/Her]> https://github.com/nim-lang/Nim/blob/devel/lib/nimbase.h#L326
13:35:01FromDiscord<Chronos [She/Her]> @yetiwizard
13:35:37FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Juo
13:35:46FromDiscord<yetiwizard> getting `zone` in there is the problem
13:35:55FromDiscord<Chronos [She/Her]> Why _zone?
13:36:04FromDiscord<yetiwizard> just trying everything I can find online
13:36:09FromDiscord<Chronos [She/Her]> Hm
13:36:24FromDiscord<Chronos [She/Her]> Does emitting the C++ code fix the issue completely?
13:36:41FromDiscord<yetiwizard> no, reading zone is still not working
13:36:47FromDiscord<yetiwizard> gcc complains about the syntax
13:36:52FromDiscord<Chronos [She/Her]> In reply to @yetiwizard "I'm trying to port": Even with copy pasting this?
13:37:02FromDiscord<yetiwizard> yea
13:37:03FromDiscord<Chronos [She/Her]> Are you using the C++ backend or the C backend?
13:38:00FromDiscord<yetiwizard> c++
13:38:12FromDiscord<Chronos [She/Her]> Hm, then I am absolutely clueless, sorry
13:38:43FromDiscord<yetiwizard> thanks anyways. I'll keep trying some more until I pull my hair out
13:39:49FromDiscord<Chronos [She/Her]> Wishing you good luck!
13:44:15FromDiscord<Chronos [She/Her]> Quick question for if anyone knows: Does `chronos` (the async library) allow for drop-in replacement of async when imported?
13:53:39*PMunch quit (Quit: Leaving)
13:55:16FromDiscord<leorize> as long as you don't use other async code
13:55:51FromDiscord<Chronos [She/Her]> Such as asyncnet?
13:56:16*alphacentauri quit (Quit: WeeChat 4.1.0)
13:56:24FromDiscord<leorize> yea
13:56:32FromDiscord<leorize> you gotta fully buy into the chronos ecosystem
13:57:19FromDiscord<Chronos [She/Her]> Gucci
13:57:37FromDiscord<Chronos [She/Her]> Though I wonder if just making asyncnet use chronos instead of asyncdispatch would work :p
13:57:39FromDiscord<Chronos [She/Her]> Probably not
14:00:57FromDiscord<leorize> chronos already come with better asyncnet
14:01:07FromDiscord<leorize> why would you bother trying to use asyncnet
14:03:35FromDiscord<Chronos [She/Her]> Just thinking of how easy it'd be to make an abstraction library for letting ppl use any async library easily
14:03:40FromDiscord<Chronos [She/Her]> Basically anyio hut for Nim
14:22:52FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4JuD
14:23:08FromDiscord<yetiwizard> (edit) "https://play.nim-lang.org/#ix=4JuD" => "https://play.nim-lang.org/#ix=4JuE"
14:23:23FromDiscord<yetiwizard> I managed to get the register content into a variable
14:23:44FromDiscord<yetiwizard> it is a pointer to a struct which at offset 0x68 has a char
14:23:56FromDiscord<yetiwizard> I want to echo the content of that cstring
14:24:13FromDiscord<yetiwizard> with this code I get gibberish
14:24:27FromDiscord<yetiwizard> echo toHex(cast[int](zone) + 0x68) - gives the correct address of the cstring tho
14:47:46FromDiscord<leorize> just build your own nim, duh↵(@Chronos [She/Her])
14:52:10FromDiscord<jmgomez> Wasnt someone working on RxNim? That would make it
14:55:08FromDiscord<Chronos [She/Her]> In reply to @leorize "just build your own": Lol
14:56:09FromDiscord<yetiwizard> sent a code paste, see https://paste.rs/uR6fc
14:56:40FromDiscord<leorize> why the emit?
14:56:48FromDiscord<yetiwizard> i've been searching for hours online and can't find a way to do it in Nim directly
14:57:02FromDiscord<leorize> what's your zone variable?
14:57:15FromDiscord<yetiwizard> zone is an object
14:57:18FromDiscord<leorize> the type I mean
14:57:26FromDiscord<yetiwizard> in this case it's PVOID
14:57:39FromDiscord<yetiwizard> but at offset 0x68 of that object
14:57:45FromDiscord<yetiwizard> is a char
14:57:59FromDiscord<Chronos [She/Her]> In reply to @yetiwizard "is there seriously no": A ptr char is just a cstring, no?
14:58:28FromDiscord<leorize> `var zoneName = cast[cstring](cast[unit](zone) + 0x68)`
14:59:02FromDiscord<yetiwizard> what's unit?
14:59:13FromDiscord<yetiwizard> is `cstring` the same as `ptr cchar`
14:59:15FromDiscord<yetiwizard> (edit) "cchar`" => "cchar`?"
15:00:42FromDiscord<Chronos [She/Her]> A string in C is just an unchecked array of characters, so
15:00:52FromDiscord<yetiwizard> sent a code paste, see https://paste.rs/Ktnti
15:00:53FromDiscord<yetiwizard> this piece of code does exactly what I want
15:01:02FromDiscord<Chronos [She/Her]> And an unchecked array is just a pointer
15:01:04FromDiscord<yetiwizard> but I don't get how to do it without emit
15:01:05FromDiscord<leorize> In reply to @yetiwizard "what's unit?": it's uintptr_t
15:01:36FromDiscord<leorize> nim's uint is uintptr\_t in C
15:01:40FromDiscord<leorize> oh it's my phone autocorrect
15:02:31FromDiscord<yetiwizard> I tried `zoneName = cast[cstring](cast[uint](zone) + 0x68)`↵and the output is↵`╨☺ⁿ∟¿☻ⁿ∟6`
15:02:48FromDiscord<yetiwizard> I guess it doesn't dereference the pointer or something
15:03:12FromDiscord<yetiwizard> I think we are missing a level here
15:03:26FromDiscord<yetiwizard> 0x68 is actually pointing to another object
15:03:34FromDiscord<yetiwizard> that has the cstring at offset 0
15:04:44FromDiscord<odexine> `zoneName = cast[ptr cstring](cast[uint](zone) + 0x68)[]`?
15:05:26FromDiscord<yetiwizard> that's it! thank you so much!
15:05:43FromDiscord<yetiwizard> but what if that cstring wasn't at index 0?
15:05:48FromDiscord<yetiwizard> but say at offset 0x24?
15:05:57FromDiscord<yetiwizard> (edit) "index" => "offset"
15:06:08FromDiscord<leorize> then add another 0x24?
15:06:41FromDiscord<yetiwizard> where exactly?
15:07:18FromDiscord<leorize> cast that new ptr to uint then add
15:08:48FromDiscord<leorize> yea nim is not great for pointer math and you'd need to make your own wrappers to do it easily
15:09:19FromDiscord<leorize> luckily that's easy enough to do
15:09:27FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jv7
15:09:43FromDiscord<yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jv7" => "https://play.nim-lang.org/#ix=4Jv8"
15:10:06FromDiscord<leorize> use uint just so you always get the correct pointer size
15:10:46FromDiscord<yetiwizard> oh, cause uint32 will not always equal uint, right?
15:10:46FromDiscord<odexine> sent a code paste, see https://play.nim-lang.org/#ix=4Jva
15:11:24FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jvb
15:11:48FromDiscord<leorize> yep↵(@yetiwizard)
15:11:52FromDiscord<yetiwizard> also, what about using `cint`
15:12:32FromDiscord<yetiwizard> in general, if I want to work with 32bit addresses in Nim, should I use uint?
15:12:33FromDiscord<odexine> cint is equivalent to, well, c's `int` and is therefore subject to the rules
15:12:35FromDiscord<yetiwizard> (edit) "uint?" => "`uint`?"
15:12:52FromDiscord<odexine> if you want to work with any addresses use uint
15:17:25FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jvf
15:17:44FromDiscord<leorize> that one should probably be typed
15:18:22FromDiscord<leorize> as in having some actual types
15:18:28FromDiscord<yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jvf" => "https://play.nim-lang.org/#ix=4Jvg"
15:18:40FromDiscord<yetiwizard> betteR?
15:18:41FromDiscord<yetiwizard> (edit) "betteR?" => "better?"
15:18:43FromDiscord<yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jvg" => "https://play.nim-lang.org/#ix=4Jvh"
15:19:01FromDiscord<leorize> a typed pointer would be even betterer
15:19:04FromDiscord<yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jvh" => "https://play.nim-lang.org/#ix=4Jvi"
15:19:30FromDiscord<yetiwizard> well, it's a void
15:19:47FromDiscord<leorize> make that void something meaningful
15:19:54FromDiscord<leorize> like an actual object of sorts
15:19:58FromDiscord<yetiwizard> true, that would be the next step
15:20:00FromDiscord<leorize> or a distinct pointer
15:20:34FromDiscord<yetiwizard> I have yet to learn the concept of classes as it works in C++ in Nim
15:20:49FromDiscord<odexine> nim doesnt heavily use the concept of classes
15:20:55FromDiscord<leorize> nim objects are C structs
15:21:05FromDiscord<leorize> they are basically the same unless you use inheritance
15:21:10FromDiscord<leorize> then they're slightly different
15:21:30FromDiscord<yetiwizard> is there something equivalent to C++ classes? with implicit this pointer?
15:21:35FromDiscord<odexine> no
15:22:23FromDiscord<yetiwizard> hmm, ok, once I get around to creating these types I'll probs have more questions 😅
15:24:07FromDiscord<nervecenter> I'm trying to use IPC (specifically `execCmdEx`) to push some pretty large gnuplot scripts to a gnuplot process via stdin, and get an svg string via stdout. There are some scenarios, it seems like when the scripts are large, that gnuplot just hangs and doesn't do anything; I think I may have blocked a pipe limit for either stdin or stdout.↵↵Is there a more canonical way to do this? I know the documentation for `execCmdEx` warns ab
15:24:24FromDiscord<yetiwizard> but thanks y'all for now!
15:32:20FromDiscord<xtrayambak> What's a good way to replace a character in a string with a two characters?
15:33:31FromDiscord<starkiller1493> https://nim-lang.org/docs/strutils.html#replaceWord%2Cstring%2Cstring%2Cstring
15:33:46FromDiscord<starkiller1493> In reply to @xtrayambak "What's a good way": https://nim-lang.org/docs/strutils.html#replaceWord%2Cstring%2Cstring%2Cstring
15:34:30FromDiscord<xtrayambak> No, not that.
15:34:49FromDiscord<leorize> it'd be stdout because that proc doesn't consume stdout until the other program stops running↵(@nervecenter)
15:34:51FromDiscord<leorize> I'm building something that's better than osproc but it won't be ready anytime soon unfortunately
15:35:10FromDiscord<xtrayambak> I mean, as in, say,↵`"Nim is\tvery cool!"`↵how can I replace `\t` with `tab` ?
15:35:23FromDiscord<xtrayambak> Replacing strings with characters is easy, not vice versa though
15:35:48FromDiscord<leorize> replaceWord is how you do it, no?
15:36:26FromDiscord<xtrayambak> I don't think so
15:36:45FromDiscord<xtrayambak> `replaceWord('\t', "tab")` won't work, as it's a type mismatch
15:37:06FromDiscord<leorize> pass a string?
15:37:11FromDiscord<leorize> because "\\t" is a string with a single tab character
15:37:33FromDiscord<xtrayambak> That doesn't work either
15:37:42FromDiscord<xtrayambak> Hold up
15:37:44FromDiscord<xtrayambak> Aaaah
15:37:56FromDiscord<leorize> ah it only does it by word boundary
15:37:58FromDiscord<xtrayambak> Woops, my editor converts tabs to spaces. I forgot that was on and that's why it didn't work.
15:38:01FromDiscord<leorize> there's one that does general replacement
15:38:03FromDiscord<xtrayambak> 😅
15:38:10FromDiscord<leorize> like multi-replace
15:38:52FromDiscord<leorize> https://nim-lang.org/docs/strutils.html#multiReplace%2Cstring%2Cvarargs%5B%5D \<- this is what you'd want
15:39:10FromDiscord<nervecenter> In reply to @leorize "it'd be stdout because": Okay, is there a way I can use streams to consume stdout piecemeal, or something?
15:39:30FromDiscord<leorize> spawn a thread↵(@nervecenter)
15:41:30FromDiscord<jviega> False
15:42:07FromDiscord<jviega> You can totally deal w/ that problem w/o threads
15:42:55FromDiscord<jviega> You just need to only write PIPEBUF at a time, and then ensure the FD is ready to read again
15:43:05FromDiscord<jviega> To avoid the deadlock
15:43:51FromDiscord<jviega> Sorry, `PIPE_BUF`
15:44:28FromDiscord<leorize> the problem is that they also have to consume the output
15:44:42FromDiscord<jviega> So? I do it all the time. It's not hard.
15:44:52FromDiscord<jviega> select() or epoll() work fine in one thread
15:45:11FromDiscord<leorize> not when you want to do it nicely, but sure they do work
15:45:40FromDiscord<jviega> Sure when you want to do it nicely. I even have an abstraction that manages arbitrary n-way fd routing without threads
15:45:52FromDiscord<jviega> So you can do expect-like things w/ a pty
15:45:54FromDiscord<demotomohiro> In reply to @nervecenter "I'm trying to use": Maybe pipe buffer become full and write to stdin or stdout get blocked.↵Dividing input data to blocks smaller than piple buffer size and reading pipe after writing each blocks to child process's stdin might fix it.↵Or use asyncnet for IPC.
15:46:27FromDiscord<jviega> Yeah, PIPE_BUF is the size you're universally okay to write w/o deadlock whenever select signals a FD is available for write
15:47:00FromDiscord<jviega> People leap to threads these days the way people used to leap to OOP 🙂
15:53:52FromDiscord<leorize> unless you're on windows \:P
15:54:33FromDiscord<jviega> Yeah, I live in a concrete bunker... no Windows
15:54:43FromDiscord<jviega> Tho I suppose I'd support WSL
15:55:08FromDiscord<leorize> i'm building the abstractions needed for all that over here\: https://github.com/alaviss/nim-sys
15:55:17FromDiscord<leorize> but life is in the way right now so don't expect it to move fast
15:55:55FromDiscord<jviega> Cool, I am more about high level APIs for things but only caring about posix-compliance 🙂
15:56:45FromDiscord<jviega> high-level but flexible. Like the Nim subprocess stuff in the stdlibrary doesn't even let you separate stdout and stderr, never mind tee them off.
15:57:45FromDiscord<leorize> you'll love this stuff\: https://github.com/alaviss/nim-sys/blob/features/exec-prototype/src/sys/exec.nim#L30-L173
15:57:58FromDiscord<leorize> just a prototype api, nothing actually works and the code in that branch is super outdated
15:58:14FromDiscord<leorize> these days nim-sys don't use asyncdispatch anymore
15:59:09FromDiscord<jviega> Not bad, but my API is more like a generic switchboard, can accept listening sockets to add them to the mix, manage ptys, etc.
15:59:44FromDiscord<leorize> this is what I call that over here\: https://alaviss.github.io/nim-sys/ioqueue.html
16:00:53FromDiscord<jviega> Similar, but that's more low-level; my interface is more like Python's subprocess module
16:01:35FromDiscord<jviega> Whatever, those are both good tools too tho, the point is you def can easily do this stuff w/o threads. Only some kinds of programs where threads will be a net positive
16:03:38FromDiscord<leorize> and as to how it's used\: https://github.com/alaviss/nim-sys/blob/fe482b7c14acd53dc1ecbe75d8b6ab56cf86f068/src/sys/private/files_posix.nim#L58-L73
16:05:31FromDiscord<nervecenter> The fly in the ointment here is that I can't control gnuplot directly; I have to feed it an entire script, and then consume an entire SVG string from stdout. I can't control its behavior to stdout. Maybe I should just write my script to temporary file, invoke it to write the SVG to temporary file, and read that file when it quits. Probably easier.
16:05:38FromDiscord<jviega> Well, the ability to say, "I want both of these sources to be stdin for a pty, and to output to these 3 places" is not covered in any of that.
16:05:53FromDiscord<leorize> you write the code for that
16:06:00FromDiscord<leorize> code that looks exactly like blocking code
16:06:01FromDiscord<jviega> I did... once.
16:06:30FromDiscord<leorize> basically I'm building the backbone for something like goroutines
16:07:10FromDiscord<leorize> you don't need magical incantation to roll your queue and have it working in tandem with everything else
16:07:16FromDiscord<jviega> @nervecenter if gnuplot is causing a deadlock it's not reading what you're sending probably because it's waiting on a blocking write, which often is, you're not reading on stdin because you're trying to write
16:07:22FromDiscord<leorize> you write blocking code and it works equally well on bsd, linux and windows
16:08:00FromDiscord<jviega> Thus, if you don't want to learn select() or epoll() write PIPE_BUF size chunks to the pipe, then try to read before you write again.
16:08:17FromDiscord<jviega> As long as the read is non-blocking
16:08:31FromDiscord<jviega> Otherwise, you need to use select() or epoll() 🙂
16:49:20*derpydoo joined #nim
16:54:50FromDiscord<nervecenter> Switching to a temp file based solution worked well
17:14:04*advesperacit quit (Ping timeout: 272 seconds)
17:14:15FromDiscord<yetiwizard> sent a long message, see http://ix.io/4JvM
17:14:23*advesperacit joined #nim
17:15:05FromDiscord<yetiwizard> I'm trying to call sol2/sol3 functions from Nim
17:15:20FromDiscord<yetiwizard> it's a real pain lol
17:19:18*advesperacit quit (Ping timeout: 258 seconds)
17:19:33*advesperacit joined #nim
17:20:21*alphacentauri joined #nim
17:23:37FromDiscord<yetiwizard> I'm trying an alternative where instead I simply emit the whole c++ function, but now I'm having a problem accessing global variables from Nim as in the generated code the global variable is declared after the emitted function
17:30:21FromDiscord<griffith1deadly> sent a code paste, see https://play.nim-lang.org/#ix=4JvT
17:31:06FromDiscord<griffith1deadly> (edit) "https://paste.rs/d3sQU" => "https://play.nim-lang.org/#ix=4JvU"
17:35:08FromDiscord<yetiwizard> if I use `args: varargs[cstring]` it generates some extra arguments but still ends with `, ...` and no `Args... args`
17:36:56FromDiscord<leorize> you can't↵(@yetiwizard)
17:37:26FromDiscord<leorize> for templates you must include the header and import it using importcpp
17:39:48FromDiscord<yetiwizard> here's my second option
17:39:59FromDiscord<yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4JvW
17:40:50FromDiscord<yetiwizard> problem 1:↵in the same file I define↵`var lua {.exportc.}: SolState = SolState()`↵but in the generated code the definition for `lua` comes after the
17:41:11FromDiscord<yetiwizard> `LuaRunScriptClass`, so I tried using `extern sol::state lua;`, idk if that would work
17:42:11FromDiscord<yetiwizard> problem 2:↵in a different file I import the file that has `runLuaScriptClass`. Now the generated code doesn't forward declare `LuaRunScriptClass` and gcc complains error: 'LuaRunScriptClass' was not declared in this scope
17:43:25*junaid_ joined #nim
17:45:50*junaid_ quit (Remote host closed the connection)
17:46:26FromDiscord<leorize> it would, but don't put extern in↵(@yetiwizard)
17:47:29FromDiscord<yetiwizard> I already declared (in Nim) `var lua {.exportc.}: SolState = SolState()` in the same file. So without extern it compains about redefinition of `lua`
17:53:56*alphacentauri quit (Quit: WeeChat 4.1.0)
17:58:09*emery quit (Read error: Connection reset by peer)
17:58:40*ehmry joined #nim
18:04:04FromDiscord<yetiwizard> ok, seems the only option is really to move the LuaRunScriptClass in a separate header file
18:04:16FromDiscord<yetiwizard> I guess it does make sense tho lol
18:04:29FromDiscord<yetiwizard> why would I mix whole cpp functions in .nim files?
18:20:23NimEventerNew thread by ITwrx: No simple way to import files from dir recusively?, see https://forum.nim-lang.org/t/10561
19:28:01arkanoidI'm doing my best to understand how threading works in nim 2.0, and how it can be used safely, but so far, I'm only getting more and more confused. Do you have a good example where I can read what can be shared between threads and how?
19:29:55arkanoidI'm also failing with the basics. An isolated object with an int struct passed to createThread results in "Error: '=copy' is not available for type <Isolated>; requires a copy because it's not the last read of 'param'; try to make param a 'sink' parameter; routine: createThread"
19:56:18*azimut quit (Ping timeout: 256 seconds)
19:58:35*ehmry quit (Ping timeout: 240 seconds)
20:07:33NimEventerNew thread by dwhall256: Custom numeric literal, see https://forum.nim-lang.org/t/10562
20:15:42FromDiscord<Elegantbeef> Arkanoid sharing refs between threads is a very annoying prospect presently
20:17:39FromDiscord<Elegantbeef> Atomic arc reduces some of the headaches, but it's bleh
20:17:58FromDiscord<Chronos [She/Her]> Hm anyone know if there's a URL validator in Nim's stdlib?
20:18:22FromDiscord<Elegantbeef> `std/uri`?
20:18:45FromDiscord<Chronos [She/Her]> Doesn't have validation, just parsing
20:18:59FromDiscord<Chronos [She/Her]> Wait
20:19:05FromDiscord<Elegantbeef> What does that even mean, if it parses it's a valid uri
20:19:08FromDiscord<Chronos [She/Her]> I'm dumb
20:19:12FromDiscord<Chronos [She/Her]> Security validation
20:19:28FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "What does that even": My illiterate brain strikes again...? :p
20:19:42*xet7 quit (Quit: Leaving)
20:19:56FromDiscord<Elegantbeef> "Security validation" Flammable fire, I can put two words that sound related together aswell 😄
20:20:17FromDiscord<jviega> You mean you want to check the x509 cert of the server?
20:21:40FromDiscord<Chronos [She/Her]> No, just meant that the URL isn't malformed :p
20:21:56FromDiscord<Chronos [She/Her]> Though, can't find any errors that it'd raise on invalid URLs?
20:22:22FromDiscord<Chronos [She/Her]> Obviously `UriParseError` but where in the body exactly is it raised?
20:22:24FromDiscord<jviega> Yeah, the uri module will do well for you on that
20:22:47FromDiscord<jviega> 🤷 but it works 🙂
20:22:47FromDiscord<Elegantbeef> Wait all the URI procs are `raises:[]` 😄
20:23:03FromDiscord<Chronos [She/Her]> Here https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/uri.nim#L201 but only for queries
20:23:47FromDiscord<Chronos [She/Her]> Oh well
20:25:13FromDiscord<Chronos [She/Her]> Also being able to await multiple futures at once would be useful :p
20:25:19FromDiscord<Chronos [She/Her]> Oh well
20:25:23FromDiscord<Elegantbeef> `all` exists
20:26:21FromDiscord<Chronos [She/Her]> Oh
20:30:48FromDiscord<.aingel.> How would I alloc a cstring buffer?
20:31:00FromDiscord<Elegantbeef> Depends what you need it for
20:31:20FromDiscord<Elegantbeef> you can just do `var myString = newString(size); myProcthatWantsCstring(cstring myString)`
20:33:41*rockcavera quit (Ping timeout: 260 seconds)
20:35:46FromDiscord<.aingel.> Gotcha
20:38:07FromDiscord<Chronos [She/Her]> Trying to make a small reproducable example to get help with an issue with my code but playground kills this :/
20:38:08FromDiscord<Chronos [She/Her]> https://play.nim-lang.org/#ix=4JwJ
20:38:22*rockcavera joined #nim
20:38:23*rockcavera quit (Changing host)
20:38:23*rockcavera joined #nim
20:38:24FromDiscord<Chronos [She/Her]> sent a long message, see http://ix.io/4JwL
20:38:47FromDiscord<Chronos [She/Her]> Doesn't seem to be working
20:39:04FromDiscord<Elegantbeef> Why do you have a lock
20:39:04FromDiscord<Elegantbeef> This is asynch
20:39:20FromDiscord<Chronos [She/Her]> Do I not need a lock? :p
20:39:50FromDiscord<Chronos [She/Her]> In reply to @chronos.vitaqua "!eval import std/[locks, asyncdispatch]": Running the code locally has no issues anyway
20:40:12FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Why do you have": Would you believe me if I called it practice? :p
20:41:41FromDiscord<Chronos [She/Her]> For my actual issue
20:41:53FromDiscord<Elegantbeef> Of course you do not need a lock
20:41:54FromDiscord<Elegantbeef> This is async code
20:41:54FromDiscord<Elegantbeef> Only one thread is active at a time
20:41:55FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4JwM
20:42:07FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4JwN
20:43:32FromDiscord<Chronos [She/Her]> Fair, I'll do that then, but I still have the issue of none of the files downloading nor being added to my 'Collection' object (my code is similar to the above but has stuff like downloading)
20:44:26FromDiscord<Chronos [She/Her]> I'd send the code but it's 300 lines :p
20:44:47FromDiscord<Chronos [She/Her]> And needs a JSON file that has personal info and would be too long to recreate
20:45:54FromDiscord<Elegantbeef> Well with all these caveats I'll just go for a snide remark of "Heh l4rn async"
20:46:32FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4JwO
20:46:58FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4JwP
20:47:22FromDiscord<Elegantbeef> How many requests are you making?
20:47:37FromDiscord<Chronos [She/Her]> Over 100? :p
20:47:50FromDiscord<Chronos [She/Her]> With 4 different async http clients
20:47:53FromDiscord<Elegantbeef> Are you saturating your file handles by anychance?
20:47:56FromDiscord<Chronos [She/Her]> But none of them getdownloaded
20:48:11FromDiscord<Elegantbeef> I also don't know if you can share http clients
20:48:59FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Are you saturating your": Probably, I could await like, 4 at a time instead maybe?
20:50:47FromDiscord<jviega> "Over 100" then you probably are.
20:51:07FromDiscord<jviega> I think on most systems the default process fd limit is not much higher than that
20:52:04FromDiscord<jviega> Tho it's been a long time since I've checked, so memory may be bad. Still, it's best practice to manage carefully
20:52:16FromDiscord<jviega> Don't let them grow unbounded for sure
20:55:04*Guest70 joined #nim
20:55:41*Guest70 quit (Client Quit)
20:55:50FromDiscord<Chronos [She/Her]> Not sure how I'm supposed to stop this tbh, since all the futures get ran anyway
20:56:04FromDiscord<Chronos [She/Her]> Like, instantly
20:57:46FromDiscord<Chronos [She/Her]> Maybe I should do this synchronously...
20:58:34FromDiscord<Chronos [She/Her]> That way, everything will be done one at a time even if it's not ideal
20:58:41FromDiscord<Elegantbeef> Nah just require the OS to have more file handles!
20:58:53FromDiscord<Elegantbeef> That doesnt solve anything here
20:59:14FromDiscord<Elegantbeef> Async is already doing things at one time
20:59:19FromDiscord<Elegantbeef> It's still single threaded
20:59:47FromDiscord<Chronos [She/Her]> Ah
21:00:00FromDiscord<jviega> Just muddies your control flow, makes it prone to odd ordering side effects, and is susceptible to unfair scheduing
21:00:22FromDiscord<Chronos [She/Her]> Then I'm completely lost... For some reason all of the echo statements in the procs get executed at once which confuses me
21:01:00FromDiscord<Elegantbeef> They don't get executed at one time, the async proc is ran until the first await then gives up to the next read async proc
21:01:04FromDiscord<jviega> "muddies your control flow" ftw
21:01:32FromDiscord<Elegantbeef> Async is just an explicit CPU scheduling
21:01:51FromDiscord<Chronos [She/Her]> Aah
21:02:01FromDiscord<Elegantbeef> `await` `poll` `waitfor` and a few other things give up your CPU to handle all waiting for processess
21:02:28FromDiscord<Elegantbeef> So if you write an async proc without using any async methods it's ran to completion when it's called
21:04:09FromDiscord<jviega> An explicit CPU scheduling that requires the user to context switch, leading to unfair scheduling and bizzare bugs when random, otherwise unrelated parts of the code change due to semantics accidentally depending on a previous deterministic ordering
21:05:15FromDiscord<Elegantbeef> I rarely use async, but when I do it's purely sensible! 😄
21:06:29FromDiscord<jviega> In my view, if people don't want fully sequential, then just get over your fears and use threads, the world will be better off for it
21:06:45FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "So if you write": That makes sense
21:06:51FromDiscord<Chronos [She/Her]> In reply to @jviega "In my view, if": I may do that :p
21:06:52FromDiscord<Chronos [She/Her]> https://play.nim-lang.org/#ix=4JwT
21:06:54FromDiscord<Elegantbeef> Just use selectors and manually do it 😛
21:06:57FromDiscord<Chronos [She/Her]> This is my code atm
21:07:08FromDiscord<Elegantbeef> TLDR
21:07:17FromDiscord<Chronos [She/Her]> Yeah :p
21:07:24FromDiscord<Elegantbeef> So many locks
21:07:35FromDiscord<Chronos [She/Her]> :p
21:07:44FromDiscord<Elegantbeef> People really will throw whatever they have at the wall and hope it sticks
21:07:50FromDiscord<Chronos [She/Her]> Yep
21:08:34FromDiscord<Chronos [She/Her]> I had the misconception of thinking async works somewhat similarly to threading but I clearly didn't use the pound of fat in my head
21:08:43FromDiscord<jviega> async 100% encourages that. Randomly sprinkle "async" and "await" until they work
21:09:17FromDiscord<leorize> we had an entire RFC about building something better
21:10:00FromDiscord<Elegantbeef> Hey selectors arent hard to use!
21:10:56FromDiscord<jviega> Every async system I've ever seen has similar problems. I think better UXs around threads are more reasonable. goroutine-style funcs + lock free data structures aren't a bad start
21:11:12FromDiscord<leorize> cue cps
21:11:19FromDiscord<jviega> csp?
21:11:40FromDiscord<leorize> no, continuation passing style
21:11:47FromDiscord<Elegantbeef> See as someone that does not do any amount of concurrency arent async and goroutines both green threads?
21:11:50FromDiscord<jviega> Oh, yeah, I guess
21:12:17FromDiscord<jviega> goroutines are basically threads. fair scheduling.
21:12:26FromDiscord<leorize> async is M\:1
21:12:31FromDiscord<leorize> goroutines is M\:N
21:12:47FromDiscord<Elegantbeef> You can use fancy notations but if you don't tell me what the notation is it doesnt help
21:13:01FromDiscord<leorize> async runs M threads on 1 real thread
21:13:06FromDiscord<jviega> continuation passing style is fine, tho have also seen people have a hard time wrapping their heads around it
21:13:07FromDiscord<leorize> goroutines does it on N threads
21:13:08FromDiscord<Elegantbeef> Ah there you
21:13:24FromDiscord<Elegantbeef> go
21:13:49FromDiscord<leorize> probably why nim cps doesn't gain traction
21:13:55FromDiscord<jviega> Yup
21:14:40FromDiscord<leorize> well we already built it and it works
21:14:48FromDiscord<leorize> but kinda useless if no one uses it
21:15:20FromDiscord<Elegantbeef> Clearly async has the same issues
21:15:47FromDiscord<Elegantbeef> People do not understand that it's all just practically wait condition that is met and code is continued after giving up the cpu
21:16:03FromDiscord<Elegantbeef> Same educational issues I mean
21:16:05FromDiscord<jviega> Oh yeah, the problem with async models is they SEEM easy; often is easy to get basic stuff working. Then people end up fighting heisenbugs that make no sense forever
21:16:09FromDiscord<jviega> CPS looks hard
21:17:02FromDiscord<leorize> building event queues for cps has been the most pleasant experience for me compared to trying to hack something for asyncdispatch
21:17:27FromDiscord<leorize> but then again, I am one of the authors so very biased
21:18:47FromDiscord<jviega> I prefer to try to find the most appropriate abstractions that future readers will be able to pick up. I lost my hipster creds almost 30 years ago
21:19:39FromDiscord<leorize> funny enough cps is gaining traction everywhere but nim
21:20:19FromDiscord<jviega> Yeah but doesn't make it less hipster
21:20:21*alice quit (Remote host closed the connection)
21:20:34FromDiscord<jviega> It does have some technical advantages as a compiler implementation approach
21:20:44FromDiscord<jviega> But for end users, 🤷
21:22:10FromDiscord<leorize> everyone loves goroutines but no one wants to build it ig
21:22:34FromDiscord<jviega> I mean, I'm fine w/ threads. It's cool to reserve a core or two for something else but not crucial
21:22:42*alice joined #nim
21:22:51FromDiscord<jviega> Otherwise we'd all be using OpenBSD
21:30:34FromDiscord<Chronos [She/Her]> Idk how to go about using threads here tbh
21:48:14FromDiscord<Chronos [She/Her]> Oh hey I did it
21:48:45FromDiscord<Chronos [She/Her]> I had to cast my proc as gcsafe tho despite it being gcsafe (at least, looked like it? I used locks on any globals)
21:48:51FromDiscord<Chronos [She/Her]> My program is working perfectly
21:50:08FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Jx2
22:11:49*advesperacit quit ()
22:23:17FromDiscord<Chronos [She/Her]> Hey, I think I'm doing threading somewhat alright? :p
22:23:35FromDiscord<Chronos [She/Her]> No crashes besides that one at the end, testing with arc now
22:30:20*derpydoo quit (Read error: Network is unreachable)
22:37:57FromDiscord<Elegantbeef> There is no analysis to check that it's safe you have to override the compiler
22:37:59FromDiscord<Elegantbeef> Nim doesnt care that you use locks accessing global variables is gc unsafe 😄↵(@Chronos [She/Her])
22:39:08FromDiscord<Chronos [She/Her]> Damn
22:39:28FromDiscord<Chronos [She/Her]> Not sure how I'd inform the compiler that accessing them is indeed safe-
22:39:39FromDiscord<Elegantbeef> `{.cast(gcsafe).}`
22:40:32arkanoiddo you know if there's an RCU implementation for Nim? https://en.wikipedia.org/wiki/Read-copy-update
22:40:35FromDiscord<Elegantbeef> If you want to avoid using a global either use `ptr T` or return additions
22:42:01FromDiscord<Elegantbeef> I don't even know what RCU is, never mind an implementation of it
22:44:15arkanoidElegantbeef, it's like the most common non-blocking algorithm for a shared data structure. The Linux kernel is full of these, and BSD kinda also
22:45:11FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "`{.cast(gcsafe).}`": On the variable?
22:45:23FromDiscord<Chronos [She/Her]> On the proc it doesn't work
22:45:41FromDiscord<Chronos [She/Her]> Unless you mean to use it like `{.cast(gcsafe).}:` and but the body in there
22:48:18FromDiscord<Elegantbeef> Yes
22:48:21FromDiscord<Elegantbeef> The latter
22:49:34FromDiscord<Chronos [She/Her]> Gucci
22:59:16arkanoidElegantbeef, this is where I tend to land when trying to understand what RCU is, if you are curious about it: https://mirrors.edge.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.2023.06.11a.pdf
23:05:07FromDiscord<Chronos [She/Her]> Code works perfectly with arc :)
23:05:29FromDiscord<Elegantbeef> I've had birds fly over my head lower than that whitepaper
23:07:48arkanoidElegantbeef, haha, well, kinda same, but it's nice to know that solutions do exist
23:08:21arkanoidhttps://liburcu.org/
23:08:46FromDiscord<Elegantbeef> Reading further it's not too bad afaict
23:09:37FromDiscord<Elegantbeef> On a linkedlist it seems to mostly just be an atomic that stores the next element. When removing you just wait a few seconds to free the to be deleted object
23:10:58FromDiscord<Elegantbeef> I say a few seconds, but of course I mean when the refcount is 0
23:15:29FromDiscord<Elegantbeef> Does seem like a fun problem to use type states on
23:18:54arkanoidtype states?
23:19:24FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/9976#65763
23:19:49FromDiscord<Elegantbeef> In the case of a RCU'd linked list you'd have a `RCU[Readable: static bool]` or similar
23:20:08FromDiscord<Elegantbeef> Sorry that should be `Writable`
23:20:35FromDiscord<Elegantbeef> It'd only be `RCU[true]` in the case you do `myRcu.waitForAll()`
23:20:57FromDiscord<Elegantbeef> Actually sorry again, it'd not be writable, but reclaimable
23:25:04arkanoidwait this is going one abstraction layer over my current capacity
23:25:39arkanoida typeclass argument is already compile time, what does a "static" add?
23:25:41*lumo_e joined #nim
23:25:49FromDiscord<Elegantbeef> You encode runtime information into the state of an object, this statically prevents you from misgivings
23:25:57FromDiscord<Elegantbeef> `static T` encodes data to a type
23:26:30arkanoidlet le re-read, slowly
23:31:17arkanoidI understand the meaning, but I don't get the advantage. It feels like some kind of effect tracking to get some flexible checks at compile time
23:31:40FromDiscord<Elegantbeef> I mean it encodes runtime information into the type system
23:31:41FromDiscord<Elegantbeef> Static typing is king
23:32:47arkanoidI would like to learn much more about how to use static typing to design/scaffold better software
23:37:26arkanoidcan I go one layer even more classtyping typeclasses? Foo[TBar: static Option[Foo2[Tbaz: static bool]]] ?
23:38:11FromDiscord<Elegantbeef> If you wanted to
23:38:12FromDiscord<Elegantbeef> You can use any type inside a static
23:38:12FromDiscord<Elegantbeef> Aslong as you can define it at compile time
23:40:46arkanoidwould be nice to challenge https://zackoverflow.dev/writing/flappy-bird-in-type-level-typescript/
23:50:49FromDiscord<Elegantbeef> Actually playing around with implementing it shows that it doesnt add much
23:51:02FromDiscord<Elegantbeef> Atleast in this case
23:51:07FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4Jxf if curious
23:53:21arkanoidwait what? how you went from non knowing what it is, to implement a version of it, in 45 minutes?!
23:53:39FromDiscord<Elegantbeef> No clue
23:54:05FromDiscord<Elegantbeef> When you don't know what you're doing you can pretend to do a lot
23:54:37FromDiscord<Elegantbeef> I don't even think I implemented it properly though given that the output is the same for all threads
23:54:40FromDiscord<Elegantbeef> Expected it to differ
23:54:47FromDiscord<Elegantbeef> Plus it didnt remove all modulo 10s
23:55:07FromDiscord<Elegantbeef> Oh found the issue
23:55:12FromDiscord<Elegantbeef> `x.parent.next = x.next`
23:55:51FromDiscord<Elegantbeef> There we go
23:55:59FromDiscord<Elegantbeef> Diff has been successful
23:56:28arkanoid:| you make me feel very stupid
23:56:49FromDiscord<Elegantbeef> Sorry I'll put less effort in
23:57:17arkanoidwhere did you find such a clear vision of it? is it in the whitepaper?
23:57:25FromDiscord<Elegantbeef> Nope
23:57:45FromDiscord<Elegantbeef> https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html#rcu-overview
23:58:07FromDiscord<Elegantbeef> Much better than the whitepaper
23:58:30FromDiscord<Elegantbeef> Reading the first two paragraphs explained everything I needed
23:58:38*ehmry joined #nim
23:59:17FromDiscord<Elegantbeef> Separation of freeing and replacing -\> wait until all consumers are done -\> actually free memory