00:05:21 | FromDiscord | <girvo> What about `nimble install --link`? Is that similar in semantics to how nimble develop used to work? |
00:08:00 | FromDiscord | <girvo> (Not that it matters, we're using --path now! but my teammate was curious) |
00:10:52 | FromDiscord | <Elegantbeef> No clue after nimble develop failed to work I've just moved to atlas |
00:23:05 | * | koltrast joined #nim |
00:27:03 | FromDiscord | <sOkam! 🫐> same |
00:31:08 | FromDiscord | <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:19 | FromDiscord | <sOkam! 🫐> the directory can be the workspace, afaik |
00:35:24 | FromDiscord | <Elegantbeef> you can make a deps folder |
00:36:03 | FromDiscord | <Elegantbeef> `atlas init --deps=deps` dumps all your deps inside the `deps` folder |
00:39:42 | FromDiscord | <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:51 | FromDiscord | <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:22 | FromDiscord | <leorize> it is the allocated size |
00:40:22 | FromDiscord | <Elegantbeef> How big the allocation is |
00:40:40 | FromDiscord | <Elegantbeef> How many elements there are presently allocated but it does not mean presently used |
00:40:56 | FromDiscord | <Elegantbeef> Nim's seq/string follow most standard strings where you allocate more than you need often |
00:53:52 | FromDiscord | <odexine> It stands for “capacity” |
00:58:40 | FromDiscord | <girvo> `newStringOfCap` is super useful for reducing uneccesary `realloc0` calls |
01:00:45 | FromDiscord | <leorize> and not to mention that nim's realloc is always malloc + copy |
01:55:21 | * | lumo_e quit (Quit: Quit) |
02:55:28 | FromDiscord | <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:51 | FromDiscord | <Elegantbeef> I'd argue it's ambiguous |
02:57:23 | FromDiscord | <leorize> that one shouldn't be though? |
02:57:41 | FromDiscord | <Elegantbeef> Should it be `2` or `1 + epsilon` 😄 |
02:59:38 | FromDiscord | <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:37 | FromDiscord | <sOkam! 🫐> kk |
03:09:50 | * | derpydoo quit (Read error: Connection reset by peer) |
03:17:39 | FromDiscord | <odexine> Ah yes the 53 bit integer precision problem kinda thing |
03:18:01 | FromDiscord | <Elegantbeef> Not an issue with my `inc` implementation |
03:18:31 | FromDiscord | <Elegantbeef> In my version `x == y` only works when `x` is inf |
03:25:09 | FromDiscord | <odexine> “Your implementation”? Where |
03:25:21 | FromDiscord | <Elegantbeef> My hypothetical one |
03:25:27 | FromDiscord | <Elegantbeef> Where it increments with epsilon |
03:25:50 | FromDiscord | <odexine> Well sure but that’s not really better |
03:26:07 | FromDiscord | <odexine> Because now increment isn’t exactly consistent or even useful |
03:26:50 | FromDiscord | <Elegantbeef> It's consistent, each gives you the next value 😛 |
03:35:59 | FromDiscord | <odexine> Okay, then the interval is not numerically equal for all values |
03:50:22 | FromDiscord | <Elegantbeef> Hey I'm never helpful |
05:29:25 | FromDiscord | <nasuray> sent a long message, see http://ix.io/4JsW |
05:31:11 | FromDiscord | <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:38 | FromDiscord | <wick3dr0se> But trying to connect via remote IP with a client doesn't work |
05:33:19 | FromDiscord | <leorize> you can listen on your public IP |
05:33:42 | FromDiscord | <leorize> but check your firewall |
05:34:17 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/d2Rrs |
05:34:43 | FromDiscord | <leorize> maybe you can try disruptek/nimph↵(@nasuray) |
05:46:40 | FromDiscord | <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:56 | FromDiscord | <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:55 | FromDiscord | <wick3dr0se> In reply to @leorize "but check your firewall": I dont have a firewall installed. Maybe router issue then.. 🫠 |
05:52:09 | FromDiscord | <Elegantbeef> How is atlas any more of a pain over Nimble? |
05:56:04 | FromDiscord | <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:03 | FromDiscord | <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:12 | FromDiscord | <wick3dr0se> (edit) "I'n" => "I'm" |
06:07:55 | FromDiscord | <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:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Jt8 |
06:10:47 | FromDiscord | <Elegantbeef> That's all that's required for figuro's setup |
06:15:05 | FromDiscord | <sOkam! 🫐> how is that easier than a list of requires? |
06:15:45 | FromDiscord | <Elegantbeef> 2 commands is hardly painful, but I guess YMMV |
06:16:14 | FromDiscord | <sOkam! 🫐> i can see 4-5 without including the atlas installation |
06:16:17 | FromDiscord | <Elegantbeef> It does generate the requires for you |
06:16:33 | FromDiscord | <sOkam! 🫐> i mean, its still better than nimble develop, which cannot be distributed |
06:16:33 | FromDiscord | <Elegantbeef> That's also not distribution I guess |
06:16:56 | FromDiscord | <Elegantbeef> Atlas is capable of making your nimble requires you just `include` afaik |
06:17:25 | FromDiscord | <sOkam! 🫐> don't know if I understood what that meant |
06:17:49 | FromDiscord | <Elegantbeef> Well actually in default setup it just adds `requires "..."` to any urls you `atlas use x` |
06:18:16 | FromDiscord | <Elegantbeef> Like it made a `locker.nimble` and added a requires for truss3D from me 'using' it |
06:22:42 | FromDiscord | <Elegantbeef> Though I guess it does not tag a version, so that's not ideal |
06:23:36 | * | Guest12 joined #nim |
06:23:59 | FromDiscord | <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:32 | FromDiscord | <Elegantbeef> Why can't you? |
06:24:38 | * | Guest12 quit (Client Quit) |
06:26:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Jta |
06:26:12 | FromDiscord | <Elegantbeef> all I did was `atlas install test.nimble` |
06:30:38 | FromDiscord | <Elegantbeef> Well after `atlas init --deps=.deps` of course |
06:32:43 | FromDiscord | <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:04 | FromDiscord | <Elegantbeef> Always takes falling down stairs and breaking your arm to learn to record it first 😛 |
06:35:16 | FromDiscord | <nasuray> Granted in the middle I did install from `atlas#head`, so could be that lol |
06:36:12 | FromDiscord | <Elegantbeef> Who knows |
06:38:14 | FromDiscord | <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:45 | FromDiscord | <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:49 | FromDiscord | <Chronos [She/Her]> (edit) ":0" => ":p" |
06:53:13 | * | PMunch joined #nim |
06:54:36 | FromDiscord | <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:58 | FromDiscord | <muchamadyja> Is there any channel or server that i can asking about beginner question? |
08:02:15 | PMunch | Apart from this one? |
08:02:24 | FromDiscord | <muchamadyja> Im newbie in here btw |
08:02:48 | PMunch | Oh right, feel free to ask beginner questions here :) |
08:03:09 | PMunch | Of course try to google stuff first though |
08:04:08 | FromDiscord | <muchamadyja> wait, I thought you were a bot account 😅 |
08:04:57 | PMunch | Common misconception, there's a bot which relays messages from other channels to this one :) |
08:10:51 | FromDiscord | <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:34 | FromDiscord | <odexine> Nope, this is the right one |
08:16:54 | PMunch | Yes you've definitely come to the right place :) |
08:22:20 | FromDiscord | <muchamadyja> |
08:29:07 | FromDiscord | <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:21 | FromDiscord | <nnsee> for some reason, it's not doing so anymore |
08:29:28 | FromDiscord | <nnsee> and I can't figure out why |
08:30:56 | Amun-Ra | yes, it should |
08:31:29 | Amun-Ra | insert a bogus text into nim.cfg and rerun nimble |
08:31:47 | Amun-Ra | perhaps something overrides those flags in the other file? |
08:42:28 | FromDiscord | <nnsee> thanks |
08:42:36 | FromDiscord | <nnsee> turns out i was just being stupid and mistyping a flag |
08:43:33 | PMunch | Easy error to make |
08:43:42 | PMunch | Also note that some flags don't work in the nim.cfg file |
08:43:51 | PMunch | For example you can't have `-d:release` in there I believe |
08:46:08 | NimEventer | New thread by oyster: 2 questions on StringStream, see https://forum.nim-lang.org/t/10559 |
08:48:33 | FromDiscord | <Phil> Stuff like this is why I just do nimble tasks, seems to fit my mental model more |
08:49:37 | FromDiscord | <Elegantbeef> Pmunch that's an old issue release flags now work from config files |
08:54:22 | FromDiscord | <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:39 | FromDiscord | <Elegantbeef> It was an old issue in like 1.2 and before |
08:54:43 | FromDiscord | <Elegantbeef> Might even be 1.4 and before |
08:57:41 | PMunch | Oh, I just assumed it was a feature |
08:57:51 | PMunch | But nice to see that it has been fixed :) |
08:58:10 | PMunch | I guess I should update Ratel then to use `-d:danger` by default |
09:28:09 | FromDiscord | <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:50 | FromDiscord | <nnsee> (because they don't follow my logging spec at all, and my log collector alerts me on malformed log entries 😅) |
09:33:13 | PMunch | Yup |
09:33:37 | PMunch | https://github.com/PMunch/echooverride |
09:34:26 | PMunch | It uses term-rewriting macros and the `--import` statement to inject it into every module |
09:35:35 | NimEventer | New 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:47 | FromDiscord | <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:53 | FromDiscord | <Chronos [She/Her]> In reply to @NimEventer "New thread by ingo:": I don't understand this hm |
09:51:08 | FromDiscord | <Chronos [She/Her]> In reply to @ieltan "Hey guys, just wondering:": I'd imagine so, yeah |
09:51:26 | FromDiscord | <ieltan> To be more specific, can I use `var T` as a clever trick to pass pointers to C wrapped procs ? |
09:52:06 | FromDiscord | <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:31 | Amun-Ra | ieltan: I was doing just that on nim 1.x to avoid using usafeaddr; you don't have to do that in nim2 |
09:52:53 | FromDiscord | <ieltan> Yes I know, I know how to manage C memory don't worry (famous last words innit) |
09:53:07 | Amun-Ra | ;> |
09:54:17 | FromDiscord | <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:34 | Amun-Ra | ieltan: no |
09:55:07 | FromDiscord | <ieltan> Oh, I see what you're talking about |
09:55:16 | FromDiscord | <ieltan> sorry, the `unsafeaddr` part confused me |
09:55:24 | FromDiscord | <ieltan> never heard of it |
09:55:30 | FromDiscord | <ieltan> what does it do ? |
09:56:08 | Amun-Ra | it allows convertion from non-var T to ptr T |
09:56:14 | Amun-Ra | conversion* |
09:56:31 | Amun-Ra | it's deprecated in nim2 |
09:57:59 | FromDiscord | <ieltan> i see, welp thanks 🙂 |
10:04:18 | Amun-Ra | hmm, what does that do? https://nim-lang.org/docs/system.html#%7C%2Ctypedesc%2Ctypedesc |
10:04:32 | Amun-Ra | proc `|`*(a, b: typedesc): typedesc = discard |
10:05:27 | FromDiscord | <ieltan> makes a typeclass afaik, the same as `type SomeType = OtherType or NotherType` |
10:05:57 | Amun-Ra | ah, right |
10:06:05 | Amun-Ra | I use `or` |
10:06:29 | Amun-Ra | I completely forgot about that alternative |
10:16:29 | * | arkanoid quit (Ping timeout: 258 seconds) |
10:18:29 | * | arkanoid joined #nim |
10:28:44 | FromDiscord | <nnsee> In reply to @PMunch "https://github.com/PMunch/echooverride": thanks! |
10:29:39 | FromDiscord | <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:15 | PMunch | It appears that Nim devel was 1.9.1 when that was written, so 2.0.0 should work I believe |
10:30:50 | FromDiscord | <nnsee> also, does it require refc? seems like it from the nim.cfg |
10:31:48 | PMunch | I think that was a bug in that version of devel |
10:31:54 | PMunch | But you can just try it out and see |
10:32:54 | PMunch | Oh right, it's the ORC httpbeast bug that requires refc I believe |
10:45:38 | PMunch | Yeah, replacing it with `-d:useStdLib` makes it work as well |
10:46:47 | PMunch | The 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:34 | FromDiscord | <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:47 | FromDiscord | <nnsee> is this bug |
11:18:15 | PMunch | https://github.com/dom96/httpbeast/issues/90 |
11:32:11 | PMunch | Is there a way to have `d:ssl` defined in my library? |
11:32:18 | PMunch | I guess a nim.cfg file would do the trick |
11:32:33 | PMunch | But it's a bit annoying to have another file just for this purpose |
11:34:17 | FromDiscord | <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:41 | PMunch | Ooh, I had ssl in quotes and it didn't work |
11:35:46 | PMunch | My bad |
12:15:29 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Ju1 |
12:15:50 | FromDiscord | <yetiwizard> what's the correct way to do it? |
12:20:00 | PMunch | The error is probably just in the expected assembly format |
12:35:36 | FromDiscord | <yetiwizard> what's the correct format? |
12:52:21 | PMunch | Depends on your compiler |
12:58:36 | FromDiscord | <yetiwizard> nim cpp --cpu:i386 using mingw32 |
13:05:30 | FromDiscord | <yetiwizard> I tried adding --passC-masm=intel but it doesn't work |
13:05:40 | FromDiscord | <yetiwizard> (edit) "--passC-masm=intel" => "--passC:-masm=intel" |
13:12:25 | FromDiscord | <yetiwizard> now it doesn't like the ↵mov `zone`, eax↵part |
13:13:03 | FromDiscord | <Chronos [She/Her]> Maybe do zone without the backticks? |
13:13:45 | PMunch | I believe the point of the backticks is to pull in the reference from Nim |
13:13:46 | FromDiscord | <yetiwizard> that worked in VS with C++, but here it doesn't compile |
13:13:54 | FromDiscord | <Chronos [She/Her]> Also `exportc` the variable |
13:14:05 | FromDiscord | <Chronos [She/Her]> In reply to @PMunch "I believe the point": Hm |
13:14:22 | FromDiscord | <Chronos [She/Her]> Then no idea |
13:14:30 | FromDiscord | <Chronos [She/Her]> You could emit the c++ code directly tbf |
13:15:02 | PMunch | Haha, that's a bit of a hack |
13:15:16 | PMunch | It should be possible with Nim directly |
13:15:23 | FromDiscord | <Chronos [She/Her]> Trye |
13:15:31 | FromDiscord | <Chronos [She/Her]> But if you need to get it working asap |
13:17:30 | FromDiscord | <yetiwizard> In reply to @chronos.vitaqua "Also `exportc` the variable": you mean like `var zone {.exportc.}: pointer = nil`? |
13:18:15 | FromDiscord | <Chronos [She/Her]> Yeah |
13:18:21 | FromDiscord | <Chronos [She/Her]> But it probably won't do anything |
13:19:36 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jug |
13:19:38 | FromDiscord | <yetiwizard> maybe NIM_NIL is the problem |
13:27:45 | FromDiscord | <Chronos [She/Her]> Ah that may be it |
13:28:25 | FromDiscord | <Chronos [She/Her]> Not sure, could you find what `NIM_NIL` is assigned to? |
13:31:28 | FromDiscord | <yetiwizard> there is no assignment to NIM_NIL in the generated code. Or is it in some other file? |
13:33:48 | FromDiscord | <Chronos [She/Her]> It may be in `nimbase.h` |
13:34:59 | FromDiscord | <Chronos [She/Her]> https://github.com/nim-lang/Nim/blob/devel/lib/nimbase.h#L326 |
13:35:01 | FromDiscord | <Chronos [She/Her]> @yetiwizard |
13:35:37 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Juo |
13:35:46 | FromDiscord | <yetiwizard> getting `zone` in there is the problem |
13:35:55 | FromDiscord | <Chronos [She/Her]> Why _zone? |
13:36:04 | FromDiscord | <yetiwizard> just trying everything I can find online |
13:36:09 | FromDiscord | <Chronos [She/Her]> Hm |
13:36:24 | FromDiscord | <Chronos [She/Her]> Does emitting the C++ code fix the issue completely? |
13:36:41 | FromDiscord | <yetiwizard> no, reading zone is still not working |
13:36:47 | FromDiscord | <yetiwizard> gcc complains about the syntax |
13:36:52 | FromDiscord | <Chronos [She/Her]> In reply to @yetiwizard "I'm trying to port": Even with copy pasting this? |
13:37:02 | FromDiscord | <yetiwizard> yea |
13:37:03 | FromDiscord | <Chronos [She/Her]> Are you using the C++ backend or the C backend? |
13:38:00 | FromDiscord | <yetiwizard> c++ |
13:38:12 | FromDiscord | <Chronos [She/Her]> Hm, then I am absolutely clueless, sorry |
13:38:43 | FromDiscord | <yetiwizard> thanks anyways. I'll keep trying some more until I pull my hair out |
13:39:49 | FromDiscord | <Chronos [She/Her]> Wishing you good luck! |
13:44:15 | FromDiscord | <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:16 | FromDiscord | <leorize> as long as you don't use other async code |
13:55:51 | FromDiscord | <Chronos [She/Her]> Such as asyncnet? |
13:56:16 | * | alphacentauri quit (Quit: WeeChat 4.1.0) |
13:56:24 | FromDiscord | <leorize> yea |
13:56:32 | FromDiscord | <leorize> you gotta fully buy into the chronos ecosystem |
13:57:19 | FromDiscord | <Chronos [She/Her]> Gucci |
13:57:37 | FromDiscord | <Chronos [She/Her]> Though I wonder if just making asyncnet use chronos instead of asyncdispatch would work :p |
13:57:39 | FromDiscord | <Chronos [She/Her]> Probably not |
14:00:57 | FromDiscord | <leorize> chronos already come with better asyncnet |
14:01:07 | FromDiscord | <leorize> why would you bother trying to use asyncnet |
14:03:35 | FromDiscord | <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:40 | FromDiscord | <Chronos [She/Her]> Basically anyio hut for Nim |
14:22:52 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4JuD |
14:23:08 | FromDiscord | <yetiwizard> (edit) "https://play.nim-lang.org/#ix=4JuD" => "https://play.nim-lang.org/#ix=4JuE" |
14:23:23 | FromDiscord | <yetiwizard> I managed to get the register content into a variable |
14:23:44 | FromDiscord | <yetiwizard> it is a pointer to a struct which at offset 0x68 has a char |
14:23:56 | FromDiscord | <yetiwizard> I want to echo the content of that cstring |
14:24:13 | FromDiscord | <yetiwizard> with this code I get gibberish |
14:24:27 | FromDiscord | <yetiwizard> echo toHex(cast[int](zone) + 0x68) - gives the correct address of the cstring tho |
14:47:46 | FromDiscord | <leorize> just build your own nim, duh↵(@Chronos [She/Her]) |
14:52:10 | FromDiscord | <jmgomez> Wasnt someone working on RxNim? That would make it |
14:55:08 | FromDiscord | <Chronos [She/Her]> In reply to @leorize "just build your own": Lol |
14:56:09 | FromDiscord | <yetiwizard> sent a code paste, see https://paste.rs/uR6fc |
14:56:40 | FromDiscord | <leorize> why the emit? |
14:56:48 | FromDiscord | <yetiwizard> i've been searching for hours online and can't find a way to do it in Nim directly |
14:57:02 | FromDiscord | <leorize> what's your zone variable? |
14:57:15 | FromDiscord | <yetiwizard> zone is an object |
14:57:18 | FromDiscord | <leorize> the type I mean |
14:57:26 | FromDiscord | <yetiwizard> in this case it's PVOID |
14:57:39 | FromDiscord | <yetiwizard> but at offset 0x68 of that object |
14:57:45 | FromDiscord | <yetiwizard> is a char |
14:57:59 | FromDiscord | <Chronos [She/Her]> In reply to @yetiwizard "is there seriously no": A ptr char is just a cstring, no? |
14:58:28 | FromDiscord | <leorize> `var zoneName = cast[cstring](cast[unit](zone) + 0x68)` |
14:59:02 | FromDiscord | <yetiwizard> what's unit? |
14:59:13 | FromDiscord | <yetiwizard> is `cstring` the same as `ptr cchar` |
14:59:15 | FromDiscord | <yetiwizard> (edit) "cchar`" => "cchar`?" |
15:00:42 | FromDiscord | <Chronos [She/Her]> A string in C is just an unchecked array of characters, so |
15:00:52 | FromDiscord | <yetiwizard> sent a code paste, see https://paste.rs/Ktnti |
15:00:53 | FromDiscord | <yetiwizard> this piece of code does exactly what I want |
15:01:02 | FromDiscord | <Chronos [She/Her]> And an unchecked array is just a pointer |
15:01:04 | FromDiscord | <yetiwizard> but I don't get how to do it without emit |
15:01:05 | FromDiscord | <leorize> In reply to @yetiwizard "what's unit?": it's uintptr_t |
15:01:36 | FromDiscord | <leorize> nim's uint is uintptr\_t in C |
15:01:40 | FromDiscord | <leorize> oh it's my phone autocorrect |
15:02:31 | FromDiscord | <yetiwizard> I tried `zoneName = cast[cstring](cast[uint](zone) + 0x68)`↵and the output is↵`╨☺ⁿ∟¿☻ⁿ∟6` |
15:02:48 | FromDiscord | <yetiwizard> I guess it doesn't dereference the pointer or something |
15:03:12 | FromDiscord | <yetiwizard> I think we are missing a level here |
15:03:26 | FromDiscord | <yetiwizard> 0x68 is actually pointing to another object |
15:03:34 | FromDiscord | <yetiwizard> that has the cstring at offset 0 |
15:04:44 | FromDiscord | <odexine> `zoneName = cast[ptr cstring](cast[uint](zone) + 0x68)[]`? |
15:05:26 | FromDiscord | <yetiwizard> that's it! thank you so much! |
15:05:43 | FromDiscord | <yetiwizard> but what if that cstring wasn't at index 0? |
15:05:48 | FromDiscord | <yetiwizard> but say at offset 0x24? |
15:05:57 | FromDiscord | <yetiwizard> (edit) "index" => "offset" |
15:06:08 | FromDiscord | <leorize> then add another 0x24? |
15:06:41 | FromDiscord | <yetiwizard> where exactly? |
15:07:18 | FromDiscord | <leorize> cast that new ptr to uint then add |
15:08:48 | FromDiscord | <leorize> yea nim is not great for pointer math and you'd need to make your own wrappers to do it easily |
15:09:19 | FromDiscord | <leorize> luckily that's easy enough to do |
15:09:27 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jv7 |
15:09:43 | FromDiscord | <yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jv7" => "https://play.nim-lang.org/#ix=4Jv8" |
15:10:06 | FromDiscord | <leorize> use uint just so you always get the correct pointer size |
15:10:46 | FromDiscord | <yetiwizard> oh, cause uint32 will not always equal uint, right? |
15:10:46 | FromDiscord | <odexine> sent a code paste, see https://play.nim-lang.org/#ix=4Jva |
15:11:24 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jvb |
15:11:48 | FromDiscord | <leorize> yep↵(@yetiwizard) |
15:11:52 | FromDiscord | <yetiwizard> also, what about using `cint` |
15:12:32 | FromDiscord | <yetiwizard> in general, if I want to work with 32bit addresses in Nim, should I use uint? |
15:12:33 | FromDiscord | <odexine> cint is equivalent to, well, c's `int` and is therefore subject to the rules |
15:12:35 | FromDiscord | <yetiwizard> (edit) "uint?" => "`uint`?" |
15:12:52 | FromDiscord | <odexine> if you want to work with any addresses use uint |
15:17:25 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4Jvf |
15:17:44 | FromDiscord | <leorize> that one should probably be typed |
15:18:22 | FromDiscord | <leorize> as in having some actual types |
15:18:28 | FromDiscord | <yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jvf" => "https://play.nim-lang.org/#ix=4Jvg" |
15:18:40 | FromDiscord | <yetiwizard> betteR? |
15:18:41 | FromDiscord | <yetiwizard> (edit) "betteR?" => "better?" |
15:18:43 | FromDiscord | <yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jvg" => "https://play.nim-lang.org/#ix=4Jvh" |
15:19:01 | FromDiscord | <leorize> a typed pointer would be even betterer |
15:19:04 | FromDiscord | <yetiwizard> (edit) "https://play.nim-lang.org/#ix=4Jvh" => "https://play.nim-lang.org/#ix=4Jvi" |
15:19:30 | FromDiscord | <yetiwizard> well, it's a void |
15:19:47 | FromDiscord | <leorize> make that void something meaningful |
15:19:54 | FromDiscord | <leorize> like an actual object of sorts |
15:19:58 | FromDiscord | <yetiwizard> true, that would be the next step |
15:20:00 | FromDiscord | <leorize> or a distinct pointer |
15:20:34 | FromDiscord | <yetiwizard> I have yet to learn the concept of classes as it works in C++ in Nim |
15:20:49 | FromDiscord | <odexine> nim doesnt heavily use the concept of classes |
15:20:55 | FromDiscord | <leorize> nim objects are C structs |
15:21:05 | FromDiscord | <leorize> they are basically the same unless you use inheritance |
15:21:10 | FromDiscord | <leorize> then they're slightly different |
15:21:30 | FromDiscord | <yetiwizard> is there something equivalent to C++ classes? with implicit this pointer? |
15:21:35 | FromDiscord | <odexine> no |
15:22:23 | FromDiscord | <yetiwizard> hmm, ok, once I get around to creating these types I'll probs have more questions 😅 |
15:24:07 | FromDiscord | <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:24 | FromDiscord | <yetiwizard> but thanks y'all for now! |
15:32:20 | FromDiscord | <xtrayambak> What's a good way to replace a character in a string with a two characters? |
15:33:31 | FromDiscord | <starkiller1493> https://nim-lang.org/docs/strutils.html#replaceWord%2Cstring%2Cstring%2Cstring |
15:33:46 | FromDiscord | <starkiller1493> In reply to @xtrayambak "What's a good way": https://nim-lang.org/docs/strutils.html#replaceWord%2Cstring%2Cstring%2Cstring |
15:34:30 | FromDiscord | <xtrayambak> No, not that. |
15:34:49 | FromDiscord | <leorize> it'd be stdout because that proc doesn't consume stdout until the other program stops running↵(@nervecenter) |
15:34:51 | FromDiscord | <leorize> I'm building something that's better than osproc but it won't be ready anytime soon unfortunately |
15:35:10 | FromDiscord | <xtrayambak> I mean, as in, say,↵`"Nim is\tvery cool!"`↵how can I replace `\t` with `tab` ? |
15:35:23 | FromDiscord | <xtrayambak> Replacing strings with characters is easy, not vice versa though |
15:35:48 | FromDiscord | <leorize> replaceWord is how you do it, no? |
15:36:26 | FromDiscord | <xtrayambak> I don't think so |
15:36:45 | FromDiscord | <xtrayambak> `replaceWord('\t', "tab")` won't work, as it's a type mismatch |
15:37:06 | FromDiscord | <leorize> pass a string? |
15:37:11 | FromDiscord | <leorize> because "\\t" is a string with a single tab character |
15:37:33 | FromDiscord | <xtrayambak> That doesn't work either |
15:37:42 | FromDiscord | <xtrayambak> Hold up |
15:37:44 | FromDiscord | <xtrayambak> Aaaah |
15:37:56 | FromDiscord | <leorize> ah it only does it by word boundary |
15:37:58 | FromDiscord | <xtrayambak> Woops, my editor converts tabs to spaces. I forgot that was on and that's why it didn't work. |
15:38:01 | FromDiscord | <leorize> there's one that does general replacement |
15:38:03 | FromDiscord | <xtrayambak> 😅 |
15:38:10 | FromDiscord | <leorize> like multi-replace |
15:38:52 | FromDiscord | <leorize> https://nim-lang.org/docs/strutils.html#multiReplace%2Cstring%2Cvarargs%5B%5D \<- this is what you'd want |
15:39:10 | FromDiscord | <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:30 | FromDiscord | <leorize> spawn a thread↵(@nervecenter) |
15:41:30 | FromDiscord | <jviega> False |
15:42:07 | FromDiscord | <jviega> You can totally deal w/ that problem w/o threads |
15:42:55 | FromDiscord | <jviega> You just need to only write PIPEBUF at a time, and then ensure the FD is ready to read again |
15:43:05 | FromDiscord | <jviega> To avoid the deadlock |
15:43:51 | FromDiscord | <jviega> Sorry, `PIPE_BUF` |
15:44:28 | FromDiscord | <leorize> the problem is that they also have to consume the output |
15:44:42 | FromDiscord | <jviega> So? I do it all the time. It's not hard. |
15:44:52 | FromDiscord | <jviega> select() or epoll() work fine in one thread |
15:45:11 | FromDiscord | <leorize> not when you want to do it nicely, but sure they do work |
15:45:40 | FromDiscord | <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:52 | FromDiscord | <jviega> So you can do expect-like things w/ a pty |
15:45:54 | FromDiscord | <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:27 | FromDiscord | <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:00 | FromDiscord | <jviega> People leap to threads these days the way people used to leap to OOP 🙂 |
15:53:52 | FromDiscord | <leorize> unless you're on windows \:P |
15:54:33 | FromDiscord | <jviega> Yeah, I live in a concrete bunker... no Windows |
15:54:43 | FromDiscord | <jviega> Tho I suppose I'd support WSL |
15:55:08 | FromDiscord | <leorize> i'm building the abstractions needed for all that over here\: https://github.com/alaviss/nim-sys |
15:55:17 | FromDiscord | <leorize> but life is in the way right now so don't expect it to move fast |
15:55:55 | FromDiscord | <jviega> Cool, I am more about high level APIs for things but only caring about posix-compliance 🙂 |
15:56:45 | FromDiscord | <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:45 | FromDiscord | <leorize> you'll love this stuff\: https://github.com/alaviss/nim-sys/blob/features/exec-prototype/src/sys/exec.nim#L30-L173 |
15:57:58 | FromDiscord | <leorize> just a prototype api, nothing actually works and the code in that branch is super outdated |
15:58:14 | FromDiscord | <leorize> these days nim-sys don't use asyncdispatch anymore |
15:59:09 | FromDiscord | <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:44 | FromDiscord | <leorize> this is what I call that over here\: https://alaviss.github.io/nim-sys/ioqueue.html |
16:00:53 | FromDiscord | <jviega> Similar, but that's more low-level; my interface is more like Python's subprocess module |
16:01:35 | FromDiscord | <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:38 | FromDiscord | <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:31 | FromDiscord | <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:38 | FromDiscord | <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:53 | FromDiscord | <leorize> you write the code for that |
16:06:00 | FromDiscord | <leorize> code that looks exactly like blocking code |
16:06:01 | FromDiscord | <jviega> I did... once. |
16:06:30 | FromDiscord | <leorize> basically I'm building the backbone for something like goroutines |
16:07:10 | FromDiscord | <leorize> you don't need magical incantation to roll your queue and have it working in tandem with everything else |
16:07:16 | FromDiscord | <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:22 | FromDiscord | <leorize> you write blocking code and it works equally well on bsd, linux and windows |
16:08:00 | FromDiscord | <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:17 | FromDiscord | <jviega> As long as the read is non-blocking |
16:08:31 | FromDiscord | <jviega> Otherwise, you need to use select() or epoll() 🙂 |
16:49:20 | * | derpydoo joined #nim |
16:54:50 | FromDiscord | <nervecenter> Switching to a temp file based solution worked well |
17:14:04 | * | advesperacit quit (Ping timeout: 272 seconds) |
17:14:15 | FromDiscord | <yetiwizard> sent a long message, see http://ix.io/4JvM |
17:14:23 | * | advesperacit joined #nim |
17:15:05 | FromDiscord | <yetiwizard> I'm trying to call sol2/sol3 functions from Nim |
17:15:20 | FromDiscord | <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:37 | FromDiscord | <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:21 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#ix=4JvT |
17:31:06 | FromDiscord | <griffith1deadly> (edit) "https://paste.rs/d3sQU" => "https://play.nim-lang.org/#ix=4JvU" |
17:35:08 | FromDiscord | <yetiwizard> if I use `args: varargs[cstring]` it generates some extra arguments but still ends with `, ...` and no `Args... args` |
17:36:56 | FromDiscord | <leorize> you can't↵(@yetiwizard) |
17:37:26 | FromDiscord | <leorize> for templates you must include the header and import it using importcpp |
17:39:48 | FromDiscord | <yetiwizard> here's my second option |
17:39:59 | FromDiscord | <yetiwizard> sent a code paste, see https://play.nim-lang.org/#ix=4JvW |
17:40:50 | FromDiscord | <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:11 | FromDiscord | <yetiwizard> `LuaRunScriptClass`, so I tried using `extern sol::state lua;`, idk if that would work |
17:42:11 | FromDiscord | <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:26 | FromDiscord | <leorize> it would, but don't put extern in↵(@yetiwizard) |
17:47:29 | FromDiscord | <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:04 | FromDiscord | <yetiwizard> ok, seems the only option is really to move the LuaRunScriptClass in a separate header file |
18:04:16 | FromDiscord | <yetiwizard> I guess it does make sense tho lol |
18:04:29 | FromDiscord | <yetiwizard> why would I mix whole cpp functions in .nim files? |
18:20:23 | NimEventer | New thread by ITwrx: No simple way to import files from dir recusively?, see https://forum.nim-lang.org/t/10561 |
19:28:01 | arkanoid | I'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:55 | arkanoid | I'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:33 | NimEventer | New thread by dwhall256: Custom numeric literal, see https://forum.nim-lang.org/t/10562 |
20:15:42 | FromDiscord | <Elegantbeef> Arkanoid sharing refs between threads is a very annoying prospect presently |
20:17:39 | FromDiscord | <Elegantbeef> Atomic arc reduces some of the headaches, but it's bleh |
20:17:58 | FromDiscord | <Chronos [She/Her]> Hm anyone know if there's a URL validator in Nim's stdlib? |
20:18:22 | FromDiscord | <Elegantbeef> `std/uri`? |
20:18:45 | FromDiscord | <Chronos [She/Her]> Doesn't have validation, just parsing |
20:18:59 | FromDiscord | <Chronos [She/Her]> Wait |
20:19:05 | FromDiscord | <Elegantbeef> What does that even mean, if it parses it's a valid uri |
20:19:08 | FromDiscord | <Chronos [She/Her]> I'm dumb |
20:19:12 | FromDiscord | <Chronos [She/Her]> Security validation |
20:19:28 | FromDiscord | <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:56 | FromDiscord | <Elegantbeef> "Security validation" Flammable fire, I can put two words that sound related together aswell 😄 |
20:20:17 | FromDiscord | <jviega> You mean you want to check the x509 cert of the server? |
20:21:40 | FromDiscord | <Chronos [She/Her]> No, just meant that the URL isn't malformed :p |
20:21:56 | FromDiscord | <Chronos [She/Her]> Though, can't find any errors that it'd raise on invalid URLs? |
20:22:22 | FromDiscord | <Chronos [She/Her]> Obviously `UriParseError` but where in the body exactly is it raised? |
20:22:24 | FromDiscord | <jviega> Yeah, the uri module will do well for you on that |
20:22:47 | FromDiscord | <jviega> 🤷 but it works 🙂 |
20:22:47 | FromDiscord | <Elegantbeef> Wait all the URI procs are `raises:[]` 😄 |
20:23:03 | FromDiscord | <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:47 | FromDiscord | <Chronos [She/Her]> Oh well |
20:25:13 | FromDiscord | <Chronos [She/Her]> Also being able to await multiple futures at once would be useful :p |
20:25:19 | FromDiscord | <Chronos [She/Her]> Oh well |
20:25:23 | FromDiscord | <Elegantbeef> `all` exists |
20:26:21 | FromDiscord | <Chronos [She/Her]> Oh |
20:30:48 | FromDiscord | <.aingel.> How would I alloc a cstring buffer? |
20:31:00 | FromDiscord | <Elegantbeef> Depends what you need it for |
20:31:20 | FromDiscord | <Elegantbeef> you can just do `var myString = newString(size); myProcthatWantsCstring(cstring myString)` |
20:33:41 | * | rockcavera quit (Ping timeout: 260 seconds) |
20:35:46 | FromDiscord | <.aingel.> Gotcha |
20:38:07 | FromDiscord | <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:08 | FromDiscord | <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:24 | FromDiscord | <Chronos [She/Her]> sent a long message, see http://ix.io/4JwL |
20:38:47 | FromDiscord | <Chronos [She/Her]> Doesn't seem to be working |
20:39:04 | FromDiscord | <Elegantbeef> Why do you have a lock |
20:39:04 | FromDiscord | <Elegantbeef> This is asynch |
20:39:20 | FromDiscord | <Chronos [She/Her]> Do I not need a lock? :p |
20:39:50 | FromDiscord | <Chronos [She/Her]> In reply to @chronos.vitaqua "!eval import std/[locks, asyncdispatch]": Running the code locally has no issues anyway |
20:40:12 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Why do you have": Would you believe me if I called it practice? :p |
20:41:41 | FromDiscord | <Chronos [She/Her]> For my actual issue |
20:41:53 | FromDiscord | <Elegantbeef> Of course you do not need a lock |
20:41:54 | FromDiscord | <Elegantbeef> This is async code |
20:41:54 | FromDiscord | <Elegantbeef> Only one thread is active at a time |
20:41:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4JwM |
20:42:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4JwN |
20:43:32 | FromDiscord | <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:26 | FromDiscord | <Chronos [She/Her]> I'd send the code but it's 300 lines :p |
20:44:47 | FromDiscord | <Chronos [She/Her]> And needs a JSON file that has personal info and would be too long to recreate |
20:45:54 | FromDiscord | <Elegantbeef> Well with all these caveats I'll just go for a snide remark of "Heh l4rn async" |
20:46:32 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4JwO |
20:46:58 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4JwP |
20:47:22 | FromDiscord | <Elegantbeef> How many requests are you making? |
20:47:37 | FromDiscord | <Chronos [She/Her]> Over 100? :p |
20:47:50 | FromDiscord | <Chronos [She/Her]> With 4 different async http clients |
20:47:53 | FromDiscord | <Elegantbeef> Are you saturating your file handles by anychance? |
20:47:56 | FromDiscord | <Chronos [She/Her]> But none of them getdownloaded |
20:48:11 | FromDiscord | <Elegantbeef> I also don't know if you can share http clients |
20:48:59 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Are you saturating your": Probably, I could await like, 4 at a time instead maybe? |
20:50:47 | FromDiscord | <jviega> "Over 100" then you probably are. |
20:51:07 | FromDiscord | <jviega> I think on most systems the default process fd limit is not much higher than that |
20:52:04 | FromDiscord | <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:16 | FromDiscord | <jviega> Don't let them grow unbounded for sure |
20:55:04 | * | Guest70 joined #nim |
20:55:41 | * | Guest70 quit (Client Quit) |
20:55:50 | FromDiscord | <Chronos [She/Her]> Not sure how I'm supposed to stop this tbh, since all the futures get ran anyway |
20:56:04 | FromDiscord | <Chronos [She/Her]> Like, instantly |
20:57:46 | FromDiscord | <Chronos [She/Her]> Maybe I should do this synchronously... |
20:58:34 | FromDiscord | <Chronos [She/Her]> That way, everything will be done one at a time even if it's not ideal |
20:58:41 | FromDiscord | <Elegantbeef> Nah just require the OS to have more file handles! |
20:58:53 | FromDiscord | <Elegantbeef> That doesnt solve anything here |
20:59:14 | FromDiscord | <Elegantbeef> Async is already doing things at one time |
20:59:19 | FromDiscord | <Elegantbeef> It's still single threaded |
20:59:47 | FromDiscord | <Chronos [She/Her]> Ah |
21:00:00 | FromDiscord | <jviega> Just muddies your control flow, makes it prone to odd ordering side effects, and is susceptible to unfair scheduing |
21:00:22 | FromDiscord | <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:00 | FromDiscord | <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:04 | FromDiscord | <jviega> "muddies your control flow" ftw |
21:01:32 | FromDiscord | <Elegantbeef> Async is just an explicit CPU scheduling |
21:01:51 | FromDiscord | <Chronos [She/Her]> Aah |
21:02:01 | FromDiscord | <Elegantbeef> `await` `poll` `waitfor` and a few other things give up your CPU to handle all waiting for processess |
21:02:28 | FromDiscord | <Elegantbeef> So if you write an async proc without using any async methods it's ran to completion when it's called |
21:04:09 | FromDiscord | <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:15 | FromDiscord | <Elegantbeef> I rarely use async, but when I do it's purely sensible! 😄 |
21:06:29 | FromDiscord | <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:45 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "So if you write": That makes sense |
21:06:51 | FromDiscord | <Chronos [She/Her]> In reply to @jviega "In my view, if": I may do that :p |
21:06:52 | FromDiscord | <Chronos [She/Her]> https://play.nim-lang.org/#ix=4JwT |
21:06:54 | FromDiscord | <Elegantbeef> Just use selectors and manually do it 😛 |
21:06:57 | FromDiscord | <Chronos [She/Her]> This is my code atm |
21:07:08 | FromDiscord | <Elegantbeef> TLDR |
21:07:17 | FromDiscord | <Chronos [She/Her]> Yeah :p |
21:07:24 | FromDiscord | <Elegantbeef> So many locks |
21:07:35 | FromDiscord | <Chronos [She/Her]> :p |
21:07:44 | FromDiscord | <Elegantbeef> People really will throw whatever they have at the wall and hope it sticks |
21:07:50 | FromDiscord | <Chronos [She/Her]> Yep |
21:08:34 | FromDiscord | <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:43 | FromDiscord | <jviega> async 100% encourages that. Randomly sprinkle "async" and "await" until they work |
21:09:17 | FromDiscord | <leorize> we had an entire RFC about building something better |
21:10:00 | FromDiscord | <Elegantbeef> Hey selectors arent hard to use! |
21:10:56 | FromDiscord | <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:12 | FromDiscord | <leorize> cue cps |
21:11:19 | FromDiscord | <jviega> csp? |
21:11:40 | FromDiscord | <leorize> no, continuation passing style |
21:11:47 | FromDiscord | <Elegantbeef> See as someone that does not do any amount of concurrency arent async and goroutines both green threads? |
21:11:50 | FromDiscord | <jviega> Oh, yeah, I guess |
21:12:17 | FromDiscord | <jviega> goroutines are basically threads. fair scheduling. |
21:12:26 | FromDiscord | <leorize> async is M\:1 |
21:12:31 | FromDiscord | <leorize> goroutines is M\:N |
21:12:47 | FromDiscord | <Elegantbeef> You can use fancy notations but if you don't tell me what the notation is it doesnt help |
21:13:01 | FromDiscord | <leorize> async runs M threads on 1 real thread |
21:13:06 | FromDiscord | <jviega> continuation passing style is fine, tho have also seen people have a hard time wrapping their heads around it |
21:13:07 | FromDiscord | <leorize> goroutines does it on N threads |
21:13:08 | FromDiscord | <Elegantbeef> Ah there you |
21:13:24 | FromDiscord | <Elegantbeef> go |
21:13:49 | FromDiscord | <leorize> probably why nim cps doesn't gain traction |
21:13:55 | FromDiscord | <jviega> Yup |
21:14:40 | FromDiscord | <leorize> well we already built it and it works |
21:14:48 | FromDiscord | <leorize> but kinda useless if no one uses it |
21:15:20 | FromDiscord | <Elegantbeef> Clearly async has the same issues |
21:15:47 | FromDiscord | <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:03 | FromDiscord | <Elegantbeef> Same educational issues I mean |
21:16:05 | FromDiscord | <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:09 | FromDiscord | <jviega> CPS looks hard |
21:17:02 | FromDiscord | <leorize> building event queues for cps has been the most pleasant experience for me compared to trying to hack something for asyncdispatch |
21:17:27 | FromDiscord | <leorize> but then again, I am one of the authors so very biased |
21:18:47 | FromDiscord | <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:39 | FromDiscord | <leorize> funny enough cps is gaining traction everywhere but nim |
21:20:19 | FromDiscord | <jviega> Yeah but doesn't make it less hipster |
21:20:21 | * | alice quit (Remote host closed the connection) |
21:20:34 | FromDiscord | <jviega> It does have some technical advantages as a compiler implementation approach |
21:20:44 | FromDiscord | <jviega> But for end users, 🤷 |
21:22:10 | FromDiscord | <leorize> everyone loves goroutines but no one wants to build it ig |
21:22:34 | FromDiscord | <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:51 | FromDiscord | <jviega> Otherwise we'd all be using OpenBSD |
21:30:34 | FromDiscord | <Chronos [She/Her]> Idk how to go about using threads here tbh |
21:48:14 | FromDiscord | <Chronos [She/Her]> Oh hey I did it |
21:48:45 | FromDiscord | <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:51 | FromDiscord | <Chronos [She/Her]> My program is working perfectly |
21:50:08 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Jx2 |
22:11:49 | * | advesperacit quit () |
22:23:17 | FromDiscord | <Chronos [She/Her]> Hey, I think I'm doing threading somewhat alright? :p |
22:23:35 | FromDiscord | <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:57 | FromDiscord | <Elegantbeef> There is no analysis to check that it's safe you have to override the compiler |
22:37:59 | FromDiscord | <Elegantbeef> Nim doesnt care that you use locks accessing global variables is gc unsafe 😄↵(@Chronos [She/Her]) |
22:39:08 | FromDiscord | <Chronos [She/Her]> Damn |
22:39:28 | FromDiscord | <Chronos [She/Her]> Not sure how I'd inform the compiler that accessing them is indeed safe- |
22:39:39 | FromDiscord | <Elegantbeef> `{.cast(gcsafe).}` |
22:40:32 | arkanoid | do you know if there's an RCU implementation for Nim? https://en.wikipedia.org/wiki/Read-copy-update |
22:40:35 | FromDiscord | <Elegantbeef> If you want to avoid using a global either use `ptr T` or return additions |
22:42:01 | FromDiscord | <Elegantbeef> I don't even know what RCU is, never mind an implementation of it |
22:44:15 | arkanoid | Elegantbeef, 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:11 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "`{.cast(gcsafe).}`": On the variable? |
22:45:23 | FromDiscord | <Chronos [She/Her]> On the proc it doesn't work |
22:45:41 | FromDiscord | <Chronos [She/Her]> Unless you mean to use it like `{.cast(gcsafe).}:` and but the body in there |
22:48:18 | FromDiscord | <Elegantbeef> Yes |
22:48:21 | FromDiscord | <Elegantbeef> The latter |
22:49:34 | FromDiscord | <Chronos [She/Her]> Gucci |
22:59:16 | arkanoid | Elegantbeef, 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:07 | FromDiscord | <Chronos [She/Her]> Code works perfectly with arc :) |
23:05:29 | FromDiscord | <Elegantbeef> I've had birds fly over my head lower than that whitepaper |
23:07:48 | arkanoid | Elegantbeef, haha, well, kinda same, but it's nice to know that solutions do exist |
23:08:21 | arkanoid | https://liburcu.org/ |
23:08:46 | FromDiscord | <Elegantbeef> Reading further it's not too bad afaict |
23:09:37 | FromDiscord | <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:58 | FromDiscord | <Elegantbeef> I say a few seconds, but of course I mean when the refcount is 0 |
23:15:29 | FromDiscord | <Elegantbeef> Does seem like a fun problem to use type states on |
23:18:54 | arkanoid | type states? |
23:19:24 | FromDiscord | <Elegantbeef> https://forum.nim-lang.org/t/9976#65763 |
23:19:49 | FromDiscord | <Elegantbeef> In the case of a RCU'd linked list you'd have a `RCU[Readable: static bool]` or similar |
23:20:08 | FromDiscord | <Elegantbeef> Sorry that should be `Writable` |
23:20:35 | FromDiscord | <Elegantbeef> It'd only be `RCU[true]` in the case you do `myRcu.waitForAll()` |
23:20:57 | FromDiscord | <Elegantbeef> Actually sorry again, it'd not be writable, but reclaimable |
23:25:04 | arkanoid | wait this is going one abstraction layer over my current capacity |
23:25:39 | arkanoid | a typeclass argument is already compile time, what does a "static" add? |
23:25:41 | * | lumo_e joined #nim |
23:25:49 | FromDiscord | <Elegantbeef> You encode runtime information into the state of an object, this statically prevents you from misgivings |
23:25:57 | FromDiscord | <Elegantbeef> `static T` encodes data to a type |
23:26:30 | arkanoid | let le re-read, slowly |
23:31:17 | arkanoid | I 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:40 | FromDiscord | <Elegantbeef> I mean it encodes runtime information into the type system |
23:31:41 | FromDiscord | <Elegantbeef> Static typing is king |
23:32:47 | arkanoid | I would like to learn much more about how to use static typing to design/scaffold better software |
23:37:26 | arkanoid | can I go one layer even more classtyping typeclasses? Foo[TBar: static Option[Foo2[Tbaz: static bool]]] ? |
23:38:11 | FromDiscord | <Elegantbeef> If you wanted to |
23:38:12 | FromDiscord | <Elegantbeef> You can use any type inside a static |
23:38:12 | FromDiscord | <Elegantbeef> Aslong as you can define it at compile time |
23:40:46 | arkanoid | would be nice to challenge https://zackoverflow.dev/writing/flappy-bird-in-type-level-typescript/ |
23:50:49 | FromDiscord | <Elegantbeef> Actually playing around with implementing it shows that it doesnt add much |
23:51:02 | FromDiscord | <Elegantbeef> Atleast in this case |
23:51:07 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4Jxf if curious |
23:53:21 | arkanoid | wait what? how you went from non knowing what it is, to implement a version of it, in 45 minutes?! |
23:53:39 | FromDiscord | <Elegantbeef> No clue |
23:54:05 | FromDiscord | <Elegantbeef> When you don't know what you're doing you can pretend to do a lot |
23:54:37 | FromDiscord | <Elegantbeef> I don't even think I implemented it properly though given that the output is the same for all threads |
23:54:40 | FromDiscord | <Elegantbeef> Expected it to differ |
23:54:47 | FromDiscord | <Elegantbeef> Plus it didnt remove all modulo 10s |
23:55:07 | FromDiscord | <Elegantbeef> Oh found the issue |
23:55:12 | FromDiscord | <Elegantbeef> `x.parent.next = x.next` |
23:55:51 | FromDiscord | <Elegantbeef> There we go |
23:55:59 | FromDiscord | <Elegantbeef> Diff has been successful |
23:56:28 | arkanoid | :| you make me feel very stupid |
23:56:49 | FromDiscord | <Elegantbeef> Sorry I'll put less effort in |
23:57:17 | arkanoid | where did you find such a clear vision of it? is it in the whitepaper? |
23:57:25 | FromDiscord | <Elegantbeef> Nope |
23:57:45 | FromDiscord | <Elegantbeef> https://www.kernel.org/doc/html/latest/RCU/whatisRCU.html#rcu-overview |
23:58:07 | FromDiscord | <Elegantbeef> Much better than the whitepaper |
23:58:30 | FromDiscord | <Elegantbeef> Reading the first two paragraphs explained everything I needed |
23:58:38 | * | ehmry joined #nim |
23:59:17 | FromDiscord | <Elegantbeef> Separation of freeing and replacing -\> wait until all consumers are done -\> actually free memory |