00:00:46 | * | Jjp137 joined #nim |
00:05:27 | * | jmdaemon joined #nim |
00:30:41 | NimEventer | New thread by widlet: Attempting to use newContext from std/net fails to compile, see https://forum.nim-lang.org/t/10862 |
00:31:58 | * | jmdaemon quit (Ping timeout: 255 seconds) |
00:48:19 | FromDiscord | <ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=html> |
00:49:24 | FromDiscord | <Elegantbeef> Read the 32bit then use `std/endianess` or auxym's package to swap them |
00:49:49 | FromDiscord | <Elegantbeef> https://github.com/auxym/bight |
00:51:43 | * | jmdaemon joined #nim |
01:02:53 | * | jmdaemon quit (Ping timeout: 240 seconds) |
01:20:23 | * | jmdaemon joined #nim |
02:33:06 | FromDiscord | <girvo> Dumb question for termer: can I make an array of stackstrings? StackString doesn't appear to be exported as a type? |
02:33:59 | FromDiscord | <girvo> Oh wait' |
02:34:01 | FromDiscord | <girvo> I see haha |
02:34:33 | FromDiscord | <girvo> sent a code paste, see https://play.nim-lang.org/#ix=html> |
02:36:09 | FromDiscord | <girvo> Now the question is how do I unpack them... send size alongside it I guess? I think that's what you were getting at @ElegantBeef yesterday |
02:39:52 | FromDiscord | <Elegantbeef> Yea `len` plus `toOpenArray(0, len)` 😄 |
02:40:22 | FromDiscord | <Elegantbeef> sorry `0, high` assuming there is a `high` |
02:40:25 | FromDiscord | <Elegantbeef> otherwise `len - 1` of course |
02:41:32 | FromDiscord | <Elegantbeef> Remember though that array is 10 \ sizeof(int) + 10 \ 512 bytes approximately |
02:41:59 | FromDiscord | <Elegantbeef> So if you do want to pass it around whilst not allocating `ref array` will let you `move` it |
02:42:20 | FromDiscord | <Elegantbeef> Though I'd suggest a `type LogBuffer = distinct ref array` so you can write your own hooks |
02:43:25 | FromDiscord | <Elegantbeef> It'd allow disabling `=copy` and `=dup` meaning there's only ever one owner |
02:46:45 | FromDiscord | <Elegantbeef> As always I've given girvo more than he wanted 😄 |
02:51:52 | FromDiscord | <girvo> Haha nah that's pretty spot on |
02:51:59 | FromDiscord | <girvo> Though thankfully it doesn't actually need to be moved anywhere |
02:52:40 | FromDiscord | <girvo> Basically just act as a re-usable buffer for incoming `string` lines, that once we hit N lines we send off with as minimal copies as possible in the process, and re-using the buffer next time |
02:53:52 | FromDiscord | <girvo> As always, it's a allocation/space trade off, and paying the upfront maximum cost once is ideal here, though we pay for it in network transmission costs... |
02:54:04 | FromDiscord | <girvo> Fun trade offs 🥲 |
02:54:12 | FromDiscord | <Elegantbeef> You do probably want to make it a ref anyway to not put it on the stack |
02:54:16 | FromDiscord | <Elegantbeef> That's a lot of stack space to eat up |
02:54:21 | FromDiscord | <girvo> Yeah it will be |
02:54:28 | FromDiscord | <Elegantbeef> Maybe making it `{.global.}` makes sense aswell 😄 |
02:55:12 | FromDiscord | <girvo> btw does {.global.} then mean it's statically allocated at the C level? I sort of assumed that was true but never checked |
02:55:21 | * | jmdaemon quit (Ping timeout: 245 seconds) |
02:55:25 | FromDiscord | <Elegantbeef> I think it makes it `static` |
02:55:30 | FromDiscord | <girvo> yeah which is perfect |
02:55:33 | FromDiscord | <Elegantbeef> best look at the C to see |
02:55:36 | FromDiscord | <girvo> Yeah I'll check |
03:47:34 | termer | girvo You can make an array of stackstrings |
03:47:53 | termer | the code pastes aren't loading on IRC anymore for some reason |
03:53:43 | * | azimut quit (Ping timeout: 240 seconds) |
04:10:54 | * | jmdaemon joined #nim |
04:12:18 | * | xet7 joined #nim |
04:57:23 | * | rockcavera quit (Remote host closed the connection) |
05:08:52 | FromDiscord | <girvo> Yeah I worked it out haha |
05:09:06 | FromDiscord | <girvo> I didn't realise they took a type param to specify size! |
05:09:55 | FromDiscord | <girvo> Hey yay the nim-libsodium upstream removed the `ptr cuchar` haha. Its now properly `ptr char` |
05:18:26 | FromDiscord | <Elegantbeef> @girvo I do wonder do you run with `--hint:Performance: on --hintAsError:Performance`? |
05:18:54 | FromDiscord | <Elegantbeef> That prevents any implicit copies from being made when a `sink` cannot be respected |
05:25:00 | FromDiscord | <girvo> Ooooooh |
05:25:00 | FromDiscord | <girvo> I do not |
05:25:09 | FromDiscord | <girvo> That's awesome, thanks |
05:26:41 | termer | girvo Using constant values as type params is one of my favorite things with Nim's type system in these situations |
05:26:47 | FromDiscord | <Elegantbeef> It does ruin a good part about Nim's move semantics, but in your case it makes sense |
05:28:10 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html> |
05:28:20 | FromDiscord | <Elegantbeef> Static parameters really are magical |
05:29:11 | FromDiscord | <Elegantbeef> Speaking of @zectbumo need any help with the static default? \:d |
05:30:43 | FromDiscord | <Elegantbeef> Statics can get even crazier with `static procs` 😄 |
05:30:43 | FromDiscord | <Elegantbeef> https://github.com/beef331/Nim/blob/b7330ccfea225833396ba0f41b77c44d0c59ef28/tests/statictypes/tstaticprocparams.nim |
05:30:52 | FromDiscord | <Elegantbeef> That might tickle your brain termer |
05:31:31 | FromDiscord | <Elegantbeef> Sadly though a PR needs to be done to remove `static T` from proc matches inside the proc parameters |
05:32:09 | FromDiscord | <Elegantbeef> The following is presently true `proc(i: static float i: int) isnot proc(i: int)` |
05:32:52 | FromDiscord | <Elegantbeef> I guess when it's inside the parameter list it does not make much sense to match |
05:32:54 | FromDiscord | <Elegantbeef> So I take it back |
05:36:12 | termer | Elegantbeef What you just posted is insane |
05:36:26 | FromDiscord | <Elegantbeef> It's super cool though |
05:36:50 | termer | trying to think of what that could be used for |
05:36:56 | FromDiscord | <Elegantbeef> Girvo and I were talking about being able to do like `log[T: static proc(...){.nimcall.}]` and being able to pass it to a `proc(...){.nimcall.}` |
05:37:05 | termer | I guess it'd be faster than passing in a function pointer, maybe |
05:37:33 | FromDiscord | <Elegantbeef> It can be faster than passing in a pointer proc, it also can be inline, and also does not require any sort of environment to keep it |
05:37:42 | termer | so the sizeof for all those would the same right |
05:37:51 | termer | or is it actually stuffing the code for it in the type |
05:37:53 | FromDiscord | <Elegantbeef> So you can do like `const myLogger = myProc[logLogic]` |
05:37:54 | termer | that can't be right |
05:38:08 | FromDiscord | <Elegantbeef> Static parameters are just generic parameters |
05:38:16 | FromDiscord | <Elegantbeef> So it create a instantiation with the value you provide |
05:38:34 | FromDiscord | <Elegantbeef> As such it's the exact same overhead as if you were to explicitly write the log proc there |
05:38:39 | termer | it's looking very C#-like |
05:38:55 | termer | what's the function for getting a type's size again |
05:39:05 | termer | sizeof |
05:39:10 | termer | nevermind |
05:39:18 | FromDiscord | <Elegantbeef> It's going to be `sizeof(pointer)` |
05:39:28 | termer | right |
05:39:29 | FromDiscord | <Elegantbeef> It emits a brand new procedure |
05:39:30 | termer | that's what I figured |
05:39:42 | FromDiscord | <Elegantbeef> Even more craziness here https://github.com/beef331/nimtrest/blob/master/tremoterefs.nim |
05:39:52 | FromDiscord | <Elegantbeef> Per type allocators using `static proc`s 😄 |
05:40:34 | FromDiscord | <Elegantbeef> The example I use for remote ref is when Girvo wanted to allocate using a SpiAllocator and to automatically dealloc/write there |
05:40:54 | termer | too tired for this silliness |
05:41:02 | FromDiscord | <Elegantbeef> It's not silly! |
05:41:11 | termer | too tired for this... COOLNESS! |
05:41:13 | termer | I wish I could use Nim again |
05:41:17 | termer | I miss its type system |
05:41:42 | FromDiscord | <Elegantbeef> I mean you can use it, just cry about web related techs |
05:42:02 | termer | waiting, perhaps forever, for CPS |
05:42:30 | termer | I considered using the CPS impl available now to write something and just deal with the horrible compile times |
05:42:51 | termer | but the problem is I don't have time to roll my own web framework |
05:43:11 | termer | 2024 is the year of the Nim tech stack guys |
05:43:26 | FromDiscord | <Elegantbeef> Bold claim |
05:43:44 | termer | 2025 will be the year of the Nim tech stack |
05:43:53 | termer | 2026 will be the year of the Nim tech stack |
05:44:08 | FromDiscord | <Elegantbeef> Eventually something's gotta give |
05:44:20 | FromDiscord | <Elegantbeef> Meanwhile I'll write a language from scratch 😄 |
05:45:10 | FromDiscord | <girvo> In reply to @termer "I guess it'd be": yeah, being able to avoid the overhead (small as it is) is really useful |
05:45:27 | FromDiscord | <Elegantbeef> It also prevents having to always provide the environment |
05:45:34 | FromDiscord | <girvo> indeed |
05:45:41 | FromDiscord | <Elegantbeef> So it makes it so you do not have to manually manage a closure |
05:46:11 | FromDiscord | <Elegantbeef> Though if Nim had closures that were stack allocated that'd reduce that issue |
05:46:17 | FromDiscord | <girvo> sent a code paste, see https://play.nim-lang.org/#ix=html> |
05:46:22 | FromDiscord | <Elegantbeef> Since you could just do a stack capture of the address |
05:46:39 | FromDiscord | <Elegantbeef> there is also the `ensureMove` in 2.x to look forward to 😛 |
05:46:49 | FromDiscord | <girvo> What languages do stack allocation of closures I wonder? I've not even really thought about it |
05:47:03 | FromDiscord | <girvo> ensureMove 😮 |
05:47:08 | termer | are you writing a language Elegantbeef |
05:47:08 | FromDiscord | <Elegantbeef> C++'s lambads are stack allocated arent they? |
05:47:22 | FromDiscord | <girvo> In reply to @Elegantbeef "C++'s lambads are stack": I think thats about the only one? |
05:47:39 | FromDiscord | <Elegantbeef> No clue but Araq does express displeasure with the fact all closures are heap allocated |
05:47:42 | FromDiscord | <girvo> (modulo Rust perhaps) |
05:48:40 | termer | sucks that they're heap allocated when they don't need to be |
05:48:44 | FromDiscord | <Elegantbeef> I mean I do not want to say yes termer cause then I have to hold myself to it, but I'm toying with a parser/lexer at the very least! |
05:48:44 | FromDiscord | <girvo> Yep just checked, Rust also stack allocates its closure environemnt |
05:49:05 | FromDiscord | <Elegantbeef> I've not wrote a parser/lexer before so it's about time 😄 |
05:49:17 | termer | is it a scripting lang or are you making a compiler |
05:49:21 | FromDiscord | <girvo> Yeah closures are so nice, but sadly we have to avoid them without an MMU/due to heap fragmentation if we weren't careful |
05:49:59 | FromDiscord | <Elegantbeef> It being a scripting language does not dismiss a compiler |
05:50:12 | termer | is it dynamically typed |
05:50:15 | FromDiscord | <Elegantbeef> But I am more interested in having a compiled backend than a scripting language |
05:50:23 | FromDiscord | <Elegantbeef> Of course it's not dynamically typed |
05:50:29 | termer | ok good |
05:50:40 | termer | my first and only language was dynamically typed and it was hilarious |
05:51:06 | FromDiscord | <Elegantbeef> The plan is an abomination of Nim + Odin influence |
05:51:42 | termer | what metaprogramming do you want to do with it |
05:51:56 | termer | and are you writing a compiler that actually outputs asm |
05:52:43 | FromDiscord | <Elegantbeef> Well you see my dumbass wants to output WASM so that it'd have compile time introspection without having to write a VM from scratch or rely on LLVM |
05:53:14 | FromDiscord | <Elegantbeef> I highly doubt it'll even get there, but the wish is to compile to wasm then also use wasm modules to implement other backends |
05:53:36 | termer | Actually that was an idea I also had |
05:53:44 | FromDiscord | <Elegantbeef> Then WASM would be the first class target and all other targets could be implemented in userspace |
05:54:02 | termer | but then my idea was I wanted to JIT compile macros and run them in the compiler, and then I'd have to bundle a wasm compiler if I did that |
05:54:05 | termer | *wasm runtime |
05:54:33 | FromDiscord | <Elegantbeef> I mean a wasm runtime is smaller than LLVM 😛 |
05:54:40 | termer | but how small and how fast |
05:54:50 | termer | and how useful do you want the lang to be |
05:55:52 | FromDiscord | <Elegantbeef> you see I do not want to say much more cause it'll just end up with me describing Nim but with a more usable type system and emphasis on generics, concepts, row polymorphism, and traits 😄 |
05:56:35 | FromDiscord | <Elegantbeef> That's all a pipedream that is more likely just to be a half assed lexer/parser that does not even emit usable AST 😄 |
05:57:43 | termer | I had an insane idea where you could write procedural code to describe how types are able to be used |
05:57:57 | termer | no generics, you just attach a procedural type guard, for example |
05:58:03 | FromDiscord | <Elegantbeef> Ugh |
05:58:11 | termer | and other things to augment everything |
05:58:19 | FromDiscord | <Elegantbeef> that's just pointless |
05:58:25 | FromDiscord | <Elegantbeef> Just make it so generics are checked generics |
05:58:25 | termer | ultimately you can write macros and code for anything |
05:58:42 | termer | I was thinking about Java generics to make it easier |
05:59:01 | FromDiscord | <Elegantbeef> If you are describing the required implementation for a type to be passed as a generic you've just made checked generics manual |
05:59:13 | termer | there'd be shorthand for it |
05:59:18 | termer | so yeah checked generics |
05:59:24 | FromDiscord | <Elegantbeef> The shorthand would be to do fucking nothing? |
05:59:26 | termer | but also you could forgo that and write your own logic |
05:59:42 | termer | So you can do TypeScript-style `is` return types basically |
05:59:46 | FromDiscord | <Elegantbeef> A procedure knows what a type needs to implement by looking at all usages of `T`, this of course fails when you have `when` |
05:59:49 | termer | but in a compile-time way |
06:00:02 | termer | You don't understand, I want to make a fun toy |
06:00:10 | FromDiscord | <Elegantbeef> Ah |
06:00:10 | termer | so I can do insane things and learn to write a compiler |
06:00:21 | FromDiscord | <Elegantbeef> I just want to do sane things |
06:00:28 | termer | would rather use Nim and existing langs |
06:00:39 | termer | also no pointers in the lang, compiler decides whether something becomes a reference or not |
06:00:49 | FromDiscord | <Elegantbeef> oh god |
06:00:52 | termer | if it's references outside where it could be on the stack, it's a reference |
06:00:54 | FromDiscord | <Elegantbeef> Go called they want their terrible idea back |
06:01:01 | termer | Go has references |
06:01:14 | FromDiscord | <Elegantbeef> The compiler decides when references are made |
06:01:22 | termer | there are explicit references |
06:01:34 | FromDiscord | <Elegantbeef> Sure |
06:01:38 | FromDiscord | <Elegantbeef> But it still has implicit ones |
06:01:43 | termer | oh yeah for sure |
06:02:03 | termer | Basically I want TypeScript, but compiled, and insane macros |
06:02:12 | FromDiscord | <Elegantbeef> Nim does have that with closures, but that's it |
06:02:25 | termer | TypeScript not in the JS way, just in the TS ways |
06:02:44 | FromDiscord | <Elegantbeef> Hopefully this toy language would have actual overloading |
06:02:50 | termer | for sure |
06:02:54 | termer | I like overloading |
06:02:58 | FromDiscord | <Elegantbeef> Imagine making a strongly typed language naming it typescript and not have overloading |
06:03:11 | termer | TypeScript has to live with a JS reality |
06:03:26 | termer | it tries not to generate JS code |
06:03:36 | termer | there are very few things in TS that generate new JS code |
06:04:45 | termer | So imagine this Elegantbeef |
06:04:53 | termer | You have these things called "constraints" |
06:05:00 | termer | which are basically big event handlers for compiler events |
06:05:25 | termer | if you've ever programmed in Java, you may know about the whole "extends SomethingListener" classes |
06:05:32 | termer | where you override handlers that you want |
06:05:58 | FromDiscord | <Elegantbeef> I mean I know C# interfaces |
06:06:08 | termer | Imagine that, but these effectively listener classes are for events that happen in the compiler |
06:06:22 | termer | and for each handler, you get passed context, including the current scope and all its data |
06:06:22 | FromDiscord | <Elegantbeef> You've just made term rewriting macros |
06:07:09 | termer | can those be attached to types |
06:07:22 | FromDiscord | <Elegantbeef> They can search for types |
06:07:31 | FromDiscord | <Elegantbeef> So yesn't |
06:07:37 | termer | these could be attached to types, to variables, to functions |
06:07:52 | FromDiscord | <Elegantbeef> Yea TRMs can search for types, variables, functions |
06:07:57 | FromDiscord | <Elegantbeef> They use AST to pattern match |
06:07:58 | termer | the write procedural code for how they can be used, how their usage is augmented, etc |
06:08:44 | termer | so you could have a constraint that limits instantiation of a generic param to only be a struct with 3 fields |
06:08:58 | termer | if you use a type for a struct with less than or more than 3 fields, it doesn't let you |
06:09:08 | termer | You could do wild things like that |
06:09:38 | FromDiscord | <Elegantbeef> This is just concepts |
06:10:07 | termer | yeah except this has access to all contextual information as well |
06:10:16 | termer | so not just what's being passed in, but where and how |
06:10:32 | termer | and these constraints would be JIT compiled so they run pretty fast |
06:10:44 | * | khazakar joined #nim |
06:12:08 | FromDiscord | <Elegantbeef> https://hatebin.com/ikpysafbko |
06:12:16 | FromDiscord | <Elegantbeef> Couldn't help myself |
06:12:35 | termer | fucking hell |
06:12:42 | termer | honestly I didn't know this could be done |
06:13:11 | termer | but see, constraints could do CRAZIER things like require that the struct have as many fields as there are variables in the current scope |
06:13:14 | FromDiscord | <Elegantbeef> I said you were describing concepts |
06:13:15 | termer | just to throw out something retarded |
06:13:23 | FromDiscord | <Elegantbeef> We can do that |
06:13:42 | FromDiscord | <Elegantbeef> Well sorta |
06:18:36 | termer | Nope, my toy lang idea is more powerful |
06:22:19 | FromDiscord | <Elegantbeef> https://hatebin.com/hmybhoisig yep it can |
06:25:36 | FromDiscord | <Elegantbeef> Termer really will quickly realise that the only thing that stops a bad guy with a macro is a even bigger macro |
06:26:59 | termer | wait |
06:27:01 | termer | what's locals |
06:27:15 | FromDiscord | <Elegantbeef> It compiler magic that makes a tuple of all local variables |
06:27:20 | termer | what the FUCK |
06:27:38 | termer | where do I find docs on this |
06:27:51 | termer | is it even documented in the first place |
06:27:58 | FromDiscord | <Elegantbeef> It's in `system` |
06:28:04 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#locals |
06:29:00 | FromDiscord | <Elegantbeef> It even gives them their names so it's `(a: "something", b: 4)` in that example |
06:29:15 | termer | this is insane |
06:29:21 | termer | how long have you been using Nim |
06:29:39 | FromDiscord | <Elegantbeef> Since 2020 |
06:30:13 | FromDiscord | <Elegantbeef> And i've never wrote anything of consquence |
06:30:33 | * | adigitoleo quit (*.net *.split) |
06:30:46 | * | adigitoleo joined #nim |
06:31:50 | termer | you've been writing it as long as me and yet know everything |
06:31:59 | * | pbsds quit (*.net *.split) |
06:32:00 | * | xutaxkamay quit (*.net *.split) |
06:32:03 | termer | I don't understand that |
06:32:13 | termer | I thought you would've been using it much much longer |
06:32:16 | * | jmdaemon quit (*.net *.split) |
06:32:17 | * | deadmarshal_ quit (*.net *.split) |
06:32:17 | * | redj quit (*.net *.split) |
06:32:17 | * | jkl quit (*.net *.split) |
06:32:18 | * | ehmry quit (*.net *.split) |
06:32:18 | * | hernan quit (*.net *.split) |
06:32:19 | * | m5zs7k quit (*.net *.split) |
06:32:20 | FromDiscord | <Elegantbeef> I was dropped as a child |
06:32:23 | FromDiscord | <Elegantbeef> A very long height |
06:32:28 | * | noeontheend quit (*.net *.split) |
06:32:29 | * | mhcat quit (*.net *.split) |
06:32:29 | * | mronetwo quit (*.net *.split) |
06:32:29 | * | dza quit (*.net *.split) |
06:32:32 | * | pbsds joined #nim |
06:32:32 | * | xutaxkamay joined #nim |
06:32:35 | * | pbsds quit (Max SendQ exceeded) |
06:33:03 | * | pbsds joined #nim |
06:35:37 | * | jmdaemon joined #nim |
06:35:37 | * | deadmarshal_ joined #nim |
06:35:37 | * | redj joined #nim |
06:35:37 | * | jkl joined #nim |
06:35:37 | * | ehmry joined #nim |
06:35:37 | * | hernan joined #nim |
06:35:37 | * | m5zs7k joined #nim |
06:35:44 | * | m5zs7k quit (Max SendQ exceeded) |
06:35:49 | * | noeontheend joined #nim |
06:35:49 | * | mhcat joined #nim |
06:35:49 | * | mronetwo joined #nim |
06:35:49 | * | dza joined #nim |
06:35:57 | * | m5zs7k_ joined #nim |
06:36:36 | * | casaca quit (Read error: Connection reset by peer) |
06:37:45 | * | adigitoleo quit (Ping timeout: 256 seconds) |
06:37:47 | * | noeontheend quit (Ping timeout: 240 seconds) |
06:37:48 | * | mhcat quit (Ping timeout: 240 seconds) |
06:37:48 | * | mronetwo quit (Ping timeout: 240 seconds) |
06:38:55 | * | mhcat joined #nim |
06:39:02 | * | mronetwo joined #nim |
06:39:09 | * | adigitoleo joined #nim |
06:43:25 | * | adigitoleo quit (Ping timeout: 256 seconds) |
06:43:47 | * | mhcat quit (Ping timeout: 268 seconds) |
06:45:12 | * | m5zs7k_ is now known as m5zs7k |
06:47:29 | * | mronetwo quit (Ping timeout: 268 seconds) |
07:09:46 | * | advesperacit joined #nim |
07:54:37 | * | adigitoleo joined #nim |
07:56:45 | * | noeontheend joined #nim |
07:56:51 | * | mhcat joined #nim |
07:56:53 | * | mronetwo joined #nim |
08:00:15 | entikan | what's the nim equivalent of "if foo in bar:" (or is that it and am I screwing something up?) |
08:00:49 | Amun-Ra | same |
08:02:35 | entikan | oh pff I did `is in` I'm an idiot |
08:02:47 | Amun-Ra | the type of the object that is searched for given value must have defined `contains` func iirc |
08:02:53 | Amun-Ra | oh ;) |
08:04:06 | * | adigitoleo quit (Ping timeout: 258 seconds) |
08:04:07 | * | mronetwo quit (Ping timeout: 260 seconds) |
08:04:07 | * | mhcat quit (Ping timeout: 260 seconds) |
08:04:07 | * | noeontheend quit (Ping timeout: 260 seconds) |
08:07:05 | * | mronetwo joined #nim |
08:07:27 | * | noeontheend joined #nim |
08:07:43 | * | mhcat joined #nim |
08:14:42 | * | adigitoleo joined #nim |
08:25:28 | FromDiscord | <mratsim> In reply to @Elegantbeef "It compiler magic that": oooh is that new?↵Quite handy for custom closures |
08:28:49 | FromDiscord | <Elegantbeef> I know it was in 1.6 |
08:28:53 | FromDiscord | <Elegantbeef> So I do not think it's new |
08:32:35 | * | mronetwo quit (Ping timeout: 260 seconds) |
08:33:14 | * | adigitoleo quit (Ping timeout: 258 seconds) |
08:33:31 | * | noeontheend quit (Ping timeout: 260 seconds) |
08:33:59 | * | mhcat quit (Ping timeout: 260 seconds) |
08:42:58 | * | noeontheend joined #nim |
08:43:04 | * | mhcat joined #nim |
08:43:10 | * | mronetwo joined #nim |
08:43:24 | * | adigitoleo joined #nim |
08:43:36 | * | adigitoleo quit (Read error: Connection reset by peer) |
08:43:39 | * | mronetwo quit (Read error: Connection reset by peer) |
08:43:39 | * | noeontheend quit (Write error: Connection reset by peer) |
08:43:40 | * | mhcat quit (Read error: Connection reset by peer) |
08:43:49 | * | adigitoleo joined #nim |
08:43:56 | * | mronetwo joined #nim |
08:44:14 | * | noeontheend joined #nim |
08:44:55 | * | mhcat joined #nim |
08:48:08 | * | adigitoleo quit (Read error: Connection reset by peer) |
08:48:10 | * | mhcat quit (Read error: Connection reset by peer) |
08:48:10 | * | noeontheend quit (Read error: Connection reset by peer) |
08:48:11 | * | mronetwo quit (Read error: Connection reset by peer) |
08:50:19 | * | mronetwo joined #nim |
08:50:21 | * | noeontheend joined #nim |
08:55:07 | * | adigitoleo joined #nim |
09:01:03 | * | noeontheend quit (Ping timeout: 260 seconds) |
09:01:03 | * | mronetwo quit (Ping timeout: 260 seconds) |
09:02:22 | * | adigitoleo quit (Ping timeout: 258 seconds) |
09:25:46 | FromDiscord | <pmunch> Locals has been around for quite a while |
10:07:57 | * | adigitoleo joined #nim |
10:11:59 | * | adigitoleo quit (Read error: Connection reset by peer) |
10:12:54 | * | noeontheend joined #nim |
10:17:00 | * | noeontheend quit (Ping timeout: 245 seconds) |
10:20:01 | FromDiscord | <nnsee> is there a sane way of parsing a string like `\x110a0b0c` into a `seq[char]` in std? |
10:20:13 | FromDiscord | <nnsee> also, side note, https://nim-lang.org/docs/sha1.html has broken links in the preamble |
10:20:34 | FromDiscord | <nnsee> the sha2 and sha3 ones |
10:22:03 | FromDiscord | <pmunch> Hmm, actually I wonder what the performance hit of accessing locals is |
10:24:28 | FromDiscord | <nnsee> In reply to @nnsee "is there a sane": actually i can just do `parseSecureHash(whateverString[2..^1])`, kind of cursed but whatever |
10:26:46 | FromDiscord | <loloof64> Hi ! I'm just starting to learn Nim. Is there a way to get common folders from Nim ? I mean Documents/Images/Configuration... ? |
10:29:58 | FromDiscord | <ayex> sent a long message, see <!doctype html> |
10:30:20 | FromDiscord | <Phil> I believe they mean fetching folders at runtime |
10:30:25 | FromDiscord | <loloof64> no |
10:30:53 | FromDiscord | <loloof64> I mean finding the Documents or Image folder on the user host machine for example |
10:31:48 | FromDiscord | <Phil> In reply to @loloof64 "Hi ! I'm just": Generally you can find the home directory, for "Document" or "Image" directories you'll need to write your own based on that (so `getHomeDir() & "/Documents` etc.) |
10:32:23 | FromDiscord | <loloof64> Thank you. I'm also wondering, will that work on both Linux and Windows ? |
10:32:23 | FromDiscord | <Phil> https://nim-lang.org/docs/appdirs.html#getHomeDir |
10:32:39 | FromDiscord | <Phil> It will get you both the correct home dir on linux and windows, the path after that is up to you. |
10:32:53 | FromDiscord | <Phil> Well, on linux, windows and macOs |
10:33:21 | FromDiscord | <loloof64> Thank you very much, that's exactly what I was looking for 😃 |
10:33:32 | FromDiscord | <nnsee> In reply to @loloof64 "Thank you. I'm also": linux and windows generally have an entirely different structure for these directories, so you shouldn't expect `$HOME/Documents` to exist on linux (although it could very well be there) |
10:34:37 | FromDiscord | <loloof64> Indeed, I forgot this fact. But at least I can get the config folder 🙂 |
10:35:20 | FromDiscord | <loloof64> (getConfigDir()) |
10:35:24 | FromDiscord | <nnsee> depending on what you want this for you might also be interested in https://nim-lang.org/docs/appdirs.html#getConfigDir |
10:35:25 | FromDiscord | <nnsee> oh |
10:35:26 | FromDiscord | <nnsee> yes |
10:35:27 | FromDiscord | <nnsee> lol |
10:36:19 | FromDiscord | <loloof64> I think there I just have to create a subfolder dedicated to my application 🙂 |
11:02:32 | FromDiscord | <mratsim> In reply to @nnsee "linux and windows generally": XDG has some standard for this, but in my own setup I didn't install the service that creates those |
11:02:45 | FromDiscord | <mratsim> I have Photos, no Pictures thank you |
11:02:55 | FromDiscord | <mratsim> (edit) "no" => "not" |
11:03:11 | FromDiscord | <Phil> I'm on arch, I didn't even set this up myself, I just got handed a Pictures dir |
11:08:52 | FromDiscord | <mratsim> In reply to @isofruit "I'm on arch, I": there is a package called xdg something that recreates those on login |
11:09:27 | FromDiscord | <salt rock lamp> xdg-user-dirs maybe, or something like that |
11:09:35 | FromDiscord | <Phil> In reply to @mratsim "there is a package": Sounds neat personally. It's nice to have unified standards |
11:09:45 | FromDiscord | <salt rock lamp> https://wiki.archlinux.org/title/XDG_user_directories |
11:09:59 | FromDiscord | <Phil> Maybe there are desktop portals for that kind of thing |
11:10:05 | FromDiscord | <mratsim> In reply to @salt rock lamp "xdg-user-dirs maybe, or something": yes this one |
11:10:36 | FromDiscord | <mratsim> In reply to @isofruit "Sounds neat personally. It's": I unified all programming lang on COBOL |
11:11:31 | FromDiscord | <Phil> The name of a directory where you put stuff is not at all comparable to the way you speak overall language to do things |
11:11:34 | FromDiscord | <mratsim> standards are there for easing collaboration. But user directories are personal? what's the point. |
11:12:38 | FromDiscord | <Phil> Providing sane defaults, e.g. to first look in a dir where a user would have images for any image manipulation software |
11:13:00 | FromDiscord | <Phil> Sure you can always ask the user during initial setup to specify directories, but sane defaults are nice |
11:13:41 | FromDiscord | <Phil> Sorry, that sentence was bad:↵"Providing sane defaults, e.g. for image manipulation software to first look for images in the dir a user would normally have images in" |
11:14:13 | FromDiscord | <bigcatnova> whats the nim equivalent to pythons `"yes" if something else "no"` |
11:14:37 | FromDiscord | <bigcatnova> (edit) "whats the nim equivalent to pythons `"yes" if something else "no"` ... " added "in string formatting" |
11:14:40 | FromDiscord | <nnsee> the point of the XDG user dir standard is that it's customizable - you can set env vars pointing to wherever you actually keep your documents, pictures, etc and applications which respect the xdg standard go looking for things there instead of the "defaults" |
11:14:42 | FromDiscord | <Phil> `if somebool: <stuff> else: <otherstuff>` |
11:15:20 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
11:16:11 | FromDiscord | <Phil> For usage in what python calls fstrings, nim got similarly working strformat with the fmt and & macros for inserting values into strings |
11:16:16 | FromDiscord | <bigcatnova> sent a code paste, see https://play.nim-lang.org/#ix=html> |
11:17:03 | FromDiscord | <bigcatnova> https://media.discordapp.net/attachments/371759389889003532/1194600788220203068/Code_7tLTyi9V4l.png?ex=65b0f1ae&is=659e7cae&hm=a6fa1a925543df8879a5856870ec1246783d36ee546bc647388d881633eb88dc& |
11:23:53 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
11:25:19 | FromDiscord | <bigcatnova> sent a code paste, see https://play.nim-lang.org/#ix=html> |
11:29:17 | * | flouer_ quit (Remote host closed the connection) |
11:34:00 | * | azimut joined #nim |
12:14:19 | * | rockcavera joined #nim |
13:13:24 | NimEventer | New thread by lim1999: Custom constructors, see https://forum.nim-lang.org/t/10863 |
13:22:19 | FromDiscord | <xtrayambak> In reply to @nnsee "linux and windows generally": I'm pretty sure the freedesktop spec ensures that there is one, on compliant distros, atleast |
13:28:46 | FromDiscord | <nnsee> In reply to @xtrayambak "I'm pretty sure the": nope, see https://discord.com/channels/371759389889003530/371759389889003532/1194600188547969094 |
13:30:20 | FromDiscord | <nnsee> sent a code paste, see https://play.nim-lang.org/#ix=html> |
13:30:44 | FromDiscord | <nnsee> (edit) |
14:02:53 | FromDiscord | <fosster> guys, can anyone help me with creating nim bindings for a library? |
14:04:40 | FromDiscord | <Phil> Oof, c++ bindings I really can't help, never done that.↵I barely know how to manually wrap C |
14:05:01 | FromDiscord | <Phil> Generally regarding bindings I just blindly point in the direction of futhark and looking at what they provide |
14:08:33 | FromDiscord | <fosster> what is futhark? |
14:08:52 | FromDiscord | <Phil> Futhark is a project by PMunch about generating C-bindings 😅 |
14:09:31 | FromDiscord | <fosster> i'm not having difficulties with bindings for classes and functions, but i just can't seem to bind the `[]` index function |
14:09:41 | FromDiscord | <Phil> Ther eare users on the discord side of things, though I only recall @jmgomez that did C++ bindings (I think).↵So potentially they might have decent sources to learn from there. |
14:09:48 | FromDiscord | <fosster> i'll check it out, hoping that it helps \:(↵(@Phil) |
14:09:54 | FromDiscord | <Phil> (edit) "Ther eare users on the discord side of things, though I only recall @jmgomez that did ... C++" added "bindings for" | removed "bindings" |
14:10:28 | FromDiscord | <Phil> (edit) "Ther eare users on the discord side of things, though I only recall @jmgomez that did bindings for C++ ... (I" added "projects" |
14:12:17 | FromDiscord | <nnsee> In reply to @fosster "guys, can anyone help": don't ask to ask, just ask. what issue are you having specifically? |
14:12:26 | FromDiscord | <fosster> unfortunately futhark doesn't seem to support c++ libs |
14:14:24 | FromDiscord | <fosster> basically i'm writing bindings for a c++ audio synthesis library called "stk", so far i've succesfully ported some classes and methods, but now i need to be able to use the index function to index an element inside the `StkFrames` type, which is like a vector of `StkFloat`s↵(@nnsee) |
14:15:52 | FromDiscord | <fosster> so far i've binded `StkFramesIterator {.importcpp: "stk::StkFrames::operator", header: "stk/Stk.h".} = object` to import the iterator (even though I think this is the problem) and `proc '[]'(self: StkFrames, index: csize_t): StkFloat {.importcpp: "#", header: "stk/Stk.h".}` to bind the index function |
14:17:26 | FromDiscord | <nnsee> you probably want `[]`, not '[]' |
14:17:39 | FromDiscord | <nnsee> if the bridge mangles it, backticks and not apostrophes |
14:18:28 | FromDiscord | <fosster> sent a code paste, see https://play.nim-lang.org/#ix=html> |
14:19:51 | FromDiscord | <fosster> i know i just placed the apostrophe insted of backticks to not fuck up the format for the message↵(@nnsee) |
14:22:53 | FromDiscord | <nnsee> i think your importcpp should be `#[#]`, no? |
14:23:22 | FromDiscord | <fosster> Untitled.png https://media.discordapp.net/attachments/371759389889003532/1194647676361396325/Untitled.png?ex=65b11d59&is=659ea859&hm=f63d91a8ec309bd2b03b16203538327499f9517f7422cb685b5e92fb57f2f0f3& |
14:25:01 | FromDiscord | <fosster> oh, after doing so i got rid of the error but when i iter on it i get `()` |
14:25:25 | FromDiscord | <nnsee> iirc iterators are a bit more complex to wrap |
14:25:52 | FromDiscord | <nnsee> but i don't know enough cpp to be helpful here |
14:26:25 | FromDiscord | <fosster> maybe should i create a `$` proc to correctly display `StkFloat`? |
14:26:37 | * | wheatengineer joined #nim |
14:26:52 | FromDiscord | <fosster> seems quite hard to do c++ bindings |
14:36:05 | FromDiscord | <demotomohiro> @fosster, there are example code to import c++ functions in Nim manual:↵https://nim-lang.org/docs/manual.html#importcpp-pragma-importcpp-for-procs |
14:38:07 | FromDiscord | <demotomohiro> See `dictLookup` proc in example code to import `operator[]` in C++. |
14:50:55 | FromDiscord | <fosster> thank you for the hint |
14:50:57 | FromDiscord | <MDuardo> Anyone could get the Nim TreeSitter to work on Neovim?↵↵(I don't want to use Emacs) |
14:57:03 | FromDiscord | <leorize> you'll have to bug astronvim maintainer to update their commit |
14:58:56 | FromDiscord | <MDuardo> He's still on vacation |
15:00:07 | FromDiscord | <MDuardo> Well, I have to use Helix for now |
15:05:29 | FromDiscord | <leorize> you can probably override the commit yourself or use some other base configs \:p |
15:06:31 | FromDiscord | <fosster> guys, how can i represent a void raw pointer in nim? |
15:07:15 | FromDiscord | <sOkam! 🫐> In reply to @fosster "guys, how can i": 99% of the time you don't. you would use `ref` instead |
15:07:41 | FromDiscord | <sOkam! 🫐> only reason to use raw pointers (or any other unsafe memory access) is for C interop |
15:07:45 | FromDiscord | <Phil> The context is likely c++ bindings, they might not own that memory |
15:07:51 | FromDiscord | <fosster> but what if i wanted |
15:07:56 | FromDiscord | <sOkam! 🫐> that said, you have `pointer` |
15:08:27 | FromDiscord | <sOkam! 🫐> pointer is untyped, so its double unsafe |
15:08:42 | FromDiscord | <sOkam! 🫐> normally you use `ref` or `ptr Type` |
15:08:43 | FromDiscord | <Phil> I mean you can do `ptr <YourType>` |
15:08:47 | FromDiscord | <Phil> Dang, too slow |
15:10:09 | FromDiscord | <fosster> thanks, yes i'm still struggling with bindings \:( |
15:10:36 | FromDiscord | <Phil> I mean, what you're doing isn't necessarily of the easy variety.↵There's a reason very few languages actually have anything even remotely approaching C++ bindings |
15:10:47 | FromDiscord | <kiloneie> sent a long message, see <!doctype html> |
15:11:28 | FromDiscord | <Phil> Time for Super-PMunch? |
15:11:34 | FromDiscord | <leorize> sent a code paste, see https://play.nim-lang.org/#ix=html> |
15:11:59 | FromDiscord | <demotomohiro> When you wrap C/C++ function like `foo(void ptr)`, you can write `proc foo(ptr: pointer) {.importc.}`. |
15:12:09 | FromDiscord | <Phil> Oh? Importc also works for c++? |
15:12:23 | * | lucasta joined #nim |
15:12:41 | FromDiscord | <demotomohiro> Use `importcpp` for c++. |
15:12:45 | FromDiscord | <Phil> Ah, check |
15:13:02 | FromDiscord | <Phil> But given they appear to be similar that regard, I can provide pointers for the simpler aspects of it then at least |
15:13:22 | FromDiscord | <kiloneie> How do you wrap a C func if you made it like this:↵`declspec( dllexport ) int sum(int a, int b)` for compiling it as a DLL ? |
15:13:47 | FromDiscord | <leorize> just `proc sum(a, b: cint) {.importc.}` would do |
15:14:07 | FromDiscord | <kiloneie> it's not working... |
15:14:25 | FromDiscord | <kiloneie> i have 1x version from ages ago working, but this one doesn't want to |
15:14:31 | FromDiscord | <leorize> the declspec and stuff is just windows magic to mark the proc as accessible from the outside where as linux just make everything visible by default |
15:15:18 | FromDiscord | <leorize> you'll need some error messages because "doesn't want to" is not helpful \:p↵(@kiloneie) |
15:15:57 | FromDiscord | <demotomohiro> In reply to @kiloneie "How do you wrap": If that function is exported from C DLL and call it from Nim code:↵https://nim-lang.org/docs/manual.html#foreign-function-interface-dynlib-pragma-for-import |
15:15:57 | FromDiscord | <kiloneie> `proc sum(a, b: cint) {.importc.}↵↵let c = sum(1, 2) #no idea...` this is what i did at first |
15:16:16 | FromDiscord | <fosster> i know, but i don't think there is much choice↵(@Phil) |
15:18:51 | * | xet7 quit (Remote host closed the connection) |
15:24:37 | FromDiscord | <kiloneie> my eye sight is -7.50, -7.75, but in coding it's like - 50 |
15:24:49 | FromDiscord | <kiloneie> : cint was missing |
15:24:54 | FromDiscord | <kiloneie> after the proc |
15:25:00 | FromDiscord | <kiloneie> before importc pragma |
15:26:59 | FromDiscord | <kiloneie> and this `{.compile: "cSharedLibrary.c".}` |
15:27:21 | FromDiscord | <Phil (he/him)> sent a long message, see <!doctype html> |
15:28:48 | FromDiscord | <kiloneie> i don't understand though how {.compile: "logic.c".} made function not from logic.c to work... both worked the same... |
15:28:52 | FromDiscord | <leorize> do you have a trace? |
15:29:33 | FromDiscord | <fosster> a way to bind c++ structs? |
15:30:42 | FromDiscord | <Phil (he/him)> tsan.txt https://media.discordapp.net/attachments/371759389889003532/1194664623039852685/tsan.txt?ex=65b12d21&is=659eb821&hm=637c0110daf3a37f407b9b66e964d61c720cec9b8b3d6bc6590750817f1c4a78& |
15:30:43 | FromDiscord | <Phil (he/him)> Sure, for reference I set "doSleep" in there to "false" for now. |
15:31:49 | FromDiscord | <leorize> are you using d\:useMalloc? |
15:32:05 | FromDiscord | <Phil> Oh god damnit this isn't my own test-suite |
15:32:08 | FromDiscord | <Phil> No I didn't |
15:32:14 | FromDiscord | <Phil> 🤦 |
15:32:19 | FromDiscord | <leorize> yea the stdlib allocator is not threadsafe |
15:32:21 | FromDiscord | <leorize> now you know |
15:32:41 | FromDiscord | <Phil> Hey, that brings me down 1 warning out of 3 |
15:33:18 | FromDiscord | <Phil> Now it's complaining about the 2 destructors racing |
15:33:26 | FromDiscord | <Phil> Next stacktrace incoming, one sec |
15:35:19 | FromDiscord | <Phil (he/him)> It's a data race between 2 destructors |
15:35:19 | FromDiscord | <Phil (he/him)> Sadly the stacktraces don't really tell you where those destructor calls originate from |
15:35:19 | FromDiscord | <Phil (he/him)> But I assume one of them is Thread A and the other Thread B |
15:35:20 | FromDiscord | <Phil (he/him)> Which is... odd |
15:35:20 | FromDiscord | <Phil (he/him)> tsan.txt https://media.discordapp.net/attachments/371759389889003532/1194665786917261362/tsan.txt?ex=65b12e37&is=659eb937&hm=d058613091bf22c81a75b621246b9ae6b72658783bfde91373c2c15dab5186b2& |
15:35:20 | FromDiscord | <Phil (he/him)> Compiled with `nim r --path:"." --gc:arc --threads:on -d:useMalloc --cc:clang --debugger:native --passc:"-fsanitize=thread -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" --passl:"-fsanitize=thread -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" tests/tsmartptrsleak.nim` btw. |
15:36:52 | FromDiscord | <leorize> it literally said threadA and threadB in the traces so I'm not sure what you mean |
15:38:31 | FromDiscord | <Phil (he/him)> ... I have learned to ignore the first bit of the stacktracen and only stare at line-numbers, it appears I need to unlearn that |
15:38:31 | FromDiscord | <leorize> anyhow, this race is a little annoying to handle and I'm surprised that asan doesn't jump on you first |
15:38:31 | FromDiscord | <Phil (he/him)> I started with tsan on threading and don't plan to introduce asan with this PR specifically |
15:38:33 | FromDiscord | <Phil (he/him)> With this PR I only want to sneak Tsan into the pipeline.↵↵I'll try to push in asan with a separate PR down the line |
15:39:10 | FromDiscord | <Phil (he/him)> Because that'll need a bit of a rework of the general test-suite so that it re-reruns with multiple sanitizers, I'll need agreement with everyone involved that that's desireable yada yada yada |
15:39:35 | FromDiscord | <Phil (he/him)> Just thought the easy thing to do right now is first step, sneak in tsan.↵Second step, neak in asan as well and maybe more sans |
15:40:47 | FromDiscord | <leorize> this is an UAF at it's core |
15:40:48 | FromDiscord | <leorize> use-after-free |
15:40:50 | FromDiscord | <Phil (he/him)> Is it? The atomic should catch it I thought |
15:40:50 | FromDiscord | <Phil (he/him)> Oh wait, the atomic is in the freed memory |
15:40:50 | FromDiscord | <Phil (he/him)> Errr |
15:40:51 | FromDiscord | <Phil (he/him)> Well... nil check doesn't really do shit there either |
15:40:52 | FromDiscord | <leorize> well the nil is per-thread so... |
15:41:12 | FromDiscord | <leorize> maybe you should try reading some c++ shared\_ptr impl and see if you can fix this one \:p |
15:41:14 | FromDiscord | <Phil (he/him)> Yeah , one thread will have an un-nil'd thingy which is the issue |
15:41:45 | FromDiscord | <Phil (he/him)> Doesn't... that kinda mean smartptrs have a uaf problem already in their very principle? |
15:41:58 | FromDiscord | <leorize> in this implementation, yes |
15:42:31 | FromDiscord | <Phil (he/him)> Err... any quick fixes that don't mean I need to learn how to implement decent smartptrs? |
15:42:43 | FromDiscord | <leorize> just don't run tsan on it \:p |
15:42:55 | FromDiscord | <leorize> you know that you can have file-specific nim.cfg right? |
15:43:08 | FromDiscord | <Phil (he/him)> Not an option, then my primary goal of continuously proving correctness of what I want is not going to work (channels) |
15:43:37 | FromDiscord | <leorize> any fix would require learning how they should be implemented, unfortunately |
15:44:00 | FromDiscord | <Phil (he/him)> Crap, so it's not just an implementation but a conceptual problem?↵Gnaaa |
15:44:02 | FromDiscord | <leorize> I haven't learnt that either so I can't help you rn |
15:44:27 | FromDiscord | <Phil (he/him)> I'll look into file specific nim.cfg then |
15:45:58 | FromDiscord | <kiloneie> sent a long message, see <!doctype html> |
15:46:11 | FromDiscord | <leorize> no |
15:46:30 | FromDiscord | <leorize> `importc` doesn't do anything for them without `header` anyways |
15:46:37 | FromDiscord | <leorize> all you have to do is to make sure that the layout is the same |
15:47:26 | FromDiscord | <kiloneie> so i can get rid of importc pragma in it ? |
15:48:20 | FromDiscord | <Phil (he/him)> Waaaait a minute |
15:49:51 | FromDiscord | <kiloneie> wait, it actually crashed if i had importc in the struct |
15:49:54 | FromDiscord | <kiloneie> now it doesn't... |
15:51:05 | FromDiscord | <kiloneie> sent a long message, see <!doctype html> |
15:51:28 | FromDiscord | <leorize> it's not |
15:51:29 | FromDiscord | <kiloneie> with the function, i don't give it the body, so if it works, i know it's pulled from C, but here... |
15:51:34 | FromDiscord | <leorize> export on struct does absolutely nothing |
15:51:45 | FromDiscord | <kiloneie> ah |
15:51:55 | FromDiscord | <leorize> struct is a type, a way to interpret a bunch of bytes, it doesn't exist beyond your code |
15:52:01 | FromDiscord | <Phil> I think I understand more fundamentally the problem.↵It would be a non issue if the smartptrs were a locked datastructure I guess |
15:52:32 | FromDiscord | <kiloneie> i read that a long time ago, yeh that makes sense |
15:52:34 | FromDiscord | <Phil> Actually no, wait, wtf, that data race should be impossible, I change my opinion |
15:53:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=html> |
15:53:22 | FromDiscord | <Phil> One must happen after the other because that shit is atomic |
15:53:36 | FromDiscord | <Phil> They can not both get fetchSub == 0 to be true |
15:54:01 | FromDiscord | <leorize> they don't have to |
15:54:09 | FromDiscord | <leorize> the problem is the `fetchSub` itself |
15:54:13 | FromDiscord | <Phil> So that can't possibly race... ah shit unless the other thread already deallocated the entire pointer before the first even gets to fetchsub |
15:54:36 | FromDiscord | <leorize> it can't do that \:P |
15:54:59 | FromDiscord | <Phil> What, why wouldn't it be able to do that? |
15:55:18 | FromDiscord | <leorize> because if both of them hasn't hit the fetchsub, there's no way the count is `0` |
15:55:45 | FromDiscord | <leorize> the issue is that `fetchSub` is an atomic write |
15:55:49 | FromDiscord | <leorize> but `free` is not |
15:55:53 | * | lucasta quit (Read error: Connection reset by peer) |
15:55:54 | FromDiscord | <leorize> so the ordering is undefined |
15:56:10 | FromDiscord | <Phil> So what, change the entire thing to fence? |
15:56:29 | FromDiscord | <Phil> ~~I feel so smart to know about these modes after the atomic weapons talk~~ |
15:57:22 | FromDiscord | <Phil> But yeah, basically, you'd need to be able to check "are you still allocated" |
15:57:24 | FromDiscord | <Phil> Which you kinda can't |
15:58:11 | FromDiscord | <Phil> You can check for "are you nil" but in the timeframe between passing that if and reaching the counter your ass might still get deallocated |
15:58:27 | FromDiscord | <Phil> (edit) "You can check for "are you nil" but in the timeframe between passing that if and reaching ... thethe" added "for" | "forthe counter your ass might still get ... deallocated" added "the pointer" |
15:58:44 | FromDiscord | <kiloneie> i don't really understand your code, but shouldn't you try to display the count somewhere to debug ? |
15:58:56 | FromDiscord | <Phil> This is less about explicit values |
15:59:06 | FromDiscord | <Phil> And more about "are there constellations that are problematic" |
15:59:29 | FromDiscord | <Phil> As in, where 2 threads might be running this code, a few CPU instructions apart, and a thing happening on one causes a segfault or the like in the other |
16:00:08 | FromDiscord | <leorize> this one might be an FP tbf |
16:00:12 | FromDiscord | <Phil> FP? |
16:00:17 | FromDiscord | <Phil> False positive |
16:00:22 | FromDiscord | <Phil> I mean, I'm not sure |
16:01:09 | FromDiscord | <Phil> As stated, both might get past the first if.↵One might already be past the second if and have deallocated the SharedPtr while the second is just about to reach the second if and tries p.val.counter when p.val just got deallocated |
16:01:09 | FromDiscord | <kiloneie> can you get id of a thread ? |
16:01:13 | FromDiscord | <Phil> getThreadId() |
16:01:37 | FromDiscord | <leorize> it's impossible for that to happen↵(@Phil) |
16:02:00 | FromDiscord | <kiloneie> idk i would just have both threads output their id to a separate file and go from there D: |
16:02:40 | FromDiscord | <Phil> In reply to @leorize "it's impossible for that": Is the amount of instructions between the two ifs so low that one can not get past the second if and have already deallocated before the second thread has gotten past the first and performed the second if? |
16:03:08 | FromDiscord | <leorize> because you can't deallocate if there's still at least one owner |
16:03:23 | FromDiscord | <leorize> that's what the refcount is for |
16:03:31 | FromDiscord | <leorize> you can't get 0 without being the last owner |
16:04:02 | FromDiscord | <Phil> ... right, my entire example was based upon both threads running decr with counter being value 1, which is impossible |
16:04:05 | * | wheatengineer quit (Remote host closed the connection) |
16:04:18 | FromDiscord | <Phil> hmmm |
16:05:22 | FromDiscord | <leorize> you can try the "slow" approach of changing fetchsub to sequentially consistent mode |
16:06:52 | FromDiscord | <Phil> Literally kills all tsan messages instantly |
16:07:18 | FromDiscord | <Phil> Well, not all, but the ones I was looking at |
16:07:19 | FromDiscord | <leorize> looks like `Release` is incorrect then |
16:07:27 | FromDiscord | <leorize> atomics are scary |
16:07:57 | FromDiscord | <leorize> https://en.cppreference.com/w/cpp/atomic/memory_order \<- you can try deciphering this |
16:10:52 | FromDiscord | <leorize> could still be a FP fwiw |
16:13:23 | FromDiscord | <Phil> I'd like to play around with using different mo's here |
16:13:44 | FromDiscord | <Phil> But the second I choose one I get told it doesn't compile, only Relaxed is somehow available, which seems wrong because the enum should be moRelaxed |
16:14:10 | FromDiscord | <kiloneie> sent a long message, see <!doctype html> |
16:15:24 | FromDiscord | <Phil> ... threading has its own atomics |
16:15:30 | FromDiscord | <Phil> Yeah no wonder |
16:15:45 | FromDiscord | <Phil> (edit) "Yeah no wonder ... " added "none of the enums match xD" |
16:18:10 | FromDiscord | <gogolxdong666> why the same type and value string doesn't equal == 0x6b2b16df7e6bedaa4d5b88e85348d44654a45838 |
16:18:47 | FromDiscord | <gogolxdong666> https://media.discordapp.net/attachments/371759389889003532/1194676724428980386/image.png?ex=65b13867&is=659ec367&hm=cde81992bfc8eb10eaf7c06f9bdad117a5f7ebd8b8d4b4814bf4b5a26b99384e& |
16:19:35 | FromDiscord | <gogolxdong666> version 2.0.3 |
16:19:51 | FromDiscord | <leorize> i'm reading more into this and I think I might require a few PhDs to figure it out |
16:20:12 | FromDiscord | <leorize> nim does not compare strings by its pointer↵(@gogolxdong666) |
16:20:12 | FromDiscord | <Phil> In that case I trust in tsan more than myself |
16:20:57 | Amun-Ra | gogolxdong666: why one is uppercase and the second is lowercase? |
16:21:14 | Amun-Ra | oh, sorry, first one is mixedcase ;) |
16:21:19 | FromDiscord | <leorize> Phil\: you can see if `AcquireRelease` works |
16:21:26 | FromDiscord | <Phil> Already done so, it does |
16:22:04 | * | azimut quit (Remote host closed the connection) |
16:22:33 | FromDiscord | <leorize> you could stick to that instead, it's "lighter" |
16:22:43 | * | azimut joined #nim |
16:22:47 | FromDiscord | <leorize> but might require testing on ARM |
16:22:57 | FromDiscord | <nnsee> @Phil I think I remember you saying you use prologue - how do you "return early" from a HandlerAsync? If I do a plain `return`, it complains about `Future[system.void]` not being a `HandlerAsync` (even though I can clearly see that's exactly what it is https://planety.github.io/prologue/plugin/core/context.html#HandlerAsync) |
16:23:25 | FromDiscord | <Phil> Give me a sec, writing a github PR comment that requries focus |
16:23:33 | FromDiscord | <nnsee> sure, sorry to bother |
16:23:43 | FromDiscord | <Phil> In reply to @leorize "but might require testing": Luckily the pipeline already has ARM in it |
16:24:05 | Amun-Ra | I can bother anyone w/o feeling sorry (if anyone need that) ;) |
16:24:10 | FromDiscord | <Phil> Windows amd fails =/ |
16:24:27 | Amun-Ra | Phil: you wrote "fails" two times |
16:24:32 | Amun-Ra | I'll see myself out |
16:24:38 | FromDiscord | <Phil> Welp, blows up for windows on all platforms |
16:24:48 | FromDiscord | <Phil> Both linux and macos take it like a champ |
16:26:39 | Amun-Ra | have you tried to cross-compile on linux with mingw and rerun on the os? |
16:27:52 | FromDiscord | <Phil> `clangclangclangclang: : : : error: unsupported option '-fsanitize=thread' for target 'x86_64-pc-windows-msvc'`↵↵OH FUCKING SHOOT ME |
16:28:19 | FromDiscord | <odexine> clang be hitting a pipe with a wrench at the start of that error message |
16:28:38 | FromDiscord | <Phil> Errr |
16:28:48 | FromDiscord | <Phil> Is this the time where I have to figure out how to add tsan to linux but not to windows? |
16:29:24 | Amun-Ra | is *san on windows a thing either way? |
16:30:33 | FromDiscord | <Phil (he/him)> Oh god I can deal with data races but github pipeline configs give me migraines |
16:30:48 | FromDiscord | <odexine> In reply to @Amun-Ra "is *san on windows": asan is |
16:31:00 | Amun-Ra | thanks |
16:31:03 | FromDiscord | <odexine> In reply to @Phil (he/him) "Oh god I can": who thought yaml as a programming language was a good idea |
16:31:12 | FromDiscord | <odexine> asan on msvc at least is a thing iirc |
16:31:14 | Amun-Ra | ;> |
16:31:18 | FromDiscord | <odexine> not sure on other compilers |
16:31:25 | FromDiscord | <Phil (he/him)> Sure but that's for later, right now it's tsan all the way |
16:31:42 | FromDiscord | <Phil (he/him)> Does nim.cfg do when blocks? |
16:31:50 | FromDiscord | <odexine> iirc its a different syntax |
16:31:56 | FromDiscord | <odexine> i forgot what exactly |
16:32:04 | FromDiscord | <leorize> it's `@if windows ... @end` |
16:32:23 | FromDiscord | <Phil (he/him)> Well more "if not windows" would be the check |
16:33:02 | FromDiscord | <leorize> you can look at it |
16:33:03 | FromDiscord | <leorize> the nim.cfg shipped with the compiler have a bunch of those |
16:36:04 | * | zgasma joined #nim |
17:48:19 | FromDiscord | <Phil> Check and done |
17:54:22 | FromDiscord | <Phil> ... the heck |
17:54:37 | FromDiscord | <Phil> I have tests that fail on windows i386 and ONLY there |
17:54:57 | FromDiscord | <Phil> Everybody else is chill, but not windows |
17:55:05 | FromDiscord | <Phil> (edit) "Everybody else is chill, but not windows ... " added "i386" |
18:07:30 | FromDiscord | <leorize> if you give me the error I can help |
18:08:35 | FromDiscord | <Phil (he/him)> Turns out windows i386 does not like clang for reasons, does not fail when I remove --cc\:clang for windows.Failure here\:↵↵https://github.com/nim-lang/threading/actions/runs/7478815691/job/20354606772 |
18:09:03 | FromDiscord | <Phil (he/him)> > Pointer size mismatch between Nim and C/C++ backend. You probably need to setup the backend compiler for target CPU.D\:\\a\\threading\\threading\\nim\\lib\\nimbase.h↵I don't really understand what that means |
18:09:33 | FromDiscord | <Phil (he/him)> Wait, is i386 32 bit and nim assumes 64bit pointers on clang by default and that's whats blowing up? |
18:09:54 | FromDiscord | <Phil (he/him)> ` D:\a\threading\threading\nim\lib\nimbase.hD:\a\threading\threading\nim\lib\nimbase.hnote: expression evaluates to '4 == 8':538:30: note: expression evaluates to '4 == 8'`↵↵Oh god damnit |
18:11:07 | FromDiscord | <leorize> the problem is that clang is 64bit |
18:11:24 | FromDiscord | <leorize> 32bit windows is "simulated" by using a 32bit gcc |
18:11:28 | FromDiscord | <Phil (he/him)> sent a code paste, see https://play.nim-lang.org/#ix=html> |
18:11:59 | FromDiscord | <leorize> you'd need to convince clang to build in 32bit mode on windows i386 \:p |
18:12:12 | FromDiscord | <leorize> pretty much just add `-m32` to build flags |
18:13:14 | FromDiscord | <Phil (he/him)> sent a code paste, see https://play.nim-lang.org/#ix=html> |
18:13:42 | FromDiscord | <Phil (he/him)> Well, if windows-i386 but not sure how that flag works |
18:14:59 | FromDiscord | <leorize> `@if windows and i386` |
18:21:12 | FromDiscord | <Phil> Alright, looking good so far |
18:21:17 | FromDiscord | <Phil> First victory! |
18:21:30 | FromDiscord | <Phil> Aaaaand we're golden! Clang for everybody! |
18:25:48 | * | noeontheend joined #nim |
18:26:22 | * | mronetwo joined #nim |
18:29:52 | * | mhcat joined #nim |
18:32:29 | * | adigitoleo joined #nim |
18:41:29 | FromDiscord | <leorize> is it green now? |
18:41:41 | FromDiscord | <Phil> Rolling in green |
18:42:17 | FromDiscord | <leorize> congrats on solving your first threading adventure |
18:42:38 | FromDiscord | <Phil> That depends on the changes getting accepted |
18:42:58 | FromDiscord | <leorize> they'll be accepted one way or another \:P |
18:43:07 | FromDiscord | <Phil> But yeah, first steps and so on. Thank you so much for explainers btw. |
18:43:16 | FromDiscord | <Phil> That managed to get me a first solid basis |
18:43:26 | FromDiscord | <Phil> That an Zevv force-feeding me the atomic weapons talk |
18:45:36 | FromDiscord | <Phil> In reply to @leorize "they'll be accepted one": Assume I'm slow, because I am |
18:46:09 | FromDiscord | <Phil> Particularly while sickly my social perceptiveness takes a nose-dive |
18:52:50 | * | TheLink left #nim (Bye!) |
20:38:40 | * | hernan quit (Ping timeout: 245 seconds) |
20:40:27 | * | hernan joined #nim |
20:45:35 | * | systemdsucks quit (Ping timeout: 264 seconds) |
20:47:00 | * | systemdsucks joined #nim |
20:47:45 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=html> |
20:48:28 | FromDiscord | <user2m> (edit) |
21:02:17 | FromDiscord | <pengwyns> Is it possible to get the nimble dir (.nimble/pkgs2/ specifically) in a normal nim app? |
21:06:18 | FromDiscord | <pengwyns> Nvm, I found out its just getHomeDir + "/.nimble" |
21:15:33 | * | xet7 joined #nim |
21:25:46 | FromDiscord | <leorize> via `it`, that is |
21:25:48 | FromDiscord | <leorize> you can use `let it {.inject.} = req` in the template to let the body access `req`↵(@user2m) |
21:34:26 | * | pbsds quit (Quit: The Lounge - https://thelounge.chat) |
21:35:51 | * | pbsds joined #nim |
21:54:28 | * | casaca joined #nim |
21:55:08 | * | oddish quit (Changing host) |
21:55:08 | * | oddish joined #nim |
21:55:53 | FromDiscord | <user2m> In reply to @leorize "you can use `let": No way!! I can't believe that works! |
21:57:44 | FromDiscord | <leorize> it's the stuff behind sequtils \It templates |
21:58:22 | FromDiscord | <nnsee> huh, neat |
22:00:48 | FromDiscord | <user2m> love it |
22:36:56 | * | jjido joined #nim |
22:53:52 | FromDiscord | <MDuardo> Is there an alternative way of using `stdout.write`?I know you can do↵`stdin.readLine` -\> `readLine(stdin)`But haven't found an alternate for \`stdout.write"↵I like the parenthesis |
22:54:40 | FromDiscord | <MDuardo> Is there an alternative way of using `stdout.write`?I know you can do↵`stdin.readLine` -\> `readLine(stdin)`↵But haven't found an alternate for `stdout.write`↵I like the parenthesis |
22:55:05 | FromDiscord | <nnsee> you can use the exact same syntax |
22:55:20 | FromDiscord | <nnsee> write(stdout, whatever) |
22:55:27 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html> |
22:55:28 | FromDiscord | <Elegantbeef> Works just fine |
22:55:44 | FromDiscord | <Elegantbeef> You also can do `stdout.write("hello, " world")` |
22:56:08 | FromDiscord | <nnsee> the first argument can always be moved in front of the proc call |
22:56:22 | FromDiscord | <nnsee> regardless of how many arguments the proc takes |
22:59:43 | FromDiscord | <MDuardo> Thank you guys, it was a little different than I expected |
23:05:15 | * | advesperacit quit () |
23:10:14 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
23:18:26 | * | zgasma quit (Quit: Lost terminal) |
23:24:20 | FromDiscord | <hlsee> sent a long message, see <!doctype html> |
23:26:29 | FromDiscord | <hlsee> sent a code paste, see https://play.nim-lang.org/#ix=html> |
23:27:09 | FromDiscord | <hlsee> Thank you in advance in case I miss the chance to respond |
23:27:42 | FromDiscord | <hlsee> sent a code paste, see https://play.nim-lang.org/#ix=html> |