00:27:25 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dNr |
00:28:36 | FromDiscord | <sOkam!> oh... is it because `notin` is reserved, and im clashing with it with `I` |
00:29:55 | FromDiscord | <sOkam!> yeah, nvm. im dummie, that's why↵well, then question 2 remains:↵When is it better to use a macro, instead of a template? |
00:29:59 | FromDiscord | <Elegantbeef> What's even the point |
00:30:12 | FromDiscord | <Elegantbeef> `a notin 10..20` |
00:30:30 | FromDiscord | <Elegantbeef> Macro if you need introspection, template if you dont |
00:30:39 | FromDiscord | <sOkam!> whats introspection? |
00:31:08 | FromDiscord | <Elegantbeef> Using the input to run code statically to change the output |
00:32:58 | FromDiscord | <sOkam!> i think im missing like 3 or 4 points in that one sentence |
00:33:28 | FromDiscord | <Elegantbeef> The reason you use a macro is you want to look into what the user has given you and change the output based off that |
00:33:39 | FromDiscord | <Elegantbeef> The reason you use a template is you can just do code subsitution |
00:33:53 | FromDiscord | <sOkam!> i see |
00:34:26 | FromDiscord | <sOkam!> so templates are similar to C #defines↵is there something similar in C that resembles nim macros? |
00:34:49 | FromDiscord | <Elegantbeef> No |
00:34:58 | FromDiscord | <Elegantbeef> Nim macros take in AST you operate on said AST and can emit new AST |
00:35:32 | FromDiscord | <sOkam!> kk. but there is no ast modification in c. i think i get it now |
00:36:20 | arkanoid | I've successfully converted my algorithm to stack only! Now it's only 2 times slower than my reference algorithm. Callgrind says that I spend most of my time in ... "pow@@GLIBC_2.29" |
00:36:53 | FromDiscord | <sOkam!> Is there a way to return `nil` from a function that returns another type?↵Or how should I handle those cases instead? |
00:37:06 | FromDiscord | <Elegantbeef> `std/option` |
00:37:31 | arkanoid | I guess I can't go faster than this without leveraging on better algorithms or special ad-hoc instructions |
00:42:35 | FromDiscord | <Elegantbeef> Arkanoid what're you compiler flags? |
00:44:02 | arkanoid | Elegantbeef: https://play.nim-lang.org/#ix=4dNw |
00:44:23 | FromDiscord | <sOkam!> In reply to @Elegantbeef "`std/option`": lets say I have an `Option[MyType]` type↵can I pass that option type to procs that take `MyType`? Or do they need to be rewritten? |
00:44:57 | FromDiscord | <Elegantbeef> You unpack the value |
00:45:10 | FromDiscord | <Elegantbeef> so `myOption.mget` if it's `varT` or `myOption.get` |
00:46:30 | arkanoid | is there anything else I can do (easily) to improve it? |
00:48:04 | FromDiscord | <Elegantbeef> `-d:lto` is one, unlikely but `--mm:arc` or `--mm:orc` is another |
00:50:48 | arkanoid | (sorry, I forget to tell you about my config.nims) I'm already using --gc:arc and --experimental: strictFuncs |
01:00:50 | arkanoid | lol, I've found C code into nim js output: benchmark.js:4102 keepInt_687866206[0]+= (void*)&r_553648196; |
01:02:32 | arkanoid | I think is benchy not tested on js |
01:03:56 | FromDiscord | <Elegantbeef> Yea keep emits code that ensures the C compiler doesnt optimise out the value, but likely has 0 JS support |
01:05:06 | FromDiscord | <Elegantbeef> It uses `emit` and `monotimes` so likely 0 JS support |
01:08:01 | arkanoid | I was just curious how it would perform on js |
01:08:51 | arkanoid | moving a whole piece of logic from python to nim stack-only, fully typed (with "unchained"!) logic, it's just refreshing |
01:10:21 | FromDiscord | <Elegantbeef> There is https://gitlab.com/define-private-public/stopwatch |
01:10:31 | FromDiscord | <Elegantbeef> If you're overly interested |
01:25:15 | * | arkurious quit (Quit: Leaving) |
01:27:51 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNF |
01:29:40 | FromDiscord | <Elegantbeef> Why do you setPos? |
01:29:45 | FromDiscord | <Elegantbeef> Ah nvm i'm dumb again |
01:32:37 | FromDiscord | <huantian> In reply to @Elegantbeef "`-d:lto` is one, unlikely": Does panics on help performance? Or is that on by default now |
01:33:13 | FromDiscord | <Elegantbeef> Fuck if i know 😄 |
01:38:58 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNH |
01:39:20 | FromDiscord | <Elegantbeef> Well it's an internal compiler error from a macro likely |
01:39:39 | FromDiscord | <Elegantbeef> You're passing `nkNilLit` to a procedure that expects `nkSym` |
01:42:11 | FromDiscord | <Elegantbeef> hmph it'd be specialised but this could be improved |
01:42:38 | * | madprog quit (Ping timeout: 240 seconds) |
01:42:46 | * | madprog joined #nim |
02:13:49 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNP |
02:14:14 | FromDiscord | <Elegantbeef> `typeof(nil)` |
02:14:24 | FromDiscord | <Patitotective> yea |
02:14:26 | FromDiscord | <Elegantbeef> God I it |
02:14:26 | FromDiscord | <Elegantbeef> hate is the word supposed to be in that sentence |
02:14:40 | * | fallback quit (Ping timeout: 272 seconds) |
02:14:55 | FromDiscord | <Patitotective> i just thought itd be easier than catching all nil literals in my macros ;] |
02:15:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dNQ |
02:17:03 | FromDiscord | <Patitotective> this is the file that fails https://github.com/Patitotective/kdl-nim/blob/devel/tests/test_serializer.nim |
02:18:21 | FromDiscord | <Elegantbeef> Yea i dont see anything here |
02:18:57 | FromDiscord | <Patitotective> maybe macros + `Stream` being a ref object (?) |
02:19:06 | FromDiscord | <Elegantbeef> no |
02:19:17 | FromDiscord | <Patitotective> :p |
02:19:19 | FromDiscord | <Elegantbeef> You're passing a nil lit into the compiler somewhere it expects a symbol |
02:19:34 | FromDiscord | <Elegantbeef> It's not rocket science, the solution is to stop using a typeless nillit |
02:20:03 | FromDiscord | <Patitotective> https://media.discordapp.net/attachments/371759389889003532/1033203048346026084/unknown.png |
02:20:12 | FromDiscord | <Patitotective> In reply to @Elegantbeef "It's not rocket science,": lemme try |
02:20:59 | FromDiscord | <Elegantbeef> I personally hate typeless nil, it's a leaking implementation if you ask me |
02:21:35 | FromDiscord | <Patitotective> i literally commented out the whole procedure and the compiler does not even care |
02:32:23 | * | fallback joined #nim |
02:35:40 | FromDiscord | <huantian> In reply to @Elegantbeef "I personally hate typeless": What if I need to do nil[] |
02:36:16 | FromDiscord | <Elegantbeef> ... |
02:36:22 | FromDiscord | <Elegantbeef> !block @huantian |
02:42:21 | FromDiscord | <Rika> Lol |
02:46:35 | FromDiscord | <Patitotective> huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuh↵everything fixes by using `let` instead of `const` |
02:46:44 | FromDiscord | <Patitotective> streams? |
02:46:47 | FromDiscord | <Patitotective> (edit) |
02:49:19 | FromDiscord | <Elegantbeef> Were you using const streams? |
02:49:39 | FromDiscord | <Patitotective> i was doing `const doc = parseKdl("node")` |
02:50:33 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNU |
02:52:59 | FromDiscord | <Elegantbeef> Make sure you close the stream inside a try finally or a defer when you're parsing |
02:53:15 | FromDiscord | <Patitotective> :o |
02:53:19 | FromDiscord | <Patitotective> forgot |
02:56:33 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNV |
02:56:42 | FromDiscord | <Elegantbeef> yep |
02:57:15 | FromDiscord | <Patitotective> same error :[[ |
02:57:34 | FromDiscord | <Elegantbeef> I mean it's obviously not going to change anything 😄 |
02:58:11 | FromDiscord | <Patitotective> btw if i close the stream after lexing, if the parser tries to read it, it will fail right? |
02:58:22 | FromDiscord | <Elegantbeef> Yes |
02:59:53 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4dNW nice |
03:04:01 | FromDiscord | <Patitotective> oh, so streams dont work at CT |
03:04:02 | FromDiscord | <Patitotective> huh |
03:04:32 | FromDiscord | <Patitotective> thats really bad, i wanted to use kdl in nimscript |
03:08:02 | FromDiscord | <Elegantbeef> There's your problem https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/streams.nim#L1293-L1298 |
03:09:22 | FromDiscord | <Elegantbeef> Only part of string streams can be used at CT sadly |
03:35:48 | FromDiscord | <Patitotective> huh https://github.com/nim-lang/Nim/pull/19739 |
03:35:50 | FromDiscord | <proton> Does Nim have io_uring |
03:37:58 | FromDiscord | <Patitotective> huh https://github.com/nim-lang/Nim/pull/12284/files |
03:38:45 | FromDiscord | <Patitotective> seems like i have to keep my string parser |
03:38:50 | FromDiscord | <Patitotective> (edit) "seems like i have to keep my string ... parser" added "based" |
03:43:08 | FromDiscord | <Elegantbeef> Generics exist |
03:44:13 | FromDiscord | <Patitotective> `stream: Stream or string`? |
03:55:04 | FromDiscord | <Elegantbeef> Or seperate procs for where you need the seperate logic |
04:23:31 | FromDiscord | <hovsater> In reply to @hotdog "Hey <@167708338589532162> welcome 🤗": Thanks! Appreciate it. 🙂 |
05:12:42 | FromDiscord | <sOkam!> I have a process that I was doing with templates that called other templates, and it was complaining about ambiguous types↵Changed all to func, and it stopped the issue↵Is there a limit to the number of levels that templates can expand? |
05:14:11 | FromDiscord | <sOkam!> I didn't try compiling (don't have a basic test code yet, since its very much wip), so maybe it's just a limitation of the lsp instead? 🤔 |
05:14:37 | FromDiscord | <Elegantbeef> The limit for template depth is a compile time error |
05:14:43 | FromDiscord | <Elegantbeef> That tells you you hit the depth |
05:30:27 | * | nisstyre quit (*.net *.split) |
05:30:27 | * | gshumway quit (*.net *.split) |
05:30:27 | * | Yardanico quit (*.net *.split) |
05:30:39 | * | Yardanico joined #nim |
05:31:00 | * | nisstyre joined #nim |
05:33:42 | * | gshumway joined #nim |
05:53:56 | * | void09_ quit (*.net *.split) |
05:53:56 | * | dom96 quit (*.net *.split) |
05:53:57 | * | robertmeta quit (*.net *.split) |
05:53:57 | * | GreaseMonkey quit (*.net *.split) |
05:53:57 | * | kevinsjoberg quit (*.net *.split) |
05:53:57 | * | ormiret quit (*.net *.split) |
05:53:57 | * | Ekho quit (*.net *.split) |
05:54:23 | * | greaser|q joined #nim |
05:54:31 | * | void09 joined #nim |
05:55:05 | * | robertmeta joined #nim |
05:55:21 | * | ormiret joined #nim |
05:55:21 | * | kevinsjoberg joined #nim |
05:55:24 | * | robertmeta quit (Changing host) |
05:55:24 | * | robertmeta joined #nim |
05:55:24 | * | wallabra_ joined #nim |
05:55:40 | * | wallabra quit (Ping timeout: 252 seconds) |
05:55:51 | * | wallabra_ quit (Changing host) |
05:55:51 | * | wallabra_ joined #nim |
05:56:20 | * | dom96 joined #nim |
05:57:07 | * | wallabra_ is now known as wallabra |
06:02:30 | * | wallabra_ joined #nim |
06:02:40 | * | wallabra quit (Ping timeout: 272 seconds) |
06:03:53 | * | Ekho joined #nim |
06:04:18 | * | wallabra_ is now known as wallabra |
06:21:28 | * | rockcavera quit (Remote host closed the connection) |
06:31:29 | FromDiscord | <sOkam!> What does it mean that `value` in `case thing of value: ...` cannot be evaluated at compile time?↵value is an int that I created right before it 🧩 |
06:34:45 | FromDiscord | <Elegantbeef> `of` branches have to be constants |
06:35:26 | FromDiscord | <sOkam!> ah didn't know |
06:43:37 | * | derpydoo joined #nim |
07:01:42 | FromDiscord | <sOkam!> is there a way to iterate a sequence in a way that each iteration value is modifiable? |
07:02:40 | FromDiscord | <Elegantbeef> `mitems` |
07:03:33 | FromDiscord | <sOkam!> tyty 🙂 |
07:09:14 | * | pro joined #nim |
07:13:12 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
07:25:03 | * | fallback quit (Ping timeout: 255 seconds) |
07:37:37 | * | fallback joined #nim |
07:48:53 | * | wallabra_ joined #nim |
07:50:26 | * | wallabra quit (Ping timeout: 252 seconds) |
07:50:43 | * | wallabra_ is now known as wallabra |
07:55:07 | FromDiscord | <qb> I'm stuck. I'm trying to calculate the center of a set of points (x, y). Any math geek who could help me out? |
07:56:31 | Amun-Ra | ##math? |
07:56:36 | Amun-Ra | oh, discord |
07:57:09 | FromDiscord | <qb> Guess I've found something |
07:57:19 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4dOz |
07:58:31 | Amun-Ra | https://en.wikipedia.org/wiki/Centroid#Of_a_finite_set_of_points |
07:58:52 | FromDiscord | <Rika> There’s a lot of definitions for “centre” isn’t there |
07:58:57 | Amun-Ra | yes |
07:58:58 | FromDiscord | <Rika> Centroid is one of them |
08:02:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dOB |
08:02:30 | FromDiscord | <Elegantbeef> Doing the division in line might be right, i cannot be bothered to do the math |
08:02:30 | FromDiscord | <Elegantbeef> more likely wrong |
08:06:12 | FromDiscord | <dlesnoff> It is better in general to divide only at the end. It gives better numerical stability. |
08:07:18 | FromDiscord | <Elegantbeef> Think it might depend on how large your numbers are |
08:07:25 | FromDiscord | <Elegantbeef> But yea do it at the end like a normal person |
08:21:35 | FromDiscord | <sOkam!> Is there a way to lock a sequence to having a minimum on X items, and error otherwise? |
08:23:06 | FromDiscord | <dlesnoff> In reply to @Elegantbeef "Think it might depend": well the sum must not overflow. Ow you might want to do the division for a certain batch size of points. |
08:26:16 | FromDiscord | <qb> seems to work fine |
08:26:18 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4dOC |
08:26:55 | FromDiscord | <Elegantbeef> It of course works but iterates 3 different types |
08:27:04 | FromDiscord | <Elegantbeef> For each axis |
08:27:48 | FromDiscord | <Elegantbeef> Just something to be conscientious of |
08:36:23 | madprops | ah i remember the beef game |
08:36:26 | madprops | im gonna play it |
08:36:38 | madprops | )i would buy on steam) |
08:41:13 | madprops | https://i.imgur.com/eGQ2GpD.jpg |
08:41:20 | madprops | stuck here and forgot what the objective is |
08:41:23 | FromDiscord | <sOkam!> In reply to @sOkam! "Is there a way": manual doesn't seem to mention anything about seq starting with index other than 0↵I assume I would need to code the error checking myself instead? 🤔 |
08:51:04 | FromDiscord | <Rika> In reply to @sOkam! "manual doesn't seem to": Yes |
08:55:18 | * | pro quit (Quit: pro) |
08:58:51 | FromDiscord | <sOkam!> kk ✍️ |
09:00:42 | FromDiscord | <narimiran> NimConf is starting in one hour!!↵↵https://www.youtube.com/watch?v=aDi50K_Id_k&list=PLxLdEZg8DRwSQQaK0UVRd1DaetVc3lIwr |
09:01:21 | madprops | nimconf? |
09:01:28 | madprops | do we get to see araq live |
09:02:23 | madprops | evolution, not revolution |
09:12:10 | * | pro joined #nim |
09:23:56 | * | fanta1 joined #nim |
09:48:04 | * | pro quit (Quit: pro) |
09:49:29 | FromDiscord | <dlesnoff> In reply to @madprops "do we get to": It will be a pre-recorded talk. But you'll be able to exchange with him in chat. |
09:59:26 | * | PMunch joined #nim |
10:01:03 | PMunch | NimConf 2022 here we go! |
10:05:14 | * | wallabra quit (Ping timeout: 272 seconds) |
10:10:32 | * | fanta1 is now known as fanta1|away |
10:12:32 | * | fanta1|away is now known as fanta1 |
10:23:15 | FromDiscord | <sOkam!> Is there an existing way to add to a seq only if the element is not already in it? |
10:26:47 | FromDiscord | <ee7> Not unless you keep track of elements that were already added. But if you want to do that, maybe you want a `set` or `HashSet` instead? |
10:31:11 | FromDiscord | <sOkam!> In reply to @ee7 "Not unless you keep": ah that should work, yep, since the values stored are an enum, and sets seem to be better for that. ty |
10:31:43 | FromDiscord | <Rika> You lose ordering if you needed that |
10:37:33 | PMunch | Is there a playlist for this years conf? |
10:37:48 | FromDiscord | <Yardanico> yes |
10:37:55 | FromDiscord | <Yardanico> In reply to @PMunch "Is there a playlist": https://www.youtube.com/playlist?list=PLxLdEZg8DRwSQQaK0UVRd1DaetVc3lIwr |
10:37:56 | PMunch | Never mind, found it |
10:38:11 | PMunch | The nimconf 2022 website still points to the old playlist.. |
11:10:30 | * | jmdaemon quit (Ping timeout: 255 seconds) |
11:21:33 | FromDiscord | <ieltan> In reply to @Yardanico "https://www.youtube.com/playlist?list=PLxLdEZg8DRwS": At 28:35, Araq mentions the Nim allocator is O(n).. From what I have read so far Nim uses the TLSF allocator which is reputed for its constant time complexity, so O(1). Is that an error or maybe the allocator was changed to something else ? |
11:25:18 | FromDiscord | <ieltan> Ah, so ORC is kind of a generational garbage collector albeit limited in scope and optimized, I see |
12:04:18 | * | derpydoo quit (Ping timeout: 272 seconds) |
12:15:12 | * | derpydoo joined #nim |
12:31:18 | FromDiscord | <aMOPel> sent a code paste, see https://play.nim-lang.org/#ix=4dPw |
12:32:54 | FromDiscord | <Rika> you cant make a ref from a nonref without a copy |
12:33:01 | FromDiscord | <Rika> otherwise, its called a pointer 😉 |
12:37:39 | FromDiscord | <aMOPel> but that is possible in cpp right? |
12:37:51 | FromDiscord | <Phil> The copy would be of the obj from stack to heap right? |
12:38:54 | FromDiscord | <aMOPel> because nonrefs are on the stack and refs on the heap? |
12:43:24 | FromDiscord | <auxym> yes |
12:44:03 | FromDiscord | <auxym> in "in cpp" you mean a pointer, then yeah. It's also possible in nim and comes with the same caveats as c++. unsafe, not handled by gc, etc |
12:44:08 | FromDiscord | <Phil> You can have a ref to sth on the stack though, I recall as much |
12:44:13 | FromDiscord | <auxym> (edit) "in" => "if" |
12:44:30 | FromDiscord | <Phil> Though I might be mixing that up with using addr |
12:47:03 | FromDiscord | <auxym> you can do some hacks with GC_ref/GC_unref, but I don't think you can create a ref to something on the stack. pretty sure that would break the gc. |
12:47:04 | FromDiscord | <aMOPel> In reply to @auxym "if "in cpp" you": I just remember in cpp you could use the & to get a reference of a thing, but it's while ago for me, and it's possible I didn't quite understand the caveats^^ |
12:47:14 | FromDiscord | <auxym> yeah, that's a pointer |
12:47:51 | FromDiscord | <auxym> you can do it in nim with `.addr` (or `unsafeAddr`). But pointers are not managed by Nim's GC, unlike refs |
12:48:41 | FromDiscord | <aMOPel> thus I'd have to free the data before my last pointer goes out of scope right? |
12:49:20 | FromDiscord | <auxym> yes, and be careful about other bugs like use after free, etc |
12:49:47 | FromDiscord | <aMOPel> but in cpp you didn't always have to free manually when using & right? |
12:49:51 | FromDiscord | <auxym> if it's a stack allocated variable, then as soon as you return from that fuction, the pointer will be invalid |
12:49:56 | FromDiscord | <exelotl> Where you'd use `&` in cppcfor a parameter you can use a var param in Nim |
12:50:04 | FromDiscord | <exelotl> (edit) "cppcfor" => "cpp for" |
12:50:42 | FromDiscord | <auxym> In reply to @aMOPel "but in cpp you": indeed, if it's on the stack. stack is popped when function returns. |
12:50:48 | FromDiscord | <exelotl> ref objects in Nim are more like smart pointers or something? (Idk modern C++ so I might be wrong) |
12:51:26 | FromDiscord | <auxym> yeah no idea about smart pointers. Actually I know very little c++, most of what I'm saying is from C haha |
12:52:34 | FromDiscord | <exelotl> ref in nim means dynamically allocated and will be automatically deallocated when the number of references drops to zero.↵If you just want to mutate a parameter at its source then `var` params are what you need |
12:53:12 | FromDiscord | <auxym> correct |
12:55:28 | FromDiscord | <aMOPel> I was wondering how efficient passing by value is in nim. Intuitively it feels so inefficient always passing something immutable in, do stuff and return new data. Like isn't there a lot of copying around involved? |
12:55:49 | FromDiscord | <aMOPel> especially when the passed objects get bigger |
12:56:54 | FromDiscord | <exelotl> Semantically is passed by value, but under the hood the compiler will pass it as a pointer if the size of the object exceeds 3sizeof(int) |
12:57:12 | FromDiscord | <exelotl> (edit) "is" => "it's" |
12:57:36 | FromDiscord | <auxym> passing is optimised by the compiler. immutable (non-`var`) arguments are actually passed by reference (pointer) under the hood (in the C codegen) when they are larger than some threshold (3sizeof(float) atm, iirc) |
12:57:51 | FromDiscord | <aMOPel> for all types? so I never even have to worry about that?^^ |
12:57:52 | * | arkurious joined #nim |
12:57:54 | FromDiscord | <auxym> yes |
12:58:10 | FromDiscord | <aMOPel> pretty awesome 😄 |
12:58:31 | FromDiscord | <dlesnoff> In reply to @auxym "passing is optimised by": Is that the treshold ? I have always wondered about it |
12:58:39 | FromDiscord | <Rika> 3 sizeof float btw is a constant number no matter what arch you're on so you can just say 24 bytes |
12:59:01 | FromDiscord | <exelotl> You can use the {.bycopy.} and {.byref.} pragmas to override this behavior if desired |
12:59:03 | FromDiscord | <auxym> In reply to @Rika "3 * sizeof float": but then I'd have to multiply numbers in my head before replying 😦 |
12:59:20 | FromDiscord | <Rika> i dont remember if it was float size or int size though |
12:59:29 | FromDiscord | <Rika> probably int size for the threshold |
12:59:44 | FromDiscord | <dlesnoff> Aren't they both 64 bits on a 64 bit arch ? |
12:59:51 | FromDiscord | <auxym> yes, but not on 32 bit |
13:00:22 | FromDiscord | <auxym> for some reason I remember sizeof(float), but 🤷 |
13:00:52 | FromDiscord | <Rika> the difference matters outside of desktop use ofc |
13:01:38 | FromDiscord | <aMOPel> In reply to @auxym "yes, but not on": is float always float64 and int could be either depending on arch? |
13:01:59 | FromDiscord | <Rika> yes |
13:03:28 | FromDiscord | <aMOPel> I've also been wondering how expensive objects, tuples and arrays are. I mean of course they have different usecases, but if it didn't matter is array more efficient than tuple more efficient than object? Is it a big difference? |
13:03:58 | FromDiscord | <aMOPel> (edit) "matter" => "matter," |
13:04:30 | * | derpydoo quit (Ping timeout: 250 seconds) |
13:07:39 | FromDiscord | <auxym> tuple is basically the same as an object/struct. just handled slightly different in type checks |
13:09:18 | FromDiscord | <aMOPel> Eg for a vector type you have homogeneous data, so you could use either. Would it be much more costly to use tuples than arrays for this? I imagine objects being more expensive when using inheritance. |
13:12:35 | FromDiscord | <auxym> plain objects (not using the `of` keyword for inheritance) just compile to a plain old struct in C, so they are as efficient. I'd expect array/tuple/object to have extremely similar performance characteristics. They are all homogeneous data stored contiguously in memory. |
13:15:30 | FromDiscord | <aMOPel> Alright. Thank you all for your help 🙂 |
13:15:34 | FromDiscord | <federico3> is fox0430 around? |
13:24:38 | FromDiscord | <untoreh> sent a code paste, see https://play.nim-lang.org/#ix=4dPL |
13:25:32 | FromDiscord | <Tanguy> Chronos should support arc & orc |
13:27:08 | FromDiscord | <Tanguy> It's tested in the CI, but I don't know if anyone actually used it in production, so you may hit some bugs |
13:28:15 | FromDiscord | <untoreh> with arc just using `sleepasync` leaks memory, but this stacktraces are from segfaults |
13:28:16 | FromDiscord | <Tanguy> The interesting line in your backtrace is "scorperZhttpZstreamserver", the crash is coming from this |
13:31:09 | FromDiscord | <untoreh> scorper does seem to do some gcsafe casts, that could be maybe |
13:37:54 | FromDiscord | <Rika> what in gods name is that stacktrace |
13:39:08 | FromDiscord | <Bung> yeah, there's one place https://github.com/bung87/scorper/blob/ac56dcce0462198babb2aeea05643ecd9c041e6d/src/scorper/http/streamserver.nim#L132↵(@untoreh) |
13:39:33 | FromDiscord | <exelotl> In reply to @Rika "what in gods name": It's a GDB stack trace showing the mangled Nim function names from C 🥲 |
13:39:45 | FromDiscord | <Rika> ah so its not from nim okay |
13:47:48 | FromDiscord | <sOkam!> What should I use for documenting Nim code, in a way that can then be converted into web documentation?↵Any recommendations? |
13:53:43 | FromDiscord | <exelotl> I'm using Sphinx with a god awful extension that I wrote myself. I'm fairly happy with the results but its still pretty unfinished :(↵https://natu.exelo.tl/↵https://git.sr.ht/~exelotl/natu-docs |
13:55:06 | FromDiscord | <exelotl> Mainly, enum & object types aren't rendered properly, and cross-references to types in function signatures don't work |
13:57:31 | FromDiscord | <exelotl> You're probably best off sticking to the built-in docgen of the Nim compiler |
13:58:12 | FromDiscord | <exelotl> Unless you desparately want to break free from the way it groups things, like I did |
14:12:35 | FromDiscord | <sOkam!> In reply to @exelotl "I'm using Sphinx with": does the builtin docgen work with readthedocs.io?↵I was thinking of sphynx for that reason (plus it seems to be pretty good for C)↵But if the docgen works for that site, I'm happy to use it |
14:12:57 | FromDiscord | <sOkam!> What made you want to break free from it, btw? any specifics? |
14:27:19 | FromDiscord | <exelotl> sent a long message, see http://ix.io/4dQ7 |
14:29:16 | FromDiscord | <exelotl> (edit) "https://paste.rs/s2C" => "http://ix.io/4dQ8" |
14:31:39 | FromDiscord | <exelotl> I don't think Nim's built-in docgen works with readthedocs |
14:32:37 | FromDiscord | <exelotl> Maybe there's a way to make it work |
14:55:03 | FromDiscord | <dlesnoff> In reply to @exelotl "The built in doc": I also wish that docs actually did group overloaded functions |
14:55:33 | FromDiscord | <dlesnoff> It could number them, and print the text documentation of each overloaded functions |
14:56:25 | FromDiscord | <dlesnoff> Thus showing how many overloaded functions there is, and the type changes between these |
15:08:08 | FromDiscord | <sOkam!> @exelotl I really like the look of your natu project docs. Really really neat |
15:08:51 | FromDiscord | <sOkam!> Have you ever worked with sphynx for C? If so, does it change much from the way it works with your system for Nim? |
15:09:32 | FromDiscord | <sOkam!> I have to deal with both languages, so if it works the same for both with that method, I would happily learn that first |
15:20:54 | FromDiscord | <exelotl> I haven't used Sphinx for C but mixing 2 languages in the same project can definitely work |
15:25:14 | FromDiscord | <sOkam!> In reply to @exelotl "I haven't used Sphinx": That would be even better. Although I'm not sure if I would need it, but potentially maybe could |
15:25:42 | FromDiscord | <sOkam!> But just learning the doc infrastructure is what stops me really. Sphynx seems intimidating |
15:34:30 | FromDiscord | <exelotl> sent a long message, see http://ix.io/4dQs |
15:37:38 | FromDiscord | <exelotl> but then the convenience of course comes from being able to automatically document things, taking the signatures and descriptions from the source code. For that, my autonim module lets you do this.↵https://git.sr.ht/~exelotl/natu-docs/tree/master/item/video.rst↵whereas the ones for other languages are probably a bit better implemented than mine. Like in python you can just say "document this entire module for me please" https://www.sp |
15:45:05 | FromDiscord | <sOkam!> it works for python too? 👀↵well, seems like I will be learning sphynx soon then |
15:47:46 | FromDiscord | <sOkam!> hows working with rst compared to md, btw. I'm very very used to md, so hoping its not too different |
15:49:10 | FromDiscord | <Tom> Hi! How do I make a new object based on an old one? Like `{...a, b: 5}` in JS, for example. |
15:58:30 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4dQy |
15:59:00 | FromDiscord | <Phil> Both var to demonstrate that the deepCopy most certainly generates a full copy |
15:59:48 | FromDiscord | <Phil> Though something like the spread operator I don't think wehave |
16:00:19 | FromDiscord | <Rika> Would have copied even if you didn’t deep copy because nothing in that object has ref semantics |
16:01:03 | FromDiscord | <Phil> I mean, yeah but I can't know if Tom won't have an object with ref semantics |
16:06:30 | * | xet7 joined #nim |
16:06:50 | FromDiscord | <exelotl> In reply to @sOkam! "hows working with rst": MD is definitely easier but also more limited and poorly standardised cause it wasn't intended for technical writing. I like RST, but imo Asciidoc is the best of them all :P |
16:07:53 | FromDiscord | <Tom> In reply to @Isofruit "Though something like the": Thanks for the info! To others as well. In this case, I want shallow, not deep. I'll just go with value assignment and change. |
16:44:03 | * | xet7_ joined #nim |
16:44:40 | * | xet7_ quit (Remote host closed the connection) |
17:00:02 | FromDiscord | <narimiran> Third and final session of NimConf 2022 is about to start:↵↵https://www.youtube.com/watch?v=0b3ixaz2uOg&list=PLxLdEZg8DRwSQQaK0UVRd1DaetVc3lIwr&index=10 |
17:12:23 | * | xet7 quit (Quit: Leaving) |
17:26:02 | * | derpydoo joined #nim |
17:45:14 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dR3 |
17:45:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dR4 |
17:46:36 | FromDiscord | <sOkam!> ty, yeah seems like that worked. it compiled 🙂 |
17:48:21 | FromDiscord | <Zoom> Hey everyone! Do we have anything to wait on a process yet? Any alternatives to std/selectors? May be something planned for [leorize](https://matrix.to/#/%40leorize%3Aenvs.net)'s nim-sys? |
17:49:24 | FromDiscord | <leorize> chronos does have something for that iirc |
17:51:57 | FromDiscord | <leorize> I have the exec branch in nim-sys with API design but unfortunately I don't have time to work on it |
17:55:06 | FromDiscord | <Zoom> they have `selectors2.nim` and it's the same problem - only sockets and user events for Windows. |
17:56:46 | FromDiscord | <Zoom> It's a bit silly that I need to use a threadpool/manual thread just to be able to wait on a process properly. |
17:57:21 | FromDiscord | <Elegantbeef> You mean wait for a process started to end? |
17:57:33 | FromDiscord | <leorize> technically that's what you do on windows too |
17:57:53 | FromDiscord | <Elegantbeef> You can use async since the process is not blocking |
17:58:15 | FromDiscord | <Elegantbeef> It's not in the stdlib, but it's not overly complicated |
18:01:45 | FromDiscord | <Zoom> I don't understand async and I don't see the point of bringing all that complexity in anyway. Thread-\>process is easier. |
18:02:16 | FromDiscord | <Bung> I think Zoom want some like goroutine |
18:02:22 | FromDiscord | <Elegantbeef> Async is just thread sharing, you give up your cpu at designated points `poll` `await` and so forth |
18:02:44 | FromDiscord | <Elegantbeef> saying goroutine are green threads? |
18:03:21 | FromDiscord | <Require Support> what do i do if there is an ambiguous calls between two nimble packages -.- |
18:03:34 | FromDiscord | <Bung> I have no idea |
18:03:35 | FromDiscord | <Elegantbeef> You do `myPackage.myProcedure` |
18:03:47 | FromDiscord | <Elegantbeef> or `import x except myProcedure` |
18:05:19 | FromDiscord | <Require Support> (edit) "calls" => "call" |
18:07:19 | FromDiscord | <sOkam!> how do you convert a `char` to `string`? 🧩 |
18:07:30 | FromDiscord | <Elegantbeef> `$` like 99% of other types |
18:07:38 | FromDiscord | <sOkam!> oh, me dummie |
18:09:11 | FromDiscord | <Zoom> To launch processes, in Rust I just use rayon.pariter and don't care how it works. In Nim I could just use std/threadpool but it doesn't work with ORC, so I dumbimplement a pool by hand, process.waitForExit() in threads and use two locks\: to save results and output logging to stderr. Tell me how I'm wrong. |
18:10:12 | FromDiscord | <Elegantbeef> https://github.com/pietroppeter/nimibook/blob/main/src/nimibook/builds.nim#L5-L25 |
18:10:32 | FromDiscord | <Elegantbeef> You're not wrong, it's just not overly complex to do it without threads in Nim |
18:13:13 | FromDiscord | <Zoom> No shit, I started with that\: just peekExitCode, but if you're trying to do it in parallel you burn too many cycles just to check the processes. Also, I got zombies this way, and couldn't find what I was doing wrong (and I think even I could have found it in those \~10 lines) |
18:15:19 | FromDiscord | <Zoom> Yeah, you could not burn cpu with asyncSleep, but what the point if you need to bring the whole async stuff just to sleep efficiently |
18:15:40 | FromDiscord | <Elegantbeef> Dont look at me i use a single core like a good boy |
18:15:44 | FromDiscord | <Elegantbeef> I rarely use threading or async |
18:17:03 | FromDiscord | <Elegantbeef> I'll say the line for you "Fucking game devs" |
18:23:38 | FromDiscord | <Zoom> My peanut size brain is barely enough to write 100-line scripts at best. When half of that is a strange thread/process pool hybrid, I feel silly. I could live with it, though. |
18:29:43 | FromDiscord | <Require Support> but you are always right |
18:29:53 | * | derpydoo quit (Ping timeout: 276 seconds) |
18:51:08 | * | derpydoo joined #nim |
19:30:24 | FromDiscord | <guttural666> how can I default strings in procedure signatures to "" = empty string without using an Option? thanks! |
19:30:52 | FromDiscord | <guttural666> empty double quotes seem to be immutable |
19:32:40 | FromDiscord | <guttural666> got proc do_stuff(from_dir, to_dir: var string = "") = |
19:33:58 | FromDiscord | <huantian> you may just want to use an overload |
19:38:06 | * | Guest30 joined #nim |
19:38:08 | Guest30 | awd |
19:40:33 | * | Guest30 quit (Client Quit) |
19:40:37 | FromDiscord | <guttural666> easier to make the strings in the signature immutable and make local copies in the proc body, bit of a waste, but okay |
19:40:40 | FromDiscord | <guttural666> thanks! |
19:41:17 | * | wallabra joined #nim |
19:41:24 | FromDiscord | <guttural666> (defaulting to dir: string = "" works in the signature) |
19:48:39 | * | greaser|q quit (Changing host) |
19:48:39 | * | greaser|q joined #nim |
19:48:41 | * | greaser|q is now known as GreaseMonkey |
20:13:27 | FromDiscord | <Phil> sent a long message, see http://ix.io/4dRH |
20:14:05 | FromDiscord | <Elegantbeef> the semantics are different in devel and stable |
20:14:21 | FromDiscord | <Elegantbeef> So if you're testing with stable of course it'll break |
20:15:09 | FromDiscord | <Phil> The pipelines were running on github and I was PR'ing to devel, so I'd assume they were set up to compile with devel etc. |
20:15:45 | FromDiscord | <Elegantbeef> Uhh |
20:15:46 | FromDiscord | <Elegantbeef> Odd |
20:16:16 | FromDiscord | <Phil> And the error of the pipeline is:↵> /home/runner/work/Nim/Nim/lib/pure/base64.nim(143, 39) Error: expression has no address; maybe use 'unsafeAddr' |
20:16:33 | FromDiscord | <Phil> So I'm chalking this one up to be a wrong warning from the compiler rather than bad code in the base64 lib |
20:16:56 | * | derpydoo quit (Quit: derpydoo) |
20:18:47 | FromDiscord | <Require Support> does valgrind work on windows binaries if im looking to find memory leaks? |
20:21:19 | FromDiscord | <Phil> Sadly can't say much about that as I don't really use it |
20:21:59 | FromDiscord | <Elegantbeef> valgrind + `-d:useMalloc` |
20:24:08 | FromDiscord | <Require Support> it works on EXEs? |
20:24:22 | FromDiscord | <Require Support> TIL |
20:24:27 | FromDiscord | <Elegantbeef> No clue i dont use windows |
20:24:45 | FromDiscord | <Require Support> oh ye from what i checked i dont think it does |
20:28:58 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4dRN |
20:30:08 | FromDiscord | <Elegantbeef> The above doesnt reimplement discard |
20:30:16 | FromDiscord | <Elegantbeef> Discard still runs the right hand |
20:31:10 | FromDiscord | <dlesnoff> Oh gosh, how could I overlooked this 😦 |
20:31:34 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dRO |
20:34:20 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4dRP |
20:35:08 | FromDiscord | <dlesnoff> The macro adds you s times the body's AST while the template adds the for loop and the body AST. |
20:49:59 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4dRS |
20:50:29 | FromDiscord | <Elegantbeef> Templates substitute code, macros allow introspection |
20:51:02 | FromDiscord | <Phil> norm's `withDb` template is a nice example for where templates are useful |
20:55:10 | FromDiscord | <Bung> oh beef you re online like 24 hours |
20:55:46 | FromDiscord | <Phil> He isn't! I'd know because I'd have asked more questions back when I was more obsessed with getting my backend written |
20:58:10 | FromDiscord | <Bung> maybe he take rest when you ask |
20:58:59 | FromDiscord | <Phil> Oh wait, wouldn't also a very simple example be generating a dot expression? |
20:59:19 | FromDiscord | <Phil> Because if I could've done that via template I would've done so ages ago |
21:01:04 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/omY |
21:01:17 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4dRY" => "https://play.nim-lang.org/#ix=4dRZ" |
21:01:52 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4dRZ" => "https://play.nim-lang.org/#ix=4dS0" |
21:01:54 | FromDiscord | <Bung> there is withmacro |
21:02:15 | FromDiscord | <Bung> help u write less |
21:12:47 | FromDiscord | <dlesnoff> Sorry for the late reply @Phil I am getting sleepy after this NimConf day after all. The harder part in writing this tutorial is understanding what makes it hard for a beginner. What are the questions you ask yourselves when you discover it ?↵What should I assume from a learning developer (does he know what is an AST ? at least some familiarity with Nim, but which part of it ?). |
21:13:39 | FromDiscord | <dlesnoff> There has been actually a lot of macro tutorials here and there, it is quite daunting to try to make something new. |
21:19:04 | FromDiscord | <sOkam!> Is there a specific idiomatic way for dealing with boolean "sets"?↵I don't want to call them bitfields, because I'm not refering to `thing:1` notation from C, but rather int variables where each bit is used as a bool |
21:27:04 | PMunch | Just a set? |
21:27:07 | PMunch | Or a bitset |
21:27:13 | FromDiscord | <Zoom> There's packedsets |
21:27:59 | FromDiscord | <sOkam!> std/bitops looks really cool↵but was thinking of something simpler that makes the syntax more sensible, as its usually the case with all things NIm |
21:29:02 | FromDiscord | <sOkam!> biggest thing for me would be to be able to access something by name, instead of having to filter it with bitwise math to extract it out |
21:30:42 | NimEventer | New thread by inv2004: Double pointer FFI to C, see https://forum.nim-lang.org/t/9541 |
21:31:42 | FromDiscord | <Elegantbeef> Nah i sleep atleast 10 hours a day↵(@Bung) |
21:32:16 | FromDiscord | <Elegantbeef> you dont need to do `obj.value` cause the field is already that↵(@Phil) |
21:32:33 | FromDiscord | <Elegantbeef> Whoops |
21:32:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSc |
21:32:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSd |
21:33:18 | FromDiscord | <Elegantbeef> One day i'll write code that runs |
21:33:59 | FromDiscord | <Elegantbeef> There we go |
21:34:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSf |
21:34:22 | FromDiscord | <Elegantbeef> And if you make it an object it'll be `a.fieldName` |
21:34:41 | FromDiscord | <sOkam!> Is there an enum-like type that grows by bits, instead of by ordinal?↵I think that would be the match made in heaven |
21:35:06 | FromDiscord | <Elegantbeef> You already have Nim bitsets |
21:35:07 | FromDiscord | <Elegantbeef> You already have what you want |
21:35:23 | FromDiscord | <Phil> In reply to @Elegantbeef "you dont need to": I'm aware of that, but the workflow very often is : ↵1) iterate over object with fieldpairs to do some analysis, write down the field-name somewhere↵2) Somewhere else, make use of the seq[static string] to do various things or cross-check stuff against another type |
21:35:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSg |
21:36:16 | FromDiscord | <Elegantbeef> See i never will write code that works... missing "]" on line 4 |
21:36:34 | FromDiscord | <Elegantbeef> Yea phil i dont deal with strings so i dont know |
21:37:29 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dSi |
21:37:56 | FromDiscord | <sOkam!> also, do you have to do `MyFlags[MyFlag.run]` to access the value? or how do you use it? |
21:40:02 | FromDiscord | <Elegantbeef> Wirth had a good idea with firstclass bitsets |
21:40:08 | FromDiscord | <Elegantbeef> Sad that no other major language uses them |
21:41:51 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dS7 |
21:42:21 | FromDiscord | <sOkam!> I guess it can be done with templates, but that's how my brain reasons about this type of idea |
21:42:27 | FromDiscord | <Elegantbeef> That's pointless though |
21:42:37 | FromDiscord | <Elegantbeef> Like what does `bitenum` give you? |
21:42:45 | FromDiscord | <sOkam!> how? the goal is to be able to use the bit as a bool |
21:42:58 | FromDiscord | <Elegantbeef> So literally a converter will suffice |
21:43:06 | FromDiscord | <sOkam!> without having to do `MyFlagGroup[Run]` |
21:43:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSa |
21:43:54 | FromDiscord | <sOkam!> ah i guess, yeah |
21:44:20 | FromDiscord | <sOkam!> can you modify that way, though? |
21:44:25 | FromDiscord | <Elegantbeef> But that doesnt make any sense really cause why is run special |
21:44:51 | FromDiscord | <sOkam!> because if its part of a state machine, it will need to be changed a lot |
21:45:03 | FromDiscord | <Elegantbeef> I dont follow |
21:45:23 | FromDiscord | <Elegantbeef> If it's a state machine you likely will use an array or case statement to provide the logic you need |
21:45:54 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dSe |
21:46:07 | FromDiscord | <Elegantbeef> So then why are you even wanting bitflags? |
21:46:39 | FromDiscord | <Elegantbeef> There is `setutils` that allows you to do `mySet[Jump] = true` |
21:46:44 | FromDiscord | <Elegantbeef> But i still dont see the point |
21:47:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSh |
21:47:57 | FromDiscord | <sOkam!> `myset.incl` and `in myset` are not things you would say to reason about the state of the logic↵which makes for extra processing when reading |
21:48:08 | FromDiscord | <sOkam!> in terms of the human brain, reasoning about it, not the machine |
21:48:36 | FromDiscord | <Elegantbeef> Ok i'm not going to comment further cause it's like 90% english |
21:49:00 | * | PMunch quit (Remote host closed the connection) |
21:49:30 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dSk |
21:49:45 | FromDiscord | <Elegantbeef> I dont see the point of a bitset here if this is a single state you care about |
21:49:47 | FromDiscord | <sOkam!> write that with that set syntax, and it becomes really hard to read |
21:50:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSl |
21:51:00 | FromDiscord | <Elegantbeef> If you only have a single state why you want bitflags is beyond me |
21:51:15 | FromDiscord | <sOkam!> excl is not an intuitive word. the point is searching for a way to make it intuitive |
21:51:36 | FromDiscord | <Elegantbeef> so then use setutils `myFlags[Running] = false` |
21:51:52 | FromDiscord | <sOkam!> the point is to use Running=false 🤦♂️ |
21:52:04 | FromDiscord | <Elegantbeef> Ah yes global variables the best |
21:52:07 | FromDiscord | <sOkam!> while still be able to use Running as an index |
21:52:08 | FromDiscord | <Elegantbeef> Anyway have fun |
21:53:47 | FromDiscord | <sOkam!> why the sarcasm? im just trying to simplify the syntax |
21:54:20 | FromDiscord | <sOkam!> and I learned in Pure C... so, yeah I might be fucking up. The goal is to learn to write simpler to read code |
22:04:51 | * | wallabra_ joined #nim |
22:07:02 | * | wallabra quit (Ping timeout: 250 seconds) |
22:07:04 | * | wallabra_ is now known as wallabra |
22:12:24 | arkanoid | is I create a converter in a module and I don't export it, will it spread over to other modules? |
22:13:11 | FromDiscord | <guttural666> any way to force echo to print out the integer value of an enum? it seems to default to the readable string |
22:13:25 | FromDiscord | <Elegantbeef> `$ ord(myEnum)` |
22:13:35 | * | fanta1 quit (Quit: fanta1) |
22:13:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSt |
22:13:57 | FromDiscord | <Elegantbeef> No it shouldnt ark, if it does it's due to a bug |
22:16:43 | FromDiscord | <Require Support> sent a code paste, see https://play.nim-lang.org/#ix=4dSv |
22:16:46 | FromDiscord | <guttural666> worked, thanks very much, now to find out what that does 😄 |
22:19:10 | FromDiscord | <guttural666> $ stringifies the ordinal type of the enum which I get with the proc ord and which would be an int32, is that about right? |
22:19:19 | FromDiscord | <Elegantbeef> `ord` returns the ordinal value |
22:19:22 | FromDiscord | <Elegantbeef> which is `int` |
22:19:53 | FromDiscord | <guttural666> don't seem to need $ for the echo though |
22:19:55 | FromDiscord | <guttural666> yeah |
22:19:58 | FromDiscord | <guttural666> got it |
22:20:06 | FromDiscord | <Elegantbeef> Correct echo implicitly calls `$` |
22:20:17 | FromDiscord | <guttural666> ah, very interesting |
22:20:22 | FromDiscord | <guttural666> thanks! |
22:20:39 | FromDiscord | <guttural666> damn, Nim is so much fun |
22:20:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSw |
22:21:11 | FromDiscord | <Elegantbeef> So in this case all calls to `echo` calls `$` |
22:22:08 | FromDiscord | <Elegantbeef> Yes↵(@Require Support) |
22:22:09 | arkanoid | not quite sure what's happening, but trying to compile this line makes compile endless and cpu spinning 100% "converter toMeasure[T: FloatLike and not openArray and not object and not Measurement](x: T): Measurement[T] = x ?? 0.01.T" |
22:26:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSx |
22:27:06 | FromDiscord | <Elegantbeef> You likely are recursively calling the converter causing the compiler to lock up |
22:27:40 | FromDiscord | <Elegantbeef> Well i guess that's wrong cause this causes the compiler to stack overflow |
22:28:40 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dSy |
22:28:53 | FromDiscord | <Elegantbeef> Nope |
22:29:41 | FromDiscord | <Bung> so problem here is it convert to closure |
22:29:44 | FromDiscord | <Elegantbeef> Arkanoid also I will note you can do `T: FloatLike and not(openArray or object or Measurement)` not that it helps you |
22:30:04 | arkanoid | Thanks! |
22:30:10 | FromDiscord | <Bung> as I notice the the code gen has env fields |
22:30:47 | FromDiscord | <Elegantbeef> Yea Bung the issue there is that `: ProcType = proc() = discard` doesnt properly raise it to a closure |
22:32:37 | FromDiscord | <Bung> wait , raise it to a closure ? |
22:32:45 | FromDiscord | <Elegantbeef> Sorry i didnt test the code |
22:32:51 | FromDiscord | <Bung> should be closure and not |
22:34:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSB |
22:34:29 | FromDiscord | <Elegantbeef> Or NimNil if that exists |
22:34:52 | FromDiscord | <Elegantbeef> The constant closure doesnt generate an environment so it's incorrect to attempt to assign it to an environment |
22:35:06 | FromDiscord | <Elegantbeef> Alternatively you need to emit a the proper type for a closure procedure |
22:36:43 | FromDiscord | <Bung> it's like the compiler think it is closure, but not assign fields propertly? |
22:38:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSE |
22:38:52 | FromDiscord | <Elegantbeef> It's attempting to copy the procedure to the address of `a`, but the two types are different |
22:39:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSF |
22:40:07 | FromDiscord | <Elegantbeef> `colonanonymous_test_4` if unclear is just a procedure, whereas `atest_6` is a closure procedure(a struct in C) |
22:40:52 | FromDiscord | <Elegantbeef> So there needs to be special handling to set the environment to nil and the procedure to the pointer |
22:41:20 | FromDiscord | <Elegantbeef> Hopefully this makes sense |
22:41:34 | FromDiscord | <Bung> so `let arr: array[1, ProcType] = [something]` left is what , right is what |
22:41:56 | FromDiscord | <account inactive> is there any packages which support the printing of text to a specific region of a terminal? Or if it can be done natively? |
22:42:23 | FromDiscord | <Elegantbeef> Left is an array of closures, right is an array of closures |
22:42:34 | FromDiscord | <Bung> right is `colonanonymous_test_4` left is `atest_6` ? |
22:42:54 | FromDiscord | <Elegantbeef> I used a smaller example sorry |
22:42:55 | FromDiscord | <Elegantbeef> And in that case you are correct |
22:42:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSI |
22:43:08 | FromDiscord | <Elegantbeef> But it's the same problem the generated C needs to be specialised for constant closures |
22:44:59 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/ca1f3f36b9aff3b8284b2f529fd6fedb72a396c5/compiler/ccgtrav.nim#L114-L115 might be where you need to look, i dont know Cgen much |
22:45:03 | FromDiscord | <Bung> um, I didn't thought left will generate like that as it's new to compiler |
22:45:43 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/search?q=ClE_0 might help you find the issue area |
22:46:32 | FromDiscord | <Bung> I thought it will generate same struct as runtime closure |
22:46:44 | FromDiscord | <Elegantbeef> I'm not testing on devel, so it might |
22:46:56 | FromDiscord | <Elegantbeef> It seems to only emit a procedure and no struct |
22:47:21 | FromDiscord | <Elegantbeef> Which makes sense as that's all required |
22:48:00 | FromDiscord | <Elegantbeef> Of course araq would give you better instruction on how to fix it, i can only guess with my very limited knowledge on what's best |
22:48:24 | FromDiscord | <Elegantbeef> I avoid the gen side of the compiler since it's just hell on earth 😛 |
22:48:55 | FromDiscord | <Elegantbeef> Worth noting the generated code here is different depending on RCs vs Refc |
22:49:39 | FromDiscord | <Elegantbeef> Hmm this is like;y the real culprit https://github.com/nim-lang/Nim/blob/2f441ac6754e76f936900f4f4641587a82967f71/compiler/ccgexprs.nim#L355-L360 |
22:51:21 | FromDiscord | <Bung> https://github.com/nim-lang/Nim/pull/20616 araq's one make me more confusing |
22:51:32 | arkanoid | I have a large object type made of many distinct float types. I need to write the equivalent type object with same attributes but with type "float" instead for casting. Can I do this with metaprogramming? I don't want to create a copypaste of all my types with distinct types back to float just to make them compatible with nimpy |
22:51:36 | FromDiscord | <Elegantbeef> What confuses you? |
22:51:51 | FromDiscord | <Elegantbeef> Just make the object a generic↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
22:51:56 | FromDiscord | <Bung> `result.kind == nkTupleConstr and result[1].kind != nkNilLit:` |
22:52:24 | FromDiscord | <Elegantbeef> The compiler converts closures to `(procName, environment)` |
22:52:48 | FromDiscord | <Elegantbeef> so if the result is a tuple we know it's a closure and if the second value is not nil we know it's a closure with environment |
22:53:00 | FromDiscord | <Elegantbeef> Eventually i'll stop replying to IRC users again |
22:53:05 | FromDiscord | <Elegantbeef> Sorry discord/irc users 😄 |
22:53:24 | FromDiscord | <Bung> ah, I understand now |
22:54:47 | FromDiscord | <Elegantbeef> I should say the tuple check is for seeing that it's a direct closure and not a closure stored in a variable |
22:55:31 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSP |
22:56:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSQ |
22:56:12 | FromDiscord | <Bung> oh yes, araq's one works |
22:56:29 | FromDiscord | <Elegantbeef> Wait it makes CGen not an issue? |
22:57:01 | FromDiscord | <Elegantbeef> Cgen should still be an issue |
22:57:11 | FromDiscord | <Bung> no, I just verify this test case https://github.com/nim-lang/Nim/pull/20597/files |
22:58:41 | FromDiscord | <Bung> yes, array constuct same error , as it has no env , will pass here |
22:59:00 | FromDiscord | <Elegantbeef> Yep it's just rewriting the C/Js gen to support this |
22:59:42 | arkanoid | is it possible to cast a ref object type to a non-ref object type with same fields in same order? |
22:59:57 | FromDiscord | <Elegantbeef> `myRef[]` |
23:01:14 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dSU |
23:14:23 | * | jmdaemon joined #nim |
23:19:18 | arkanoid | well, thanks, but apparently is not sufficient for what I am trying to do |
23:20:13 | arkanoid | nimpy page says there's an experimental way to export a nim type as python class, but it doesn't say if there's another way to do that (for example exporting as a dict) https://github.com/yglukhov/nimpy#exporting-nim-types-as-python-classes |
23:35:57 | * | wallabra_ joined #nim |
23:36:41 | * | wallabra quit (Ping timeout: 276 seconds) |
23:37:53 | * | wallabra_ is now known as wallabra |
23:46:48 | FromDiscord | <Bung> cgen part is complicated.. |
23:53:12 | * | wallabra quit (Ping timeout: 250 seconds) |
23:53:31 | FromDiscord | <Bung> I think I can modify the assignment instead of generate same struct |
23:53:43 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dSX |
23:55:09 | * | wallabra joined #nim |
23:55:15 | NimEventer | New thread by bpr: Newbie first impressions, see https://forum.nim-lang.org/t/9542 |