01:14:43 | FromDiscord | <creikey> In reply to @dom96 "You’re honestly better off": I tested this attack with a cloudflare websockets proxied server https://github.com/treeform/ws/issues/42 and cloudflare did not stop the server from receiving the packet, causing the VPS to allocate gigabytes of memory and stall |
01:21:19 | * | PMunch quit (Ping timeout: 268 seconds) |
01:22:29 | FromDiscord | <Elegantbeef> > You’re honestly better off just not using the internet and moving into the woods↵FTFY |
01:25:00 | FromDiscord | <creikey> In reply to @Elegantbeef "> You’re honestly better": to be honest |
01:25:22 | FromDiscord | <!Patitotective> beef says that because he lives with bears |
01:25:29 | FromDiscord | <creikey> I'm sad that deepbeef is on hold the bot will not be invited |
01:25:40 | FromDiscord | <creikey> the only other option is to like use the discord client and scrape it like that |
01:25:43 | FromDiscord | <creikey> probably would take forever |
01:37:26 | FromDiscord | <Elegantbeef> Alternatively put all that effort into something worthwhile |
01:37:42 | FromDiscord | <Elegantbeef> Making an AI replicate a jackass isnt something worth anyone's time |
01:39:06 | FromDiscord | <SrMordred> sent a code paste, see https://play.nim-lang.org/#ix=47Jg |
01:39:17 | FromDiscord | <Elegantbeef> It's an unsafe pointer o the first element |
01:39:19 | FromDiscord | <Elegantbeef> to\ |
01:39:39 | FromDiscord | <Elegantbeef> So if the pointer outlives `text` you'll have issues, but most APIs luckily dont hold onto cstrings |
01:40:11 | FromDiscord | <SrMordred> oh wait, nim strings are null terminated? |
01:40:19 | FromDiscord | <Elegantbeef> Most languages that use pascal strings actually internally make cstrings, so you can for free get a safe temporary C string |
01:40:45 | FromDiscord | <Elegantbeef> It's a single extra byte that ensures free C interop |
01:41:28 | FromDiscord | <!Patitotective> In reply to @Elegantbeef "So if the pointer": ~~imgui when~~ |
01:41:32 | FromDiscord | <SrMordred> ahhh, nice. i thought that cstring created a string. ↵that´s better tbh 🙂 (at least when interoping with c) |
01:41:40 | FromDiscord | <Elegantbeef> Yep |
01:41:56 | FromDiscord | <Elegantbeef> The only downside is if the API dumbly takes ownership of that cstring |
01:42:44 | FromDiscord | <Elegantbeef> In that case you'd have to hold onto string and make it outlive the library |
01:42:51 | FromDiscord | <SrMordred> then i would need to make sure that the original string are alive somewhere |
01:42:53 | FromDiscord | <Elegantbeef> Libraries that do that are far and few inbetween though |
01:43:05 | FromDiscord | <SrMordred> yeah, normally are copied or used on the moment |
01:43:17 | FromDiscord | <Elegantbeef> Exactly |
01:43:42 | FromDiscord | <Elegantbeef> I know imgui as patito mentioned has an API that takes a `cstring` but expects it to be allocated with their allocator, so you can accidentally pass the wrong 'type' |
01:44:32 | FromDiscord | <Elegantbeef> Given that i've been toying with a statically typed custom allocated type C's type system is a joke 😛 |
01:44:51 | FromDiscord | <SrMordred> coincidentally, i'm making a ui system on top of raylib for my needs ;p |
01:45:33 | FromDiscord | <Elegantbeef> Hopefully it can be a nice retained declarative UI |
01:45:39 | FromDiscord | <Elegantbeef> That's clearly the bes |
01:45:41 | FromDiscord | <Elegantbeef> best\ |
01:46:40 | FromDiscord | <!Patitotective> In reply to @Elegantbeef "Hopefully it can be": i havent started the imgui declarative wrapper yet 💀 💀 ↵ill insipirate from owlkettle |
01:47:17 | FromDiscord | <!Patitotective> btw owlkettle's author uploaded a video about it https://www.youtube.com/watch?v=O44x_la1o_M :p |
01:47:37 | FromDiscord | <Elegantbeef> Nifty |
01:48:36 | FromDiscord | <Elegantbeef> Wow no inspiration from my GUI |
01:49:12 | FromDiscord | <!Patitotective> which |
01:49:26 | FromDiscord | <!Patitotective> oh i remember |
01:49:32 | FromDiscord | <Elegantbeef> https://github.com/beef331/truss3d/blob/master/examples/guitest.nim#L22-L141 |
01:49:56 | FromDiscord | <SrMordred> sent a code paste, see https://play.nim-lang.org/#ix=47Jh |
01:50:00 | FromDiscord | <Elegantbeef> Oh god i hate it |
01:50:01 | FromDiscord | <SrMordred> https://media.discordapp.net/attachments/371759389889003532/1008915503009505290/unknown.png |
01:50:12 | FromDiscord | <!Patitotective> In reply to @Elegantbeef "https://github.com/beef331/truss3d/blob/master/exam": hmmmmmmmmmmmmmm perhaps |
01:50:23 | FromDiscord | <!Patitotective> In reply to @SrMordred "i have some ideias,": please no |
01:50:36 | FromDiscord | <Elegantbeef> Builder pattern i guess works, but i really dislike it |
01:53:21 | FromDiscord | <!Patitotective> i liked the appstate owlkettle thing, rather than global vars 💀 |
01:53:24 | FromDiscord | <SrMordred> i tested all the ui libs out there and i always hit something simple that are made hard because the ui make a lot of things already for u. ↵but im my case i want something more simple, but want control to put the things on the pixel that i want. ↵for now its been nice to be able to put a centralized text with no effort |
01:53:34 | FromDiscord | <Elegantbeef> What global variables?↵(@!Patitotective) |
01:53:43 | FromDiscord | <!Patitotective> In reply to @SrMordred "i tested all the": ~~imgu-~~ |
01:53:48 | FromDiscord | <!Patitotective> In reply to @Elegantbeef "What global variables? (<@762008715162419261>)": `btns` |
01:54:07 | FromDiscord | <Elegantbeef> That's for the test, just like owlkettle you'd cache those on an object |
01:54:11 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=47Ji |
01:54:35 | FromDiscord | <Elegantbeef> For my game i have a `editorGui: seq[UIElement]` for the world editor |
01:54:47 | FromDiscord | <Elegantbeef> They're both retained GUI so... they're identical |
01:55:04 | FromDiscord | <SrMordred> imgui dont fit my needs. nor raygui, nor egui nor none xD |
01:55:32 | FromDiscord | <Elegantbeef> Remember patito my GUI is for games not for programs |
01:55:41 | FromDiscord | <Elegantbeef> So there isnt a place to just inject render/update calls |
01:55:56 | FromDiscord | <Elegantbeef> Owlkettle handles the entire program loop |
01:56:05 | FromDiscord | <!Patitotective> hMmMm |
01:57:29 | FromDiscord | <Elegantbeef> And with that stream of defensiveness... 😄 |
01:57:40 | FromDiscord | <!Patitotective> should my declarative wrapper only draw things and not manage the actual app? so you can do your custom thing or maybe letting you change the default managing |
01:57:54 | FromDiscord | <Elegantbeef> That's between you and your god |
01:59:45 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=47Jj |
01:59:50 | FromDiscord | <!Patitotective> (edit) |
02:02:30 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=47Jm |
02:02:37 | FromDiscord | <Elegantbeef> What about what? |
02:03:57 | FromDiscord | <Elegantbeef> I mean you can do whatever you want patito, for my macro it's easier to not specialise procedures |
02:04:00 | FromDiscord | <Elegantbeef> It's like 30 loc |
02:07:47 | FromDiscord | <!Patitotective> hMmmM ok |
02:09:37 | FromDiscord | <Elegantbeef> For context pat, it's a very braindead simple macro https://github.com/beef331/truss3d/blob/master/src/truss3D/gui.nim#L96-L124 |
02:10:13 | FromDiscord | <Elegantbeef> And really that `gotPos` is redundant and i should just make `pos` optional |
02:11:32 | FromDiscord | <Elegantbeef> I also really should replace all usages of vmath with a concept |
02:15:34 | FromDiscord | <SrMordred> i need to experiment with nim asts again. ↵got a little traumatised after rust macros. |
02:16:22 | FromDiscord | <Elegantbeef> I like Nim's macros, there are tedious thing with the typed AST, but it's generally a good experience |
02:16:44 | FromDiscord | <Elegantbeef> I did start wrapping the API to make writing macros a bit more ergonomic https://github.com/beef331/micros/ |
02:17:43 | FromDiscord | <SrMordred> oh looks pretty nice at first glance |
02:19:17 | FromDiscord | <voidwalker> Any chance I'd get help for nimx here ? I want to draw images (https://github.com/yglukhov/nimx/blob/master/test/sample03_image.nim) as elements in a collection view (https://github.com/yglukhov/nimx/blob/master/test/sample07_collections.nim) so they get arranged automatically on window resize, like the netflix grid or something like that |
02:19:36 | FromDiscord | <voidwalker> And have them be clickable |
02:19:48 | FromDiscord | <Elegantbeef> It doesnt cover the entire AST presently, but yea it makes it more like using accessors and less like navigating AST manually |
02:20:03 | * | jmdaemon joined #nim |
02:20:18 | * | jmd_ quit (Ping timeout: 248 seconds) |
02:22:39 | FromDiscord | <Elegantbeef> I'd imagine you make your own view that on draw iterates all elements to draw and organises them into a grid |
02:23:04 | FromDiscord | <Elegantbeef> I've never used nimx so i dont know how to do anything with it |
02:28:20 | FromDiscord | <!Patitotective> In reply to @voidwalker "And have them be": not sure how nimx works but you could check if the mouse is clicked and an image is hovered |
02:28:22 | FromDiscord | <voidwalker> I wanted them to be collections, since the collection elements already can be autoarranged with their properties |
02:28:57 | FromDiscord | <voidwalker> Otherwise I'd have to find some algorithms for arranging items into a grid, depending on window sizes and such.. ugh |
02:30:44 | FromDiscord | <!Patitotective> In reply to @voidwalker "Otherwise I'd have to": you just have to know each element's size and divide it by the window size |
02:30:47 | FromDiscord | <!Patitotective> not so hard |
02:31:56 | FromDiscord | <Elegantbeef> SO why cant you just use a collection? |
02:34:42 | FromDiscord | <voidwalker> I don't know how to draw on the collection "Rect"s |
02:34:58 | FromDiscord | <voidwalker> In the sample code they are generated like this: |
02:35:16 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=47Jr |
02:35:25 | FromDiscord | <Elegantbeef> You'd just use an image instead of `newView` i'd believe |
02:35:33 | FromDiscord | <voidwalker> (edit) "https://play.nim-lang.org/#ix=47Jr" => "https://play.nim-lang.org/#ix=47Js" |
02:36:15 | FromDiscord | <voidwalker> The drawimage proc works like this: |
02:36:25 | FromDiscord | <voidwalker> https://media.discordapp.net/attachments/371759389889003532/1008927180849434725/unknown.png |
02:37:14 | FromDiscord | <voidwalker> but newRect looks like an anonymous Rect, to try and specify the toRect parameter |
02:39:50 | FromDiscord | <Elegantbeef> ImageSampleView is a view |
02:40:10 | FromDiscord | <Elegantbeef> So you'd setup the image then add it |
02:41:20 | FromDiscord | <voidwalker> Yeah I already figured out how to add the images in the sample code for ImageSampleView |
02:41:44 | FromDiscord | <voidwalker> But this whole concept of views and rects, I do not yet understand how they piece together |
02:42:43 | FromDiscord | <Elegantbeef> Yea me either i never grasp these types of APIs properly |
02:58:36 | * | arkurious quit (Quit: Leaving) |
03:19:40 | * | jmd_ joined #nim |
03:20:17 | * | jmdaemon quit (Ping timeout: 252 seconds) |
03:20:51 | FromDiscord | <flaorabtc> https://t.me/+sj30hB-ZyA03Nzg0I'll 20 people on how to earn $10,000 or more in just 3day's from the crypto market.but you will pay me 10% commission when you receive your profit. if interested send me a direct message, for more information... Contact via📩📩📩📩📩📩📩📩TELEGRAM💬@@FLORAGORDONhttps://t.me/+sj30hB-ZyA03Nzg0 |
03:21:25 | FromDiscord | <SaAnd> @Moderator |
03:30:22 | FromDiscord | <!Patitotective> <@&371760044473319454> |
03:30:42 | FromDiscord | <Girvo> Dumb question; I have an enum, ish. basically a set of uint16's that have meaning. `msgNoop` = 0, `msgSync` = 1, and so on. But we do not have every single `uint16` defined. We receive a uint16 over the network, and I'm currently casting it, to work out what it is and use it, but that obviously is unsafe and would break if it's a number thats not defined in the enum yet. I'm sure there is a better cleaner approach, so figured I'd ask |
03:31:58 | FromDiscord | <Elegantbeef> `type Message = distinct uint16`? |
03:32:00 | FromDiscord | <!Patitotective> if your enum does not have holes in it you can check if the number you receive is in `0..YourEnum.high` and if not you know it is not valid |
03:32:27 | FromDiscord | <Elegantbeef> If it's not contiguous it's fun |
03:32:30 | FromDiscord | <Girvo> Perfect |
03:32:33 | FromDiscord | <Girvo> In our case it is 🙂 |
03:32:44 | FromDiscord | <Girvo> `.high` is exactly what I was chasing haha |
03:35:16 | FromDiscord | <Elegantbeef> Also please tell me you were not doing `cast[MyEnum](val)` 😛 |
03:35:51 | FromDiscord | <Girvo> So what I did was I thought "what would cause beef the most pain to see" and did that 😄 |
03:36:04 | FromDiscord | <Elegantbeef> You can just do `MyEnum(myValue)` |
03:36:28 | FromDiscord | <Girvo> (I know I'm just messing with ya haha) |
03:41:21 | FromDiscord | <Girvo> Is it possible to ask the system to drop it's buffered data in a socket on the floor? I know I can check `socket.hasBufferedData` but I'm not sure what to do with it if it is true, and I've received a tag (and length and message) that I don't want to care about |
03:41:46 | FromDiscord | <Girvo> Sorry, `hasDataBuffered` |
03:42:22 | FromDiscord | <Elegantbeef> If you dont need buffered data you can create the socket unbuffered |
03:42:40 | FromDiscord | <Elegantbeef> Otherwise i dont imagine you can |
03:42:56 | FromDiscord | <Girvo> Okay, fair enough. Short of closing/reopening the socket |
03:44:02 | FromDiscord | <Girvo> Theres no way of asking the socket how much data it has buffered, is there? |
03:44:22 | FromDiscord | <Elegantbeef> I do not know, dont imagine so |
03:44:30 | FromDiscord | <Girvo> Yeah I can't see anything in `std/net` at least |
04:09:00 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JC |
04:11:17 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JD |
04:14:41 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JF |
04:15:19 | FromDiscord | <!Patitotective> (you can do `2u16` btw) |
04:15:28 | FromDiscord | <Girvo> Oh shit haha thats nicer 😄 appreciate it |
04:19:56 | FromDiscord | <Elegantbeef> Are you using `copyMem` for the getting types or doing `cast[ptr T](a[ind].addr)[]`? |
04:23:40 | FromDiscord | <Girvo> The latter at the moment |
04:23:48 | FromDiscord | <Girvo> Well, technically both |
04:23:52 | FromDiscord | <treeform> sent a code paste, see https://play.nim-lang.org/#ix=47JH |
04:23:59 | FromDiscord | <treeform> `addr buffer` takes address of the string structure not the data |
04:25:16 | FromDiscord | <treeform> and its `newSeq` |
04:25:21 | FromDiscord | <treeform> it it should have bytes in it to send |
04:28:27 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JI |
04:28:37 | FromDiscord | <Elegantbeef> `newSeq[byte](4)` |
04:28:38 | FromDiscord | <Girvo> So I must've missed something haha |
04:28:44 | FromDiscord | <Girvo> Ah yeah it needs a size |
04:28:45 | FromDiscord | <treeform> "it it should have bytes in it to recv" |
04:28:51 | FromDiscord | <Girvo> ^ I'm with you |
04:29:14 | FromDiscord | <treeform> it might be simpler to ↵`buffer = socket.recv(4)` |
04:30:00 | FromDiscord | <treeform> that is what i do: https://github.com/treeform/ws/blob/master/src/ws.nim#L332 |
04:30:19 | FromDiscord | <Elegantbeef> That does allocate a new string though |
04:30:41 | FromDiscord | <Elegantbeef> Girvo is embedded that's a nono |
04:31:28 | FromDiscord | <treeform> if that's the case yeah |
04:33:15 | FromDiscord | <treeform> but arc ref counting would take care the string even in embedded |
04:33:30 | FromDiscord | <Elegantbeef> yea but you're allocating |
04:40:02 | NimEventer | New Nimble package! imnotify - A notifications library for Dear ImGui, see https://github.com/Patitotective/ImNotify |
04:49:27 | FromDiscord | <Ras> In reply to @Girvo "Man I am doing": what is this for btw |
04:49:43 | FromDiscord | <Ras> seems an awful lot like something I've been working on for the last few days |
04:53:24 | FromDiscord | <Girvo> hah its a TLV-based TCP message system for communicating to an embedded microcontroller |
04:53:57 | FromDiscord | <Ras> ahhh, okay |
04:54:35 | FromDiscord | <Ras> not related to my thing in any way then :p |
04:57:43 | FromDiscord | <Ras> @dom96 y'all were talking about sqlite the other day, this was just posted on HN, seems relevant to your discussion |
04:57:45 | FromDiscord | <Ras> https://antonz.org/sqlite-is-not-a-toy-database/ |
05:03:54 | FromDiscord | <Phil> sent a long message, see http://ix.io/47JL |
05:13:40 | FromDiscord | <Girvo> Everyone always says "but I _will_ be write heavy" despite them building Yet Another Blog System where they post once a month at best lol |
05:17:00 | FromDiscord | <Girvo> sent a code paste, see https://paste.rs/nXH |
05:17:15 | FromDiscord | <Girvo> Ignore the double `and` just a typo copying it over |
05:17:19 | FromDiscord | <Elegantbeef> `(buf[1].uint16 shl 8)` |
05:17:37 | FromDiscord | <Girvo> (edit) "https://play.nim-lang.org/#ix=47JO" => "https://play.nim-lang.org/#ix=47JN" |
05:17:45 | FromDiscord | <Elegantbeef> also should be `or` no? |
05:18:02 | FromDiscord | <Elegantbeef> `and` would only keep the same bits |
05:18:53 | FromDiscord | <Rika> This is why you use the dedicated stuff in bitops |
05:19:10 | FromDiscord | <Girvo> Yeah Rika I'm about 2 seconds away from doing exactly that lol |
05:19:24 | FromDiscord | <Girvo> I was just trying to make sure I understood what it was actually doing |
05:19:31 | FromDiscord | <Rika> I’ll always be here to scold you for not using it 😉 |
05:19:59 | * | rockcavera quit (Remote host closed the connection) |
05:20:00 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JP |
05:20:01 | FromDiscord | <Girvo> Yeah works 😄 cheers beef haha |
05:20:19 | FromDiscord | <Elegantbeef> `and` being bitwise on ints was a mistake that even araq dislikes |
05:20:24 | FromDiscord | <Elegantbeef> Nim2.0 change?! 😄 |
05:20:32 | FromDiscord | <Girvo> Hah I'd definitely be okay with that breaking change |
05:21:55 | FromDiscord | <Rika> In reply to @Elegantbeef "`and` being bitwise on": I don’t dislike it personally |
05:22:14 | FromDiscord | <Rika> I’m not sure what the downside is |
05:22:14 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JQ |
05:24:10 | FromDiscord | <Prestige> I find myself trying to use & like other languages, but I'm on the same page with Rika about it |
05:24:30 | FromDiscord | <Rika> I dislike & |
05:24:47 | FromDiscord | <Rika> And I especially dislike | |
05:28:00 | FromDiscord | <Phil> TIL that `let x = 5 or 2` is valid nim |
05:28:27 | FromDiscord | <Phil> I don't understand why it is valid nim, but it does compile |
05:28:49 | FromDiscord | <Elegantbeef> `not` and `and` are the cause of many bugs 😄 |
05:28:49 | FromDiscord | <Rika> That’s the bitwise or |
05:29:14 | FromDiscord | <Elegantbeef> all the bits on in 5 and all the bits on in 2 |
05:29:17 | FromDiscord | <Rika> In reply to @Elegantbeef "`not` and `and` are": Not sure what you mean |
05:29:43 | FromDiscord | <Elegantbeef> Between order of operations and accidental usage of `not` `and` can cause issues |
05:29:50 | FromDiscord | <Elegantbeef> `not 10 == 30` |
05:30:26 | FromDiscord | <Rika> I guess I use parentheses very often |
05:32:17 | FromDiscord | <Girvo> I don't use them enough in Nim |
05:32:20 | FromDiscord | <Girvo> It looks nicer without them 😛 |
05:32:26 | FromDiscord | <Ras> oof, as someone new to nim, i would've never thought that the `or` and `and` keywords do bitwise operations - i would've only expected `|` and `&` to do those |
05:34:29 | * | kenran joined #nim |
05:34:31 | * | kenran quit (Client Quit) |
05:42:31 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JS |
05:43:05 | FromDiscord | <Girvo> I know `length` is right in this case, it's `2` as I have a two-byte `uint16` as `[4]` and `[5]` of data |
05:43:13 | FromDiscord | <Elegantbeef> length - 1? |
05:44:18 | FromDiscord | <Ras> how would one go about `discard`-ing in a synchronous proc but `await`-ing in an async proc when using the multisync macro? lines 4 and 6 https://media.discordapp.net/attachments/371759389889003532/1008974460654714960/unknown.png |
05:44:35 | FromDiscord | <Elegantbeef> `await` is removed with multisync afaik |
05:45:06 | FromDiscord | <Ras> yeah, as far as the documentation says, multisync strips `await`s when called synchronously |
05:45:26 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JT |
05:45:57 | FromDiscord | <Elegantbeef> Oh |
05:46:01 | FromDiscord | <Elegantbeef> `value[0].addr` |
05:46:04 | FromDiscord | <Elegantbeef> Or use an array |
05:46:40 | FromDiscord | <Girvo> Yeah shit thats what it was! |
05:46:41 | FromDiscord | <Girvo> Cheers 🙂 |
05:47:02 | FromDiscord | <Girvo> And yeah it'll be moved to an array shortly, this was just my first-pass at it with seq |
05:48:31 | FromDiscord | <Elegantbeef> You can also do `when c is Connection` i think↵(@Ras) |
05:48:44 | FromDiscord | <Ras> ah, great, thanks |
05:50:15 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=47JU |
06:24:05 | * | vicecea quit (Remote host closed the connection) |
06:24:33 | * | vicecea joined #nim |
06:30:29 | FromDiscord | <Ras> how do i actually.. return a future? very last line here https://media.discordapp.net/attachments/371759389889003532/1008986085658984528/unknown.png |
06:32:58 | FromDiscord | <Rika> Probably with explicit “return” |
06:34:49 | FromDiscord | <Ras> huh |
06:35:00 | FromDiscord | <Ras> also, what does this error mean https://media.discordapp.net/attachments/371759389889003532/1008987221371654204/unknown.png |
06:35:30 | FromDiscord | <Elegantbeef> Compile the code |
06:35:40 | FromDiscord | <Elegantbeef> That just states there is an issue with the template/generic |
06:39:42 | * | PMunch joined #nim |
06:58:06 | FromDiscord | <creikey> I have this asyncCheck'd function, where a few function calls deep an exception is raised and it's not caught in the block where I catch it here. What gives? https://media.discordapp.net/attachments/371759389889003532/1008993033410330634/unknown.png |
06:58:43 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/asyncdispatch.html#asynchronous-procedures-handling-exceptions |
06:58:54 | FromDiscord | <creikey> yeah I thought asynCheck re-raises it |
06:59:02 | FromDiscord | <Rika> No not necessarily |
06:59:05 | FromDiscord | <creikey> https://media.discordapp.net/attachments/371759389889003532/1008993280643584040/unknown.png |
06:59:07 | FromDiscord | <Rika> Sometimes it doesn’t work |
06:59:13 | FromDiscord | <Rika> I assume |
06:59:18 | FromDiscord | <Elegantbeef> > The async procedures also offer limited support for the try statement. |
06:59:24 | FromDiscord | <Rika> Otherwise there wouldn’t be that warning yes |
07:00:03 | FromDiscord | <creikey> In reply to @Elegantbeef "https://nim-lang.org/docs/asyncdispatch.html#asynch": if I yield the async dispatcher does other stuff right? It doesn't stall the whole thread like await |
07:00:16 | FromDiscord | <creikey> oh I see asyncCheck is completely not what I want |
07:01:02 | FromDiscord | <flywind> !eval type Mystring = string; echo typeof(default(Mystring)) |
07:01:03 | NimBot | Compile failed: Unable to open output log |
07:03:36 | FromDiscord | <flywind> It prints "string" in arc. |
07:04:00 | FromDiscord | <Elegantbeef> That seems correct |
07:04:44 | FromDiscord | <flywind> This still prints MyString |
07:04:55 | FromDiscord | <flywind> sent a code paste, see https://play.nim-lang.org/#ix=47K5 |
07:06:24 | FromDiscord | <flywind> (edit) "This still prints MyString ... " added "in ARC" |
07:06:35 | FromDiscord | <Elegantbeef> It's quite questionable what is correct 😄 |
07:09:15 | FromDiscord | <flywind> Yeah, I agree. My PR for default fields accidentally make the former one prints "string" in refc too. I'm checking this. |
07:09:56 | FromDiscord | <creikey> wait but like this is what I want to do https://media.discordapp.net/attachments/371759389889003532/1008996012985155584/unknown.png |
07:10:26 | FromDiscord | <creikey> like I would just write that code if I used yield instead of asyncCHeck |
07:10:27 | FromDiscord | <creikey> (edit) "asyncCHeck" => "asyncCheck" |
07:13:31 | FromDiscord | <Rika> What |
07:13:34 | FromDiscord | <Rika> What do you want to do |
07:14:07 | FromDiscord | <creikey> call some code I wrote from an async function and if it raises an exception catch it |
07:14:18 | FromDiscord | <creikey> I think I figured it out though |
07:14:26 | FromDiscord | <creikey> one of the functions in the call stack isn't tagged as async |
07:14:45 | FromDiscord | <creikey> I'm not completely sure about the semantics of it but I think that means the exception doesn't set the future as failed |
07:14:49 | FromDiscord | <creikey> and so it's uncaught |
07:14:50 | FromDiscord | <creikey> or something |
07:16:23 | FromDiscord | <Rika> In reply to @creikey "call some code I": Await should raise as well? |
07:16:50 | FromDiscord | <creikey> In reply to @Rika "Await should raise as": yeah asyncCheck keeps running |
07:17:12 | FromDiscord | <Rika> Well that’s because async check is more akin to a process fork then ignore |
07:18:22 | * | PMunch quit (Quit: Leaving) |
07:23:15 | FromDiscord | <creikey> like instead of this, I want to just get the data from the async function and if it failed re-raise the exception from the call sight, until the function I have handling the http requests handles it in a root try/catch statement https://media.discordapp.net/attachments/371759389889003532/1008999360496934942/unknown.png |
07:23:25 | * | PMunch joined #nim |
07:27:35 | * | gsalazar joined #nim |
07:30:12 | FromDiscord | <Girvo> Anyone have suggestions for a serialisation protocol thats space-efficient (binary, ideally) and works well in Nim? |
07:30:22 | FromDiscord | <creikey> In reply to @Girvo "Anyone have suggestions for": binny? |
07:31:43 | FromDiscord | <Elegantbeef> not really a protocol |
07:32:56 | FromDiscord | <Girvo> @creikey Looks interesting. We don't necessarily _need_ support from other languages, but it would be a nice-to-have. But BSON et al. all have various downsides, esp. for embedded use (its silly, but BSONs lack of support for uint8 and uint16 annoy me, and for some of our data really matters. Can be worked around of course, but ideally I don't want to lol) |
07:33:17 | FromDiscord | <creikey> In reply to @Girvo "<@180866243819995136> Looks interesting. We": I don't know how good capnproto's nim bindings are but it has excellent cross langaue support |
07:33:32 | FromDiscord | <Elegantbeef> Nim does have protobuf support |
07:33:37 | FromDiscord | <Girvo> yeah, i was also looking at MsgPack, ProtoBufs, etc. |
07:33:55 | FromDiscord | <Elegantbeef> Frosty might be the thing to go with, though you'd have to re-implement your format |
07:34:06 | FromDiscord | <Elegantbeef> It'd allow you to serialise directly to your target with a specific format |
07:34:14 | FromDiscord | <Girvo> Oh Frosty looks nice |
07:34:27 | FromDiscord | <Girvo> Wouldn't be too hard to wire in the TLV structure either |
07:35:00 | FromDiscord | <Girvo> `nimph clone disruptek/frosty` what in the hell is nimph haha |
07:35:15 | FromDiscord | <Elegantbeef> Disruptek's package manager |
07:35:25 | FromDiscord | <Girvo> Hah neat. Never heard of it |
07:35:46 | FromDiscord | <Elegantbeef> You've never met dis, but he writes great software, just a bit too abrasive so no longer here |
07:36:19 | FromDiscord | <Elegantbeef> Actually you might've met him |
07:36:24 | FromDiscord | <Elegantbeef> Forgot you used to use nim |
07:36:31 | FromDiscord | <Girvo> Haha yeah I remember him |
07:36:46 | FromDiscord | <creikey> async nim may have been a mistake to use for this |
07:37:10 | FromDiscord | <creikey> just watched the talk by the nim in action guy, it's just a macro that converts the proc to an iterator |
07:37:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=47Ke |
07:37:22 | FromDiscord | <Girvo> join me on the threaded dark side mwahaha |
07:37:32 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=47Kf |
07:37:35 | FromDiscord | <Girvo> I'm kidding, don't, it's pain over here 😭 |
07:37:51 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=47Kg |
07:38:07 | FromDiscord | <Elegantbeef> That's not what async is doing |
07:38:12 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/asyncmacro.nim#L128-L131 |
07:39:00 | FromDiscord | <creikey> so like you can't use try: with await at all ever? what does "unreliable" mean in the docs, under what circumstances does that fail |
07:39:24 | FromDiscord | <Elegantbeef> Actually that's kinda what it does |
07:39:30 | FromDiscord | <Elegantbeef> No clue how it is i've never really used async |
07:39:43 | FromDiscord | <Girvo> I reckon I'm going to go with MessagePack via `msgpack4nim` -- seems nice, and fits what I'm after |
07:40:21 | FromDiscord | <Elegantbeef> You could consider trying chronos' async |
07:40:38 | FromDiscord | <creikey> I just don't like how I don't understand what's going on in my program right now |
07:40:42 | FromDiscord | <creikey> like what code is actually running |
07:43:26 | FromDiscord | <creikey> I think my biggest point of confusion, is how do the callbacks actually work? |
07:43:37 | FromDiscord | <creikey> like when you call asyncCheck like this https://media.discordapp.net/attachments/371759389889003532/1009004488096481370/unknown.png |
07:43:45 | FromDiscord | <creikey> it registers a callback which raises the exception right |
07:44:05 | FromDiscord | <creikey> does that exception then get handled in the function asyncCheck was called in? |
07:44:06 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/asyncfutures.nim |
07:44:26 | FromDiscord | <Elegantbeef> It should go up the stack |
07:44:39 | FromDiscord | <Rika> Await will re raise the error |
07:44:41 | FromDiscord | <creikey> that's so weird though, like it's a function inside a function |
07:44:45 | FromDiscord | <Rika> I don’t think async check will |
07:45:00 | FromDiscord | <Elegantbeef> `discard await X`? |
07:45:20 | FromDiscord | <creikey> In reply to @Rika "I don’t think async": it does that though in the screenshot I sent right |
07:45:24 | FromDiscord | <Rika> No |
07:45:40 | FromDiscord | <creikey> it raises the exception in a proc declared inside a proc declared inside a proc |
07:45:48 | FromDiscord | <Rika> The callback is not called in the same function as the proc that calls async check |
07:45:57 | FromDiscord | <creikey> no way that's crazy |
07:46:01 | FromDiscord | <creikey> oohhh I get it |
07:46:02 | FromDiscord | <Rika> What |
07:46:04 | FromDiscord | <creikey> so what's the point of asyncCheck |
07:46:06 | FromDiscord | <creikey> wait |
07:46:08 | FromDiscord | <creikey> it just like |
07:46:10 | FromDiscord | <creikey> calls the callback |
07:46:13 | FromDiscord | <Ras> In reply to @Elegantbeef "Compile the code": i did, everything compiles and runs fine |
07:46:15 | FromDiscord | <Elegantbeef> do discard `Future[T]` |
07:46:16 | FromDiscord | <Ras> i have no idea why it's complaining |
07:46:18 | FromDiscord | <creikey> in the async runner |
07:46:20 | FromDiscord | <Ras> or what it's even complaining about |
07:46:21 | FromDiscord | <Rika> Async check does not call the |
07:46:22 | FromDiscord | <Rika> Yes |
07:46:24 | FromDiscord | <creikey> ohhhhh |
07:46:26 | FromDiscord | <creikey> that makes so much more sense |
07:46:30 | FromDiscord | <Elegantbeef> Phantom error restart editor if doesnt fix it cry↵(@Ras) |
07:46:39 | FromDiscord | <Ras> i am crying |
07:46:51 | FromDiscord | <creikey> so I should never use asyncCheck if I want my program to not crash on an exception |
07:47:03 | FromDiscord | <Rika> I guess |
07:47:07 | FromDiscord | <creikey> await reraises it though, but not "reliably" according to the documentaion |
07:47:08 | FromDiscord | <creikey> (edit) "documentaion" => "documentation" |
07:47:22 | FromDiscord | <Rika> Async check adds the handler to the future so you could do this (wait brb) |
07:47:29 | FromDiscord | <creikey> https://media.discordapp.net/attachments/371759389889003532/1009005465218322453/unknown.png |
07:47:31 | FromDiscord | <creikey> this is what await is |
07:47:49 | FromDiscord | <creikey> I don't really get this |
07:48:04 | FromDiscord | <creikey> https://media.discordapp.net/attachments/371759389889003532/1009005609095548948/unknown.png |
07:48:05 | FromDiscord | <creikey> auto in nim??} |
07:48:06 | FromDiscord | <creikey> (edit) "nim??}" => "nim??" |
07:48:11 | FromDiscord | <Elegantbeef> Yes |
07:48:14 | FromDiscord | <Rika> yes |
07:48:17 | FromDiscord | <Elegantbeef> It's often a nice way of writing generics |
07:48:48 | FromDiscord | <Elegantbeef> The multiasync await is for the sync variant |
07:48:54 | FromDiscord | <Elegantbeef> It creates a locally scoped await that is a no op |
07:49:03 | FromDiscord | <Elegantbeef> The latter is the one that's called for async procedrues |
07:49:05 | FromDiscord | <creikey> ohhh if you await on |
07:49:09 | FromDiscord | <creikey> something that's not async |
07:49:10 | FromDiscord | <creikey> it just does nothing |
07:49:23 | FromDiscord | <Elegantbeef> Inside multisync yes |
07:49:28 | FromDiscord | <creikey> this whole time I thought await was a language keyword or something |
07:49:34 | FromDiscord | <Rika> no lol |
07:49:37 | FromDiscord | <Ras> the multisync macro strips awaits |
07:49:47 | FromDiscord | <Rika> nim async is fully implemented as a library |
07:49:55 | FromDiscord | <creikey> In reply to @Rika "nim async is fully": like zero help from the compiler? |
07:50:05 | FromDiscord | <creikey> I tried reading the async macro but it was incomprehensible |
07:50:05 | FromDiscord | <Elegantbeef> Indeed |
07:50:06 | FromDiscord | <Rika> other than macros and closure iterators |
07:50:13 | FromDiscord | <Elegantbeef> This is why macro systems are good |
07:50:23 | FromDiscord | <Elegantbeef> Macro systems allow heavily extending the language in user space |
07:50:32 | FromDiscord | <Girvo> Indeed. A good language shouldn't need compiler support to add async behaviour |
07:50:42 | FromDiscord | <Elegantbeef> Rust devs cry |
07:50:58 | FromDiscord | <creikey> I thought rust async was all macros too |
07:51:02 | FromDiscord | <Elegantbeef> To be fair Girvo i'm surprised we got remoterefs to work in Nim's type system |
07:51:04 | FromDiscord | <Rika> is it |
07:51:09 | FromDiscord | <Elegantbeef> No rust is compiler support |
07:51:23 | FromDiscord | <Rika> In reply to @Girvo "Indeed. A good language": not sure why you think so, i'm not sure what i think of it myself |
07:51:26 | FromDiscord | <creikey> my brain is fried from nim async rn |
07:51:47 | FromDiscord | <Elegantbeef> Remember that in Rust all macro usage uses `!` and only can capture one block of code either `{}` or `()` |
07:51:57 | FromDiscord | <Girvo> @ElegantBeef I sort of am, but sort of am not surprised. There was nothing obvious that I could see that meant it _couldn't_ work, but then I remember trying to do some higher-kinded types stuff back in the v0.10 days and broke the compiler doing something that it technically could do lol |
07:52:06 | FromDiscord | <Ras> i literally just rewrote my library to support async alongside sync and i've found nim's async to be excellent to work with |
07:52:08 | FromDiscord | <Elegantbeef> so `async fn name(){}` wouldnt be possible with it |
07:52:26 | FromDiscord | <creikey> In reply to @Ras "i literally just rewrote": yeah I think I just don't know what's going on enough to avoid pitfalls |
07:52:30 | FromDiscord | <Rika> nim async is kinda funky but it aint bad at all no |
07:52:30 | FromDiscord | <creikey> I'm learning though |
07:52:46 | FromDiscord | <Elegantbeef> I know atleast one rust programmer that wishes Rust's was done in macro to not cause a engrained async system that requires compiler updates |
07:53:04 | FromDiscord | <Phil> Out of curiosity, was that you jumping in completely new to async or is nim's async just different? |
07:53:12 | FromDiscord | <Elegantbeef> The benefit of a async library means you can have multiple implementations that can coexist(atleast mostly) |
07:53:13 | FromDiscord | <Rika> who are you asking |
07:53:16 | FromDiscord | <Phil> question aimed at creikey |
07:53:21 | FromDiscord | <Girvo> In reply to @Rika "not sure why you": From a language implementation perspective, adding special-cased handling for async behaviour is a bit of a code-smell, IMO. But I'm biased for sure lol |
07:53:34 | FromDiscord | <creikey> In reply to @Isofruit "Out of curiosity, was": I've been using nim's async for 4 weeks with this program and read multiple documentation pages multiple itmes |
07:53:35 | FromDiscord | <Rika> In reply to @Girvo "From a language implementation": i see, that makes sense to me |
07:53:37 | FromDiscord | <creikey> (edit) "itmes" => "times" |
07:53:55 | FromDiscord | <Phil> In reply to @creikey "I've been using nim's": Nah meant more if you e.g. had to code asynchronously in other languages before |
07:54:12 | FromDiscord | <creikey> In reply to @Isofruit "Nah meant more if": yeah I did embedded async with micropython, pretty nice |
07:54:14 | FromDiscord | <creikey> also did async in python |
07:54:17 | FromDiscord | <creikey> and I wrote an async server in rust |
07:54:19 | FromDiscord | <Elegantbeef> I personally think the compiler should be a super small core and extensible in userspace as it makes it very good to write code with |
07:54:23 | FromDiscord | <creikey> that was used in production awhile ago |
07:54:27 | FromDiscord | <Elegantbeef> When you can make first class features in user space you have a good language |
07:54:28 | FromDiscord | <Phil> Because async is one of those things that imo first needs to break your brain in a very special kind of way before you start to get it |
07:54:29 | FromDiscord | <creikey> I also have written a good amount of async js |
07:54:45 | FromDiscord | <creikey> server side and client side |
07:54:55 | FromDiscord | <Phil> Check, then nim's async is just a bit different then I guess |
07:54:56 | FromDiscord | <creikey> I'm probably forgetting something else that I've done though I'm not very good at recording what I do |
07:55:13 | FromDiscord | <creikey> In reply to @Isofruit "Check, then nim's async": I just don't know what's going on, like await only works sometimes? what? |
07:55:22 | FromDiscord | <Phil> Like, rxjs legit broke me for a while before it made sense. |
07:55:24 | FromDiscord | <Elegantbeef> The thing that really makes it click to me is that `await`, `waitFor` and friends are just "give up CPU for async operations" |
07:55:24 | FromDiscord | <creikey> what does a function being "unreliable" even mean |
07:55:42 | FromDiscord | <Elegantbeef> I think huan said that sometimes try except will not compile |
07:55:59 | FromDiscord | <Elegantbeef> When it fails it sounded like it was a compile time failure not runtime, i might be wrong |
07:55:59 | FromDiscord | <creikey> I'm fine with not compiling but it made it sound like it would just sometimes not work, but still compile |
07:56:22 | FromDiscord | <creikey> In reply to @Elegantbeef "The thing that really": await and waitFor sound like they do the same thing to me is why it's been confusing |
07:56:43 | FromDiscord | <Elegantbeef> well `waitFor` is blocking and `await` is not |
07:56:52 | FromDiscord | <Elegantbeef> Hence why await on non async is an error |
07:56:53 | FromDiscord | <enthus1ast> waitFor drives its own async poll loop |
07:57:02 | FromDiscord | <creikey> yeah waitFor is the thing that starts the event handler |
07:57:10 | FromDiscord | <creikey> in other languages you use await for both |
07:57:16 | FromDiscord | <creikey> or the event handler is just started at the top |
07:57:21 | FromDiscord | <creikey> (edit) "at the top" => "implicitly" |
07:57:25 | FromDiscord | <creikey> because it's baked into the language |
07:57:27 | FromDiscord | <Elegantbeef> I mean you dont use them for both |
07:57:35 | FromDiscord | <Elegantbeef> You can waitfor an async procedure inside async code |
07:57:51 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=47Kj |
07:57:57 | FromDiscord | <Girvo> In reply to @Rika "i see, that makes": As an addition, any language with Generator support can have coroutines added, which can match the semantics of async/await 🙂 The only reason to special case it is to ensure `yield` isn't confusing with two subtly different usages. PHP got Async support via libraries this way! |
07:58:19 | FromDiscord | <enthus1ast> this is usefull for combining the async loop with other external event loops like for guis etc |
07:58:20 | FromDiscord | <Phil> In reply to @Elegantbeef "well `waitFor` is blocking": Wait... await is not blocking? |
07:58:23 | FromDiscord | <Phil> But... what? |
07:58:37 | FromDiscord | <Ras> it blocks in the current proc, no? |
07:58:39 | FromDiscord | <Elegantbeef> not blocking in the respects of async code |
07:58:47 | FromDiscord | <Elegantbeef> async gives up the cpu to operate |
07:58:55 | FromDiscord | <creikey> In reply to @Isofruit "Wait... await is not": I think await waits for the future you provide it and frees up the dispatcher to do other things |
07:58:59 | FromDiscord | <Elegantbeef> await says "here we will run a 'continuation'" |
07:59:12 | FromDiscord | <creikey> I have 0 clue how the dispatcher "resumes" the function though |
07:59:15 | FromDiscord | <creikey> with no compiler help |
07:59:22 | FromDiscord | <Elegantbeef> closure procedures |
07:59:22 | FromDiscord | <creikey> like isn't there a function stack and stuff |
07:59:22 | FromDiscord | <Girvo> Continuations, typically |
07:59:28 | FromDiscord | <Phil> Ohh not blocking as in your code is still waiting for future completion, but while it does so other operations can complete |
07:59:35 | FromDiscord | <creikey> yeah |
07:59:44 | FromDiscord | <Elegantbeef> closure iterators\ |
07:59:46 | FromDiscord | <Phil> If that's the case, why use waitfor? |
07:59:53 | FromDiscord | <Phil> If that literally blocks your CPU |
07:59:57 | FromDiscord | <Phil> (edit) "If that literally blocks your ... CPU" added "entire" |
07:59:59 | FromDiscord | <Phil> (edit) "If that literally blocks your entire CPU ... " added "Thread" |
07:59:59 | FromDiscord | <Elegantbeef> You only want your cpu to operate on that code |
08:00:26 | FromDiscord | <Rika> if you want to not use async |
08:00:26 | FromDiscord | <Elegantbeef> There are cases you may want that |
08:00:33 | FromDiscord | <enthus1ast> î often use waitFor when i use an async lib but my code is pretty much sync |
08:00:35 | FromDiscord | <creikey> In reply to @Elegantbeef "closure iterators\*": so the function's stack is on the heap? https://media.discordapp.net/attachments/371759389889003532/1009008758241906758/unknown.png |
08:00:46 | FromDiscord | <creikey> like in every async function all local variables aren't in the stack but are allocated on the heap |
08:00:54 | FromDiscord | <Elegantbeef> The environment is stored on the heap |
08:01:06 | FromDiscord | <Elegantbeef> That doesnt mean all local afaik |
08:01:18 | FromDiscord | <Elegantbeef> That's only the persistent variables |
08:01:43 | FromDiscord | <creikey> like somewhere the cpu is doing jmp to after the await statement, and all of the cpu's registers are the same as they were when it jmp'd to other things |
08:01:58 | FromDiscord | <Elegantbeef> Dont talk asm with me i dont speak that way |
08:02:00 | FromDiscord | <creikey> like the state of the function is the same |
08:02:06 | FromDiscord | <creikey> somehow |
08:02:16 | FromDiscord | <Elegantbeef> closure iterators are continuable functions |
08:02:21 | FromDiscord | <Girvo> Do you know much about coroutines and continuations? |
08:02:28 | FromDiscord | <Elegantbeef> So the way async macro works is to insert `yield` calls where they make sense |
08:02:31 | FromDiscord | <creikey> In reply to @Girvo "Do you know much": yeah coroutines work like this |
08:03:25 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/intern.html#code-generation-for-closures |
08:03:32 | FromDiscord | <Elegantbeef> Good writeup to explain how closures work in Nim |
08:03:39 | FromDiscord | <Girvo> Oh neat, it uses lambda lifting? |
08:03:47 | FromDiscord | <Elegantbeef> Yea |
08:04:40 | FromDiscord | <Girvo> Do we have escape analysis? |
08:04:52 | FromDiscord | <Elegantbeef> Nim does have some |
08:05:12 | FromDiscord | <Elegantbeef> This is why you cannot make a closure use a `var T` |
08:05:28 | FromDiscord | <Phil> To this day in my brain has understood the difference between closure and anonymous proc only "intellectually". Like, I know the difference is that the closure also captures its environment, but the consequences that arrive from that have never computed for me. |
08:06:11 | FromDiscord | <Phil> Like yeah, you get a variable from your surroundings... so a copy of the ref or value depending on its types so it might lead to side-effects if it's a ref-type... so? |
08:06:18 | FromDiscord | <Girvo> Yeah the unfortunate over-use of "closure" to just mean "anonymous procedure" in certain circles confuses things sometimes lol |
08:06:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=47Ko |
08:06:52 | FromDiscord | <Elegantbeef> Yea the fun part with calling conventions is they're very much not equivlent |
08:07:15 | FromDiscord | <creikey> what is lambda lifting 😭 |
08:07:23 | FromDiscord | <creikey> I'm like 5 terms deep rn |
08:07:43 | FromDiscord | <d4rckh> is there any when defined flag i can use to have different logic for when im compiling as a dll on windows? |
08:07:50 | FromDiscord | <Girvo> Lambda lifting is a way to "lift" a local function into a global scope, to put it badly/simply |
08:07:53 | FromDiscord | <creikey> no way the compiler moves lambda functions to global scope and passes captures variables as parameters??? |
08:07:55 | FromDiscord | <Girvo> https://en.wikipedia.org/wiki/Lambda_lifting |
08:07:58 | FromDiscord | <creikey> that's incredible |
08:07:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=47Kp |
08:08:06 | FromDiscord | <creikey> that's like how I would think to do it off the top of my head |
08:08:08 | FromDiscord | <creikey> but no idea how to do it |
08:08:13 | FromDiscord | <Rika> oh man lambda lifting might actually melt your mind |
08:08:17 | FromDiscord | <Girvo> Hahaha |
08:08:19 | FromDiscord | <Elegantbeef> When you're a compiler it's 'easy' |
08:08:33 | FromDiscord | <creikey> this is actually trolling |
08:08:38 | FromDiscord | <Rika> lol |
08:08:39 | FromDiscord | <Elegantbeef> this is also the only real compiler support async has, i think there have been specific PRs to get lambda lifting done |
08:08:44 | FromDiscord | <creikey> functional langauges are a lie |
08:08:47 | FromDiscord | <Elegantbeef> done for async\ |
08:08:57 | FromDiscord | <Girvo> All of this is very much in the functional programming language theoretics stuff, so if you've not come from programming language implementation or Lisps, it can seem a bit hairy |
08:09:17 | FromDiscord | <creikey> I should learn lisp at some point once I'm done spending hours trying to get an exception to be caught in nim async |
08:09:20 | FromDiscord | <Elegantbeef> Speaking of calling conventions, girvo did you see my bigbrain idea of using `{.inline.}` for the remotre refs |
08:09:43 | FromDiscord | <Elegantbeef> Since they dont exist at runtime we can use 'inline pointer procs' 😄 |
08:09:48 | FromDiscord | <Girvo> Ah I don't think I picked up on it -- shit yeah thats nice haha |
08:09:59 | FromDiscord | <creikey> > Repeated lifts may be used to convert a program written in lambda calculus into a set of recursive functions, without lambdas. This demonstrates the equivalence of programs written in lambda calculus and programs written as functions |
08:10:00 | FromDiscord | <creikey> is this proven |
08:10:08 | FromDiscord | <Girvo> Yes |
08:10:14 | FromDiscord | <creikey> what does that proof even look like |
08:10:15 | FromDiscord | <creikey> alien alnguage |
08:10:17 | FromDiscord | <creikey> (edit) "alnguage" => "language" |
08:10:18 | FromDiscord | <Girvo> Maths : |
08:10:20 | FromDiscord | <Girvo> (edit) ":" => "🙂" |
08:10:36 | FromDiscord | <Elegantbeef> It's a very minimal benefit but it does increase the chance that we get inlined code with the allocation and deallocations |
08:10:50 | FromDiscord | <Girvo> Yeah and with this, any possible benefit is worth it |
08:11:08 | FromDiscord | <Girvo> And it doesn't make it unclear or anything, so definitely worth it |
08:11:20 | FromDiscord | <Elegantbeef> I still dont know what to call it though, RemoteRef feels wrong |
08:11:31 | FromDiscord | <Girvo> Yeah I agree |
08:11:51 | FromDiscord | <Girvo> `FarRef` lol |
08:11:54 | FromDiscord | <creikey> lambda lifting is wackiest thing I've learned about this month |
08:12:32 | FromDiscord | <Girvo> Wait til you see how you can represent natural numbers using nothing but functions 😉 |
08:12:38 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/DXW |
08:12:59 | FromDiscord | <Girvo> https://sskelkar.github.io/representing-natural-numbers-in-lambda-calculus/ its pretty awesome! |
08:13:34 | FromDiscord | <Girvo> SICP is a book I highly recommend reading and working through if you find this stuff interesting |
08:13:36 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=47Kr |
08:14:02 | FromDiscord | <creikey> In reply to @Girvo "SICP is a book": if this is like rabbithole that doesn't help me write better programs I wouldn't want to |
08:14:32 | FromDiscord | <Girvo> Oh no, its one of the few books in this area that can _absolutely_ help you write better programs. But it's definitely a rabbithole! |
08:14:42 | FromDiscord | <Elegantbeef> The reason it cannot be captured is it's unsafe to hold onto a pointer↵(@Phil) |
08:14:58 | FromDiscord | <creikey> In reply to @creikey "so the first lambda": this is wrong |
08:14:59 | FromDiscord | <Elegantbeef> You do not know where that pointer came from it might be a stack variable |
08:15:22 | FromDiscord | <Elegantbeef> As such if you dont do escape analysis you get a stack variable and attempt to use it and it's wrong |
08:15:36 | FromDiscord | <Phil> In reply to @Elegantbeef "You do not know": So capturing means I must have a pointer to that exact value, I can't just do a copy of that value and keep it |
08:15:36 | FromDiscord | <Elegantbeef> Remember closures do not run where they're made |
08:15:36 | FromDiscord | <Elegantbeef> Or rather do not have to run |
08:15:52 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=47Kt |
08:15:52 | FromDiscord | <creikey> wait but isn't that fine |
08:16:05 | FromDiscord | <Elegantbeef> Well of course you can copy, but Nim assumes that for `var T` you want to hold onto the value |
08:16:07 | FromDiscord | <Elegantbeef> So it tells you it'd outlive the origin |
08:16:25 | FromDiscord | <Elegantbeef> As such you can either unsafely cast it to a pointer before the closure and use that or use a `ref T` |
08:16:45 | FromDiscord | <Elegantbeef> Since refs are Gc'd you can safely capture them as the closure ticks their lifetime |
08:17:13 | FromDiscord | <Elegantbeef> Closures actually copy the stack values declared in their stack scope, but for references they cannot |
08:17:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=47Kv |
08:18:27 | FromDiscord | <Phil> So an environment can consist of copied variable values and references to outside variable values |
08:18:33 | FromDiscord | <Phil> environment of a closure |
08:18:57 | FromDiscord | <Elegantbeef> It can hold onto any value that is safe to hold onto 😄 |
08:19:00 | FromDiscord | <Phil> And due to the var I tell nim I want a reference to a in my environment |
08:19:21 | FromDiscord | <Elegantbeef> attempting to hold onto `var T` in nim is saying "I want a checked pointer to T" |
08:19:34 | FromDiscord | <Elegantbeef> The error is due to that checked part |
08:19:45 | FromDiscord | <Elegantbeef> If you do `ptr T` there is no error |
08:20:22 | FromDiscord | <Phil> But then I basically risk a runtime error (panic? not sure) |
08:20:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=47Ky |
08:20:39 | FromDiscord | <Elegantbeef> No the issue with `ptr T` is not panics really |
08:20:47 | FromDiscord | <creikey> I'm sorry for using asyncCheck everywhere and making my program randomly crash I was listening to Free Bird when I wrote it |
08:20:48 | FromDiscord | <Elegantbeef> The issue with `ptr T` is dangling pointers |
08:21:13 | FromDiscord | <d4rckh> In reply to @d4rckh "is there any when": up |
08:21:15 | FromDiscord | <Elegantbeef> the safety that `var T` gives you is that the pointer isnt nil and also it's not dangling |
08:21:16 | FromDiscord | <Phil> Ah, which might keep memory unfree'd though it should be free'd ? |
08:21:33 | FromDiscord | <Elegantbeef> `when defined(windows) and defined(library)` i think |
08:21:38 | FromDiscord | <Elegantbeef> No |
08:21:51 | FromDiscord | <Elegantbeef> Dangling pointers are pointers to the stack that outlive their usage |
08:22:11 | FromDiscord | <d4rckh> ty |
08:22:51 | FromDiscord | <creikey> In reply to @Girvo "Oh no, its one": I'm looking at this book, I want to solve engineering problems and make good programs this seems like puzzle solving. Are those the same thing? I have no idea |
08:23:17 | FromDiscord | <Elegantbeef> What is printed? |
08:23:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=47Kz |
08:23:43 | FromDiscord | <Elegantbeef> remove `doOtherThing()` and what is printed? |
08:24:02 | FromDiscord | <Elegantbeef> You do have to love Nim to being so simple to explain dangling pointers |
08:24:20 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=47KA |
08:24:27 | FromDiscord | <Elegantbeef> That's not fine |
08:24:34 | FromDiscord | <creikey> (edit) "https://play.nim-lang.org/#ix=47KA" => "https://play.nim-lang.org/#ix=47KB" |
08:24:43 | FromDiscord | <creikey> but like A hasn't left the stack yet when the proc that increments it is called |
08:24:45 | FromDiscord | <Elegantbeef> That's a compiletime error that capturing `a` is unsafe |
08:24:57 | FromDiscord | <Elegantbeef> Except this procedure doesnt know you passed it a global variable |
08:25:11 | FromDiscord | <Elegantbeef> the global variable is declared after it and indirected with `var T` |
08:25:13 | FromDiscord | <creikey> returning a proc that captures a parameter is just like returning a struct that captures a parameter right? |
08:25:36 | FromDiscord | <Elegantbeef> returning a proc that captures a parameter is a closure procedure |
08:25:39 | FromDiscord | <mratsim> a closure is a struct, ptr to function + environment |
08:26:08 | FromDiscord | <creikey> like this is all fine right |
08:26:10 | FromDiscord | <creikey> sent a code paste, see https://play.nim-lang.org/#ix=47KC |
08:26:11 | FromDiscord | <creikey> how is that different |
08:26:21 | FromDiscord | <Elegantbeef> Cause you cannot hold onto `var int` |
08:26:27 | FromDiscord | <creikey> oh you can't do that either? |
08:26:28 | FromDiscord | <Elegantbeef> Nim doesnt have a borrow checker by default |
08:27:20 | FromDiscord | <creikey> I don't understand this error message though https://media.discordapp.net/attachments/371759389889003532/1009015488971538512/unknown.png |
08:27:30 | FromDiscord | <mratsim> {.experimental: "views".} might allow holding the var int |
08:28:40 | * | PMunch quit (Quit: Leaving) |
08:28:43 | FromDiscord | <mratsim> In reply to @creikey "I don't understand this": I wouldn't trudst the error message as you're treading an "here be dragons" code path |
08:29:30 | FromDiscord | <mratsim> 1. except maybe (big maybe) with the views flag, you can't assign "var T", it's not a first-class type |
08:30:15 | FromDiscord | <creikey> can you have a var type in an object? |
08:30:26 | FromDiscord | <ElegantBeef> With views you can |
08:30:28 | FromDiscord | <ElegantBeef> Not without |
08:30:35 | FromDiscord | <mratsim> try with `{.experimental: "views".}` |
08:30:36 | * | PMunch joined #nim |
08:30:39 | FromDiscord | <mratsim> unsure |
08:30:57 | FromDiscord | <Elegantbeef> Are we back?! |
08:31:00 | FromDiscord | <Elegantbeef> We are! |
08:32:08 | FromDiscord | <Elegantbeef> Due to the lack of views being on by default you cannot hold onto `var T` `lent T` or `openArray` presently |
08:32:30 | FromDiscord | <Elegantbeef> In 10 years when views come you'll be able to use them and it'll be borrow checked just like Rust's |
08:32:54 | FromDiscord | <Elegantbeef> Presently views is extremely experimental and results in a ton of bugs/codegen issues |
08:33:44 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=47KE |
08:34:49 | FromDiscord | <Elegantbeef> Welcome to dangling pointers |
08:34:59 | FromDiscord | <Phil> But... but that's its own stack variable!!! |
08:35:04 | FromDiscord | <Elegantbeef> `var a = 100` is a stack variable |
08:35:14 | FromDiscord | <Elegantbeef> so when you take the address of it you're taking the address of the stack |
08:35:22 | FromDiscord | <Phil> Is this the kind of crap that folks in C have to deal with on the regular? |
08:35:32 | FromDiscord | <Elegantbeef> then when you call `doOtherThing()` you write `30000` over that `100` then increment it |
08:35:45 | FromDiscord | <mratsim> In reply to @Isofruit "Is this the kind": assembly |
08:35:48 | FromDiscord | <Elegantbeef> So then when the program echos from that pointer it gets `30001` since that's in stack |
08:35:57 | FromDiscord | <mratsim> why take an address of an int |
08:36:08 | FromDiscord | <Elegantbeef> To explain dangling pointers to phil |
08:36:29 | FromDiscord | <Phil> The fact that the `var a` in `doOtherThing` is not getting its own piece of memory kind of breaks me |
08:36:41 | FromDiscord | <Elegantbeef> This is what the stack is for |
08:36:44 | FromDiscord | <enthus1ast> crazy; this also depends on the mm |
08:37:17 | FromDiscord | <Elegantbeef> The stack is a small chunk of reused memory that is often overwritten |
08:37:32 | FromDiscord | <mratsim> In reply to @Isofruit "The fact that the": Actually, here it's simple enough that compiled it doesn't use memory but register only or even optimized away |
08:37:35 | FromDiscord | <Elegantbeef> This is why dangling pointers are sketchy, they dont behave like other pointer issues |
08:37:43 | FromDiscord | <mratsim> In reply to @Elegantbeef "This is what the": it was a rhetorical question |
08:37:55 | FromDiscord | <Elegantbeef> Ah ok wasnt clear |
08:39:31 | FromDiscord | <Elegantbeef> Phil learning stack, he's going to be a god soon |
08:40:14 | FromDiscord | <Elegantbeef> Well with refc you have more operations so it's likely to corrupt the stack automatically |
08:40:23 | FromDiscord | <Elegantbeef> Orc/Arc are deterministic so corrupt the stack deterministically |
08:40:32 | FromDiscord | <Phil> In reply to @Elegantbeef "so when you take": Wait, "the address of the stack" as in that is one single namespace and any variable on the stack of equal name is equal?↵Like if I had an addr to a variable called "potato" any reassignment to "potato" writes to the same potato?↵Wait, could I even do redefinitions of one being `var potato = "potato"` and elsewhere `var potato = 5` ? |
08:40:42 | FromDiscord | <Elegantbeef> No |
08:40:45 | FromDiscord | <Elegantbeef> The name of the variable doesnt matter |
08:40:50 | FromDiscord | <Elegantbeef> It's a local variable in a procedure |
08:41:02 | FromDiscord | <Elegantbeef> It writes to the same spot in memory when the procedure stackframe is added |
08:41:15 | FromDiscord | <Elegantbeef> When you call `doThing` it grows the stack for that `a` |
08:41:27 | FromDiscord | <Elegantbeef> Then after the call the stack shrinks again |
08:41:51 | FromDiscord | <Elegantbeef> Then when you call `doOtherThing` it grows the stack again, so the two variables reside at the same place in memory |
08:42:04 | FromDiscord | <Elegantbeef> Which is why when you mutate that location after it appears to back propagate |
08:42:39 | FromDiscord | <Elegantbeef> Cause the two variables happen to take the same memory location on the stack, so taking address of the first accidently points to the second |
08:43:11 | FromDiscord | <Elegantbeef> The stack is linear memory, so when you take an address of it you never want that pointer to outlive the procedure |
08:43:17 | FromDiscord | <Elegantbeef> This part of what a borrow checker does |
08:46:02 | FromDiscord | <Phil> That is some wildly complicated source of errors |
08:46:19 | FromDiscord | <Elegantbeef> It's not that complicated 😄 |
08:49:24 | FromDiscord | <Elegantbeef> Learning that the stack is a fixed size ticker tape that your scoped value types are stored to is the first step! |
08:50:17 | FromDiscord | <Elegantbeef> Just dont think all value types are stored there like whoever did the otherday |
08:52:40 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=47KG |
08:53:03 | FromDiscord | <Phil> That's the first time I got exposed to this type of memory corruption I think |
08:53:24 | FromDiscord | <Elegantbeef> Yep and since it's not a checked pointer it doesnt give any indication |
08:54:05 | * | PMunch quit (Quit: Leaving) |
08:54:17 | FromDiscord | <Elegantbeef> These types of errors are why `ref` and `var` exist |
08:54:53 | FromDiscord | <Elegantbeef> These safe pointer types give you memory safety |
08:55:05 | FromDiscord | <Phil> It just seems like such a wild error that you get to provoke by coincidentally creating pointers to the same stack memory area |
08:55:20 | FromDiscord | <Elegantbeef> Atleast some variation of memory safety, there is dispute on what memory safety constitutes |
08:55:23 | * | PMunch joined #nim |
08:55:57 | FromDiscord | <Elegantbeef> You can do the same thing to the heap of course |
08:56:14 | FromDiscord | <Elegantbeef> Where you accidently free the memory you have on the heap but dont nil the pointer |
08:56:19 | * | PMunch quit (Client Quit) |
08:56:25 | FromDiscord | <Elegantbeef> It'll appear to work fine until you allocate onto that chunk again |
08:56:45 | FromDiscord | <Phil> With basically little to no type-safety checks in place I can see how you can easily break your own memory in C |
08:56:49 | FromDiscord | <Elegantbeef> Cause of how the heap works depending on what you're doing it might be a while before you allocate a block that fits the memory/page |
08:57:22 | FromDiscord | <Elegantbeef> Yea C's pointer types especially are comically bad |
08:57:28 | FromDiscord | <Elegantbeef> The fuck does a `T` even mean |
08:58:03 | FromDiscord | <Elegantbeef> That can mean `ptr ptr T` or `ptr UncheckedArray[T]` |
08:58:23 | FromDiscord | <Elegantbeef> There's probably even more that can mean |
08:58:52 | FromDiscord | <Elegantbeef> Pascal is a better language for a basis of an ABI language |
09:06:22 | FromDiscord | <4zv4l> is there a kind of Mutex type or something in Nim ?↵to modify a variable that is shared between threads |
09:06:23 | FromDiscord | <Phil> TIL back in the day Pascal and C were head to head, and now here we are, with nim with strong references to Pascal, generating C code |
09:07:26 | FromDiscord | <Elegantbeef> `std/locks`↵(@4zv4l) |
09:08:47 | FromDiscord | <4zv4l> why does the Lock need to be init and deinit ? |
09:09:38 | FromDiscord | <Elegantbeef> Not a clue |
09:10:58 | FromDiscord | <4zv4l> also how can I detach a Thread↵https://nim-lang.org/docs/threads.html |
09:11:01 | FromDiscord | <4zv4l> didn't find here |
09:11:40 | FromDiscord | <Elegantbeef> Dont think you can |
09:12:04 | FromDiscord | <4zv4l> what |
09:12:11 | FromDiscord | <4zv4l> cannot detach thread ? |
09:12:18 | * | PMunch joined #nim |
09:12:29 | FromDiscord | <Phil> For those that don't casually multi-thread, difference of detach to create? |
09:12:32 | FromDiscord | <Elegantbeef> Threads are threads they run the code you give them from when you create them |
09:13:08 | FromDiscord | <Elegantbeef> Based off C++ it seems like `createThread` does that |
09:13:08 | FromDiscord | <4zv4l> but what if I don't need to wait for it and just let it clean everything by itself ? |
09:13:12 | FromDiscord | <Elegantbeef> > Detaches the thread represented by the object from the calling thread, allowing them to execute independently from each other. |
09:13:29 | FromDiscord | <Elegantbeef> You literally just `createThread` and it starts detatched then |
09:13:39 | FromDiscord | <4zv4l> alright |
09:13:43 | FromDiscord | <4zv4l> so don't need to join |
09:13:45 | FromDiscord | <Elegantbeef> Why the hell would a thread start attached |
09:13:52 | FromDiscord | <Elegantbeef> That seems like someone designed the C++ API backwards |
09:14:29 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=47KP |
09:14:35 | FromDiscord | <Phil> ... I'm scared to ask what an attached thread is. In my mind-model threads are always independant from one another except in the regard that one thread might signal another or they might both access the same piece of memory |
09:14:49 | FromDiscord | <Phil> (edit) "is. In" => "is, but what is it?↵In" |
09:14:56 | FromDiscord | <Elegantbeef> Basically phil it's who does the cleanup |
09:15:04 | FromDiscord | <4zv4l> In reply to @Elegantbeef "> Detaches the thread": where did you see that description ? |
09:15:11 | FromDiscord | <Elegantbeef> From the C++ manual |
09:15:18 | FromDiscord | <4zv4l> oh not from Nim alright |
09:15:19 | FromDiscord | <Elegantbeef> The first result of "detach thread" i could find |
09:15:25 | FromDiscord | <Phil> As in who frees the memory they access and the memory the thread itself occupied? |
09:15:40 | FromDiscord | <4zv4l> so in Nim you don't have to call join if you don't want to wait for them right ? |
09:15:56 | FromDiscord | <Elegantbeef> You `joinThread` to blocking wait |
09:16:07 | FromDiscord | <Elegantbeef> If you dont want to block wait and want them to run you dont call anything but `createThread` |
09:16:24 | FromDiscord | <4zv4l> alright |
09:16:28 | FromDiscord | <4zv4l> thank you |
09:17:13 | * | PMunch quit (Quit: Leaving) |
09:17:30 | FromDiscord | <Phil> > In other words sets a thread's affinity. If you don't know what this means, you shouldn't use this proc.↵I like the style of whoever wrote the thread docs |
09:19:35 | FromDiscord | <4zv4l> yeah funny one xD |
09:20:26 | FromDiscord | <4zv4l> In reply to @Isofruit "> In other words": wondering what happen if you give too many cores you don't have to that function |
09:21:13 | * | PMunch joined #nim |
09:21:31 | FromDiscord | <Elegantbeef> Your OS scheduler handles it |
09:22:00 | FromDiscord | <4zv4l> so throws an error or give as much cores as it can ? |
09:22:52 | FromDiscord | <Elegantbeef> it probably just gives you a random core, but no clue |
09:29:12 | FromDiscord | <creikey> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/asyncdispatch.nim#L1961 where is the source of this function? |
09:29:45 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/asyncdispatch.nim#L1649 |
09:29:49 | FromDiscord | <creikey> yeah found it |
09:29:50 | FromDiscord | <creikey> with google |
09:32:56 | FromDiscord | <mratsim> In reply to @Isofruit "It just seems like": Not just an error, all exploits via "buffer overflow" use that |
09:33:39 | FromDiscord | <mratsim> In reply to @4zv4l "why does the Lock": register to the Linux/Windows kernel |
09:35:44 | FromDiscord | <Ras> In reply to @mratsim "Not just an error,": UAF seems like a more appropriate vuln to draw parallels here |
09:42:54 | FromDiscord | <creikey> can you await multiple futures in nim? |
09:43:01 | FromDiscord | <creikey> (edit) removed "in nim?" |
09:43:02 | FromDiscord | <creikey> (edit) "futures" => "futures?" |
09:46:59 | FromDiscord | <Rika> Yes |
09:47:12 | FromDiscord | <creikey> is it just straight up like |
09:47:13 | FromDiscord | <creikey> comma separte them |
09:47:16 | FromDiscord | <creikey> (edit) "separte" => "separate" |
09:47:27 | FromDiscord | <Rika> https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D |
09:47:30 | FromDiscord | <Rika> No |
09:48:05 | FromDiscord | <creikey> I think I should try to describe my actual problem so I can get higher level direction instead of looking to features like that |
09:48:17 | FromDiscord | <creikey> basically, I'm using the ws library to handle clients in a game right |
09:48:33 | FromDiscord | <creikey> standard stuff like this https://media.discordapp.net/attachments/371759389889003532/1009035930956480543/unknown.png |
09:48:58 | * | jmd_ quit (Ping timeout: 244 seconds) |
09:49:14 | FromDiscord | <creikey> at some point one of the clients will "start the game", so I have a long running operation where the timing of the game is managed |
09:49:32 | FromDiscord | <creikey> where the server will wait 60 seconds or whatever configured amount, announce to all the clients in the lobby the next phase of the game has started, etc |
09:50:17 | FromDiscord | <creikey> I used asyncCheck before to start that function but I think that's wrong because the exceptions spawned by it won't be caught, because my waitFor event loop isn't in a try: catch |
09:50:30 | FromDiscord | <creikey> I think what I should do is just register a callback on the future that does some logging if it fails for whatever reason then does nothing |
09:50:40 | FromDiscord | <creikey> is this correct? |
09:54:05 | FromDiscord | <Phil> My takeaway is that memory is evil |
09:54:16 | FromDiscord | <mratsim> In reply to @creikey "I think what I": Your future can return an error code or a variant, and you can log as well, in-place, for debugging |
09:54:19 | FromDiscord | <Phil> (in reference to the earlier debate) |
09:55:04 | FromDiscord | <mratsim> In reply to @Isofruit "My takeaway is that": it's something to learn |
09:55:13 | FromDiscord | <mratsim> and the abstraction of it something to appreciate |
09:55:30 | FromDiscord | <creikey> In reply to @mratsim "and the abstraction of": writing linked list in rust is classic just remembered that |
09:55:43 | FromDiscord | <mratsim> it also explain why unsafeAddr is considered unsafe or why Rust is important |
09:56:35 | FromDiscord | <mratsim> though I think the memory safety part is overblown. It's way less tricky than deadlocks, livelocks and race conditions which the borrow checker doesn't prevent at all. |
09:57:28 | FromDiscord | <creikey> In reply to @mratsim "though I think the": yeah, in rust I found I still spent a lot of time debugging compared to C/C++, it was just logic errors/subtle properties of RAII/etc |
09:57:31 | FromDiscord | <Phil> ... Can you even do that without making it impossible to program useful stuff? |
09:57:44 | FromDiscord | <creikey> I really wish a new programming language would make debugging easier instead of trying to eliminate bugs with language features |
09:57:57 | * | vicecea quit (Remote host closed the connection) |
09:58:05 | FromDiscord | <creikey> like imagine if you put as much effort into making the rust compiler as you did into like the super ultra debugger 3000 that helped out and visualized all of that stuff |
09:58:22 | FromDiscord | <creikey> so much more productive |
09:58:27 | * | vicecea joined #nim |
09:58:45 | FromDiscord | <Phil> Hmmm shouldn't rust be capable of preventing race conditions since it can prevent shared mutable state (outside of databases but for that shit I think bets are off in general) |
09:58:54 | FromDiscord | <Phil> (edit) "Hmmm shouldn't rust be capable of preventing race conditions since it can prevent shared mutable state (outside of databases but for that shit I think bets are off in general) ... " added "?" |
10:00:23 | FromDiscord | <Phil> I guess I just answered my own question I am realizing |
10:01:22 | FromDiscord | <mratsim> In reply to @Isofruit "Hmmm shouldn't rust be": they prevent data races with ownership, but race conditions are different |
10:01:59 | FromDiscord | <mratsim> https://en.wikipedia.org/wiki/Dining_philosophers_problem |
10:05:04 | FromDiscord | <mratsim> sent a long message, see http://ix.io/47KX |
10:05:15 | FromDiscord | <mratsim> (edit) "http://ix.io/47KX" => "http://ix.io/47KY" |
10:10:30 | FromDiscord | <Rika> Don’t some rust programmers conflate the two? |
10:11:26 | FromDiscord | <dom96> In reply to @creikey "I think what I": yes, for server apps you should create a `asyncLog` proc that you can call to set up this call back |
10:32:21 | FromDiscord | <Ras> i have a list of enums: https://media.discordapp.net/attachments/371759389889003532/1009046955722289192/unknown.png |
10:32:54 | FromDiscord | <Ras> and a list of corresponding objects |
10:32:57 | FromDiscord | <Ras> https://media.discordapp.net/attachments/371759389889003532/1009047103516971038/unknown.png |
10:33:10 | FromDiscord | <mratsim> In reply to @Rika "Don’t some rust programmers": sure they do, and then they think Rust is the holy grail for thread safety |
10:33:37 | FromDiscord | <Ras> how would one go about associating these? I'd like to look up the enum to see which object to unmarshall json to |
10:34:00 | FromDiscord | <mratsim> In reply to @Ras "how would one go": object variant? |
10:34:00 | FromDiscord | <Ras> i think a switch is the easiest option, probably? |
10:34:03 | FromDiscord | <Ras> object variant? |
10:34:38 | FromDiscord | <mratsim> https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants |
10:35:23 | FromDiscord | <mratsim> see: https://github.com/mratsim/chirp8/blob/master/src/cpu.nim#L25-L89 |
10:35:40 | FromDiscord | <Ras> oh, fancy |
10:35:41 | FromDiscord | <Ras> thanks |
10:35:46 | FromDiscord | <creikey> In reply to @dom96 "yes, for server apps": Did you see my thing about cloudflare not stopping big websockets packets? Is this something I should fork ws and block to prevent or should I not worry about it? |
10:50:26 | FromDiscord | <Ras> @mratsim unfortunately, doesn't work for my case |
10:50:29 | FromDiscord | <Ras> https://media.discordapp.net/attachments/371759389889003532/1009051520014229604/unknown.png |
10:51:40 | FromDiscord | <Ras> actually, since everything has a base of 0x8000000, i can just base everything off 0 and just do a logical and later |
10:51:51 | FromDiscord | <Ras> (edit) "logical and" => "bitwise AND" |
11:07:47 | FromDiscord | <krisppurg> quick question, when was duplicatemoduleimport added to nim? |
11:09:54 | FromDiscord | <Ras> In reply to @mratsim "https://nim-lang.org/docs/tut2.html#object-oriented": actually, i still can't do that, as multiple different "kinds" can have the same value |
11:10:16 | FromDiscord | <Ras> the compiler complains that i'm trying to redefine it |
11:10:33 | FromDiscord | <Ras> https://media.discordapp.net/attachments/371759389889003532/1009056565292175360/unknown.png |
11:14:34 | FromDiscord | <Rika> Yes you will have to change the field name |
11:18:32 | * | PMunch quit (Quit: Leaving) |
11:28:31 | FromDiscord | <Ras> that's not possible in my case |
11:28:56 | FromDiscord | <Ras> as the json i'm unmarshalling is not mine |
11:29:13 | FromDiscord | <Ras> i just did a case statement |
11:30:53 | * | dnh joined #nim |
11:34:09 | FromDiscord | <Rainbow Asteroids> if all of your variants have the field `change`, then you can put the change string outside of the case statement |
11:34:27 | FromDiscord | <Ras> nope, unfortunately not all of them do |
11:34:37 | FromDiscord | <Ras> some of them have a duplicate "id" as well, which others lack |
11:34:43 | FromDiscord | <Ras> (edit) ""id"" => "`id`" |
11:44:26 | * | PMunch joined #nim |
11:57:28 | * | PMunch quit (Quit: Leaving) |
12:06:56 | FromDiscord | <rakgew> sent a code paste, see https://play.nim-lang.org/#ix=47Li |
12:06:57 | FromDiscord | <b1rdf00d> sent a code paste, see https://paste.rs/dWK |
12:09:19 | * | PMunch joined #nim |
12:18:06 | FromDiscord | <dom96> In reply to @creikey "Did you see my": I didn't, no. Might be worthwhile to handle in the ws library |
12:18:13 | FromDiscord | <domosokrat> sent a code paste, see https://play.nim-lang.org/#ix=47Lk |
12:19:48 | FromDiscord | <creikey> In reply to @dom96 "I didn't, no. Might": I did test just sending a frame with a really big promised size but the actual data wasn't that big, and it seemed like cloudflare handled it, but I forgot to do a control experiment locally to see if I did it right |
12:22:05 | FromDiscord | <rakgew> domosokrat thank you so much!!↵now the ptr has some content. so in general when C says\: `something` it would be `addr ptr something` in nim? |
12:24:12 | FromDiscord | <Ras> In reply to @b1rdf00d "I ran into this": interesting, thanks |
12:27:17 | FromDiscord | <rakgew> ah ok - it looks different on the book link - thx! |
12:33:57 | FromDiscord | <rakgew> coming from python, C with all its ptrs and addrs are still fairly confusing to me.. |
12:34:31 | FromDiscord | <domosokrat> rakgew\: Yes, in general if in C a function parameter is `f(something p)` it means to pass the address to an `something p`. Which translates to `var p: ptr something; f(addr p)` |
12:35:34 | FromDiscord | <rakgew> I see. thank you so much for explaining! |
12:38:02 | * | xet7 quit (Quit: Leaving) |
12:39:10 | FromDiscord | <rakgew> in the example ot the scm book what would be the equivalent to this stragne line in nim?\:↵`git_commit commit = (git_commit)head_commit;`↵left side seems clear-ish to me\: a ptr variable of type git\_commit, but what is going on on the other side of `=` ? are they casting head commit into `ptr git_commit` ? |
12:41:15 | FromDiscord | <EyeCon> In reply to @Girvo "Anyone have suggestions for": CBOR - I hope no one said it yet, I was away for some time |
12:41:35 | FromDiscord | <EyeCon> No direct Nim support but it's easy to do it yourself |
12:41:47 | FromDiscord | <EyeCon> If you're interested, I can share some code |
12:41:52 | FromDiscord | <rakgew> cool it worked\: `let git_commit = cast[ptr git_commit](head_commit)` |
12:42:06 | FromDiscord | <demotomohiro> `f(something p)` might also means to pass the array of pointers. We cannot tell what you what the C function takes only from signature. You would better to check the manual or refernce of the library. |
12:43:54 | FromDiscord | <rakgew> @demotomohiro thanks for the headsup on multiple meaning.↵yep, I m reading it in the libgit2 api docs\:↵https://libgit2.org/libgit2/#HEAD/group/repository/git_repository_open |
12:44:49 | FromDiscord | <rakgew> @demotomohiro are you the author of\:↵https://internet-of-tomohiro.netlify.app/nim/clibrary.en.html↵by any chance? that was very helpful for me!! |
12:47:13 | FromDiscord | <mratsim> mmmh, the forum search / user history doesn't allow me to find this thread because it only display 10 results: https://media.discordapp.net/attachments/371759389889003532/1009080893220069426/unknown.png |
12:49:53 | FromDiscord | <demotomohiro> In reply to @rakgew "<@288750616510201856> thanks for the": That is the case @domosokrat said. |
12:50:47 | FromDiscord | <demotomohiro> In reply to @rakgew "<@288750616510201856> are you the": Yes. I'm glad to help you. |
12:52:13 | FromDiscord | <mratsim> sent a long message, see http://ix.io/47Lp |
12:52:41 | FromDiscord | <demotomohiro> In reply to @Girvo "Anyone have suggestions for": https://github.com/jangko/msgpack4nim↵msgpack is binary, space effient and there is pure Nim library. |
13:02:23 | FromDiscord | <Rika> In reply to @EyeCon "No direct Nim support": https://git.sr.ht/~ehmry/nim_cbor |
13:03:15 | FromDiscord | <Rika> also pure nim iirc |
13:03:40 | FromDiscord | <Rika> its "json but binary, but also better than bson" |
13:05:10 | FromDiscord | <EyeCon> In reply to @Rika "https://git.sr.ht/~ehmry/nim_cbor": Ah, thanks, now that you mention it I think I saw this implementation but it was lacking something, can't remember exactly what it was |
13:30:48 | * | gsalazar quit (Read error: Connection reset by peer) |
13:31:00 | * | gsalazar joined #nim |
13:32:00 | ehmry | nim_cbor has a wierd interface, I'm not sure how people use cbor in practice |
13:33:27 | ehmry | EyeCon if you remember what it was let me know |
13:33:28 | FromDiscord | <Rika> i used it before; ended up changing most of the library anyway xd never upstreamed it because i never finished changing it |
13:33:42 | FromDiscord | <Rika> sorry i also forgot what changes i needed |
13:35:01 | ehmry | seems like whenever you are using cbor you want some application specific optimizations |
13:50:25 | ehmry | the proper thing to do would be a CDDL to Nim code generator, which I would do if there where more CDDL schemas |
13:54:22 | FromDiscord | <Rika> does that stand for "common data description language" or smth |
13:54:25 | FromDiscord | <Rika> close |
13:54:34 | FromDiscord | <Rika> concise data definition language |
14:12:23 | FromDiscord | <EyeCon> In reply to @ehmry "EyeCon if you remember": Sure, I'll take a look again |
14:15:07 | FromDiscord | <EyeCon> ehmry: Based on how I used CBOR in a toy project, can it be that it doesn't serialize/unserialize objects directly (a la jsony)? |
14:15:44 | FromDiscord | <EyeCon> That's how I planned to use CBOR anyway |
14:17:42 | * | jkl quit (Ping timeout: 268 seconds) |
14:18:03 | * | jkl joined #nim |
14:23:28 | PMunch | Huh, I've been considering to write a small program which can add files and webpages to a taskwarrior task and allow me to open those things automatically. Lo and behold I did some googling and someone had already written such a tool, and it's written in Nim! |
14:23:32 | PMunch | https://github.com/jschlatow/taskopen |
14:28:25 | * | arkurious joined #nim |
14:30:32 | FromDiscord | <Rika> nice |
14:34:36 | * | PMunch quit (Quit: Leaving) |
14:36:23 | FromDiscord | <rakgew> sent a code paste, see https://paste.rs/Chg |
14:41:42 | FromDiscord | <rakgew> sent a code paste, see https://play.nim-lang.org/#ix=47LZ |
14:44:24 | FromDiscord | <rakgew> is ther clever way to turn it into array of strings? |
14:45:27 | FromDiscord | <mratsim> In reply to @rakgew "is ther clever way": Whats the type of ``strings`` ? |
14:45:34 | FromDiscord | <rakgew> when I `echo tag_list.strings[]` it gives me\: "v0.1.0"↵but shoud there not be all tags? |
14:46:20 | FromDiscord | <rakgew> type of strings is\: `ptr cstring` |
14:47:16 | FromDiscord | <rakgew> but I hoped I could find all tags in there and just need to split with special char.. (?) |
14:48:34 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#ix=47M2 |
14:50:08 | FromDiscord | <mratsim> In reply to @rakgew "when I `echo tag_list.strings[]`": you probably wrapped it wrong |
14:50:21 | FromDiscord | <rakgew> @mratsim thanks so much! will try.. (I never implemented an itertor in nim but I m sure I can find info on that in the docs) |
14:50:54 | FromDiscord | <rakgew> well it is wrapped by nimgit2 via nimterop |
14:54:11 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#ix=47M5 |
14:54:48 | FromDiscord | <rakgew> amazing! thanks heaps!! |
14:54:52 | FromDiscord | <mratsim> Be sure to properly allocate and deallocate the memory to store the cstring |
14:55:35 | FromDiscord | <rakgew> will try! \:-D |
14:57:35 | * | kenran joined #nim |
14:59:07 | * | kenran quit (Client Quit) |
15:11:02 | FromDiscord | <rakgew> sent a code paste, see https://paste.rs/l5c |
15:12:19 | FromDiscord | <rakgew> are there now 2 versions of git\_strarray with the same name? |
16:11:07 | FromDiscord | <ezquerra> Would it be possible to have something akin to Python's breakpoint() keyword, which would make gdb pause whenever the keyword is used? I've been trying to use gdb to debug some nim code and I was not able to do it because gdb only knows about the compiled nim code |
16:11:23 | FromDiscord | <ezquerra> I find that debugging is one of the weakest parts of the "nim experience" |
16:13:15 | FromDiscord | <ezquerra> Or maybe it is just that I don't have things setup correctly 😅 |
16:16:49 | FromDiscord | <auxym> yeah tooling for nim in general (including debugging) isn't it's strong point |
16:17:23 | FromDiscord | <ezquerra> In an ideal world I'd be able to just create a breakpoint in VSCode, start a debug session and the program would pause when the breakpoint is hit, showing all the nim variable names (not the translated C ones) in the VSCode debugger |
16:18:22 | FromDiscord | <auxym> I'm not aware of anything like python's breakpoint statement, but gdb is pretty powerful, you can set breakpoints in a startup file. I think the saem nim extension for vscode supports debugging now, too? I wasn't able to get it working though |
16:19:14 | FromDiscord | <Rika> nim has a gdb wrapper |
16:19:26 | FromDiscord | <ezquerra> But I would settle for something less fancy, like creating breakpoints using an explicit breakpoint() call which would pause the program and maybe drop me into some kind of basic (nim) "repl" which would let me echo the list of variables that are in scope with their values or something like that |
16:19:31 | FromDiscord | <Generic> it only works with gc ref though if, on those days where it decides to work at all |
16:19:43 | FromDiscord | <Generic> do you compile with --debugger:native? |
16:19:52 | FromDiscord | <ezquerra> I did that |
16:20:01 | FromDiscord | <ezquerra> Then I ran gdb myprogram.exe |
16:20:20 | FromDiscord | <ezquerra> But I did not know how to set a breakpoint based on the nim filename and line number |
16:20:40 | FromDiscord | <Generic> weird, did you try a few different locations |
16:22:31 | FromDiscord | <Generic> ? |
16:22:57 | FromDiscord | <Rika> have you seen this |
16:22:58 | FromDiscord | <Rika> https://internet-of-tomohiro.netlify.app/nim/gdb.en.html |
16:23:10 | * | Jjp137 quit (Ping timeout: 244 seconds) |
16:28:25 | FromDiscord | <ezquerra> I did not know about that |
16:34:54 | FromDiscord | <ezquerra> sent a long message, see http://ix.io/47MA |
16:43:09 | FromDiscord | <domosokrat> That sounds like a gdb without python support. |
16:43:59 | FromDiscord | <domosokrat> But I have no idea where to find one with it for windows |
17:04:14 | FromDiscord | <rakgew> yay - I was able to solve the git\_strarray from earlier with a snippet from gittyup lib\:↵`echo "[INFO]: ", cstringArrayToSeq(cast[cstringArray](tag_list.strings), tag_list.count)`↵with that it nicley lists all the git tags into a cstring seq. \:-D |
17:08:59 | * | jmdaemon joined #nim |
17:28:41 | * | pro joined #nim |
17:37:18 | FromDiscord | <ezquerra> The gdb that I am using is the one that is part of the windows nim distribution, so I would expect it to work well with the nim-gdb.py script? |
17:38:16 | * | pro quit (Quit: pro) |
17:43:49 | FromDiscord | <domosokrat> I would have expected that too.↵(@ezquerra) |
17:48:59 | * | xet7 joined #nim |
17:49:15 | FromDiscord | <ezquerra> In any case, I just gave it a try on a Linux system. In there nim-gdb fails because it cannot find nim-gdb.py. It looks for it on /home/ezquerra/.nimble/tools/nim-gdb.py, but there is no tools folder under .nimble. Instead I can find the file in /home/ezquerra/.choosenim/toolchains/nim-1.6.6/tools/nim-gdb.py |
17:50:37 | FromDiscord | <ezquerra> sent a long message, see http://ix.io/47MW |
17:50:53 | FromDiscord | <ezquerra> However, I can still not set breakpoints by referencing the nim source files |
17:52:53 | * | rockcavera joined #nim |
17:52:53 | * | rockcavera quit (Changing host) |
17:52:53 | * | rockcavera joined #nim |
17:58:01 | FromDiscord | <ezquerra> Are people just using echo for debugging? |
17:59:51 | FromDiscord | <Rainbow Asteroids> pros use `stdout.write` |
18:03:40 | FromDiscord | <ezquerra> In most cases when I am debugging all I want is to be able to see or explore the values of the variables that are in scope on a certain location. Is there a way to do that with a macro, for example? |
18:05:35 | FromDiscord | <domosokrat> There is dump in the sugar module |
18:06:01 | FromDiscord | <domosokrat> Ah, you want all, I guess. |
18:06:06 | FromDiscord | <ezquerra> Yeah, but you must manually dump the vars you are interested in |
18:06:07 | FromDiscord | <ezquerra> yeah |
18:06:20 | FromDiscord | <domosokrat> Ignore my answer then |
18:06:23 | FromDiscord | <ezquerra> That is the most basic feature of a debugger |
18:06:59 | FromDiscord | <ezquerra> Can a macro get the list of the variables that can be accessed from the current scope? |
18:09:31 | FromDiscord | <domosokrat> I just tried nim-gdb. I can set breakpoints for nim files. |
18:10:56 | FromDiscord | <Phil> .... You can? |
18:11:06 | FromDiscord | <Phil> As in, you can inspect the value stuff has at a given time? |
18:11:13 | FromDiscord | <Phil> Like java debugger breakpoints? |
18:12:00 | FromDiscord | <Phil> In reply to @ezquerra "Are people just using": Someone who jumped into nim from higher level languages: Yes, that is my debugging way of life, though mostly less debugging and more logging |
18:12:19 | FromDiscord | <Phil> Which amounts to the same in the end but the latter one has a fancy framework attached! |
18:13:24 | FromDiscord | <domosokrat> @ezquerra\: I don't know about java debugger breakpoints. But inspecting variables works, e.g. via `info locals` |
18:13:25 | FromDiscord | <Phil> (edit) "Someone" => "As someone" |
18:13:32 | FromDiscord | <Prestige> In reply to @Isofruit "As in, you can": I can as well |
18:13:45 | FromDiscord | <Phil> wild, I'll need to look into that |
18:14:03 | FromDiscord | <domosokrat> sorry, should have tagged @Phil |
18:14:32 | FromDiscord | <Phil> I assume demo has a guide for that? |
18:16:32 | FromDiscord | <Phil> He does! Sweet↵Thanks @demotomohiro |
18:25:44 | FromDiscord | <ezquerra> In reply to @domosokrat "<@974046326088163438>\: I don't know": How can I use info locals if I cannot set a breakpoint? |
18:27:14 | * | xaltsc quit (Ping timeout: 255 seconds) |
18:28:08 | * | xaltsc joined #nim |
18:28:24 | FromDiscord | <ezquerra> In reply to @Isofruit "Which amounts to the": I think logging has its place, but an using an actual debugger can help a lot in many cases |
18:28:53 | FromDiscord | <domosokrat> The thing is, for me something like `break five_clique.nim:115` works↵(@ezquerra) |
18:33:25 | * | Jjp137 joined #nim |
18:37:18 | FromDiscord | <ezquerra> In reply to @domosokrat "The thing is, for": Umm, I just recompiled and tried again (on Linux) and it worked! |
18:37:30 | FromDiscord | <ezquerra> It is probably not the recompilation but something that I was doing wrong before |
18:39:57 | FromDiscord | <ezquerra> So this seems better than I thought :). However, it does not work out of the box on Linux, and it does not seem to work at all on Windows :/ |
18:51:07 | FromDiscord | <krisppurg> sent a code paste, see https://play.nim-lang.org/#ix=47Ni |
18:59:08 | FromDiscord | <Kermithos> are you on windows? |
19:01:07 | FromDiscord | <domosokrat> are you using openssl3? nim currently does not work with openssl3 |
19:11:31 | * | PMunch joined #nim |
19:45:48 | * | kenran joined #nim |
19:49:18 | FromDiscord | <erde74> sent a code paste, see https://play.nim-lang.org/#ix= |
20:27:06 | FromDiscord | <Bung> whats this meaning in c `sizeof(IOleObject )` |
20:35:05 | ehmry | EyeCon: I may have done that already https://git.sr.ht/~ehmry/nim_cbor/commit/c7c3ae0d9c82c7bcffbb919abd0fcc4992110770 |
20:42:53 | * | niminal joined #nim |
20:42:59 | * | kenran quit (Quit: WeeChat info:version) |
20:43:20 | FromDiscord | <Elegantbeef> It gets the size of a pointer↵(@Bung) |
20:44:08 | FromDiscord | <Bung> but pointer size is constant ? |
20:44:42 | FromDiscord | <Bung> int32 or int64 depends on arch |
20:44:58 | FromDiscord | <Elegantbeef> Yes? |
20:45:03 | FromDiscord | <Elegantbeef> They get the size of a pointer from that |
20:45:41 | FromDiscord | <Elegantbeef> It my be the size of the struct, but no clue it's ambiguous |
20:46:45 | FromDiscord | <Prestige> I would think that means the size of the pointer, but I don't know all of C's weirdness |
20:46:48 | FromDiscord | <Bung> dont know, first time see at end |
20:47:25 | FromDiscord | <Elegantbeef> If `IOleObject` is a typedef'd pointer it could be dereferencing it |
20:48:09 | FromDiscord | <Bung> so its dereferencing and size of struct |
20:48:17 | FromDiscord | <Elegantbeef> No clue |
20:48:25 | FromDiscord | <Elegantbeef> C is a very ambiguous language |
20:48:42 | FromDiscord | <domosokrat> definitely size of a pointer to IOleObject |
20:49:29 | FromDiscord | <domosokrat> dereferencing would be sizeof(\ IOleObect) and only if IOleObject is a valirable |
20:49:47 | FromDiscord | <domosokrat> variable |
20:50:21 | FromDiscord | <Prestige> Yeah.. |
20:50:21 | FromDiscord | <Elegantbeef> I figured as much but i never remember dereferencing properly or how C's sizeof works |
20:50:31 | FromDiscord | <Prestige> could also test it out if you weren't sure, I suppose |
21:03:24 | * | PMunch quit (Quit: leaving) |
21:20:11 | qwr | C is pretty straightforward, pointer type is totally separate from the pointed type, whatever it happens to be, so sizeof pointer gives the pointers size, usually 4 on 32-bit platforms and 8 on 64-bit platforms |
21:21:26 | qwr | only weirdness is imho, that sizeof operator works both on values and (types) |
21:22:13 | FromDiscord | <Generic> that's useful because there's no way in C to get the type of a value |
21:22:14 | FromDiscord | <Elegantbeef> I dont think the latter part is that weird |
21:38:40 | * | dnh quit (Quit: Textual IRC Client: www.textualapp.com) |
21:55:16 | * | niminal quit (Ping timeout: 268 seconds) |
22:19:08 | * | djanatyn1 is now known as djanatyn |
23:19:00 | * | rockcavera quit (Read error: Connection reset by peer) |
23:19:19 | * | rockcavera joined #nim |
23:19:19 | * | rockcavera quit (Changing host) |
23:19:19 | * | rockcavera joined #nim |