<< 22-10-2022 >>

00:27:25FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dNr
00:28:36FromDiscord<sOkam!> oh... is it because `notin` is reserved, and im clashing with it with `I`
00:29:55FromDiscord<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:59FromDiscord<Elegantbeef> What's even the point
00:30:12FromDiscord<Elegantbeef> `a notin 10..20`
00:30:30FromDiscord<Elegantbeef> Macro if you need introspection, template if you dont
00:30:39FromDiscord<sOkam!> whats introspection?
00:31:08FromDiscord<Elegantbeef> Using the input to run code statically to change the output
00:32:58FromDiscord<sOkam!> i think im missing like 3 or 4 points in that one sentence
00:33:28FromDiscord<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:39FromDiscord<Elegantbeef> The reason you use a template is you can just do code subsitution
00:33:53FromDiscord<sOkam!> i see
00:34:26FromDiscord<sOkam!> so templates are similar to C #defines↵is there something similar in C that resembles nim macros?
00:34:49FromDiscord<Elegantbeef> No
00:34:58FromDiscord<Elegantbeef> Nim macros take in AST you operate on said AST and can emit new AST
00:35:32FromDiscord<sOkam!> kk. but there is no ast modification in c. i think i get it now
00:36:20arkanoidI'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:53FromDiscord<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:06FromDiscord<Elegantbeef> `std/option`
00:37:31arkanoidI guess I can't go faster than this without leveraging on better algorithms or special ad-hoc instructions
00:42:35FromDiscord<Elegantbeef> Arkanoid what're you compiler flags?
00:44:02arkanoidElegantbeef: https://play.nim-lang.org/#ix=4dNw
00:44:23FromDiscord<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:57FromDiscord<Elegantbeef> You unpack the value
00:45:10FromDiscord<Elegantbeef> so `myOption.mget` if it's `varT` or `myOption.get`
00:46:30arkanoidis there anything else I can do (easily) to improve it?
00:48:04FromDiscord<Elegantbeef> `-d:lto` is one, unlikely but `--mm:arc` or `--mm:orc` is another
00:50:48arkanoid(sorry, I forget to tell you about my config.nims) I'm already using --gc:arc and --experimental: strictFuncs
01:00:50arkanoidlol, I've found C code into nim js output: benchmark.js:4102 keepInt_687866206[0]+= (void*)&r_553648196;
01:02:32arkanoidI think is benchy not tested on js
01:03:56FromDiscord<Elegantbeef> Yea keep emits code that ensures the C compiler doesnt optimise out the value, but likely has 0 JS support
01:05:06FromDiscord<Elegantbeef> It uses `emit` and `monotimes` so likely 0 JS support
01:08:01arkanoidI was just curious how it would perform on js
01:08:51arkanoidmoving a whole piece of logic from python to nim stack-only, fully typed (with "unchained"!) logic, it's just refreshing
01:10:21FromDiscord<Elegantbeef> There is https://gitlab.com/define-private-public/stopwatch
01:10:31FromDiscord<Elegantbeef> If you're overly interested
01:25:15*arkurious quit (Quit: Leaving)
01:27:51FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNF
01:29:40FromDiscord<Elegantbeef> Why do you setPos?
01:29:45FromDiscord<Elegantbeef> Ah nvm i'm dumb again
01:32:37FromDiscord<huantian> In reply to @Elegantbeef "`-d:lto` is one, unlikely": Does panics on help performance? Or is that on by default now
01:33:13FromDiscord<Elegantbeef> Fuck if i know 😄
01:38:58FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNH
01:39:20FromDiscord<Elegantbeef> Well it's an internal compiler error from a macro likely
01:39:39FromDiscord<Elegantbeef> You're passing `nkNilLit` to a procedure that expects `nkSym`
01:42:11FromDiscord<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:49FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNP
02:14:14FromDiscord<Elegantbeef> `typeof(nil)`
02:14:24FromDiscord<Patitotective> yea
02:14:26FromDiscord<Elegantbeef> God I it
02:14:26FromDiscord<Elegantbeef> hate is the word supposed to be in that sentence
02:14:40*fallback quit (Ping timeout: 272 seconds)
02:14:55FromDiscord<Patitotective> i just thought itd be easier than catching all nil literals in my macros ;]
02:15:20FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dNQ
02:17:03FromDiscord<Patitotective> this is the file that fails https://github.com/Patitotective/kdl-nim/blob/devel/tests/test_serializer.nim
02:18:21FromDiscord<Elegantbeef> Yea i dont see anything here
02:18:57FromDiscord<Patitotective> maybe macros + `Stream` being a ref object (?)
02:19:06FromDiscord<Elegantbeef> no
02:19:17FromDiscord<Patitotective> :p
02:19:19FromDiscord<Elegantbeef> You're passing a nil lit into the compiler somewhere it expects a symbol
02:19:34FromDiscord<Elegantbeef> It's not rocket science, the solution is to stop using a typeless nillit
02:20:03FromDiscord<Patitotective> https://media.discordapp.net/attachments/371759389889003532/1033203048346026084/unknown.png
02:20:12FromDiscord<Patitotective> In reply to @Elegantbeef "It's not rocket science,": lemme try
02:20:59FromDiscord<Elegantbeef> I personally hate typeless nil, it's a leaking implementation if you ask me
02:21:35FromDiscord<Patitotective> i literally commented out the whole procedure and the compiler does not even care
02:32:23*fallback joined #nim
02:35:40FromDiscord<huantian> In reply to @Elegantbeef "I personally hate typeless": What if I need to do nil[]
02:36:16FromDiscord<Elegantbeef> ...
02:36:22FromDiscord<Elegantbeef> !block @huantian
02:42:21FromDiscord<Rika> Lol
02:46:35FromDiscord<Patitotective> huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuh↵everything fixes by using `let` instead of `const`
02:46:44FromDiscord<Patitotective> streams?
02:46:47FromDiscord<Patitotective> (edit)
02:49:19FromDiscord<Elegantbeef> Were you using const streams?
02:49:39FromDiscord<Patitotective> i was doing `const doc = parseKdl("node")`
02:50:33FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNU
02:52:59FromDiscord<Elegantbeef> Make sure you close the stream inside a try finally or a defer when you're parsing
02:53:15FromDiscord<Patitotective> :o
02:53:19FromDiscord<Patitotective> forgot
02:56:33FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dNV
02:56:42FromDiscord<Elegantbeef> yep
02:57:15FromDiscord<Patitotective> same error :[[
02:57:34FromDiscord<Elegantbeef> I mean it's obviously not going to change anything 😄
02:58:11FromDiscord<Patitotective> btw if i close the stream after lexing, if the parser tries to read it, it will fail right?
02:58:22FromDiscord<Elegantbeef> Yes
02:59:53FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4dNW nice
03:04:01FromDiscord<Patitotective> oh, so streams dont work at CT
03:04:02FromDiscord<Patitotective> huh
03:04:32FromDiscord<Patitotective> thats really bad, i wanted to use kdl in nimscript
03:08:02FromDiscord<Elegantbeef> There's your problem https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/streams.nim#L1293-L1298
03:09:22FromDiscord<Elegantbeef> Only part of string streams can be used at CT sadly
03:35:48FromDiscord<Patitotective> huh https://github.com/nim-lang/Nim/pull/19739
03:35:50FromDiscord<proton> Does Nim have io_uring
03:37:58FromDiscord<Patitotective> huh https://github.com/nim-lang/Nim/pull/12284/files
03:38:45FromDiscord<Patitotective> seems like i have to keep my string parser
03:38:50FromDiscord<Patitotective> (edit) "seems like i have to keep my string ... parser" added "based"
03:43:08FromDiscord<Elegantbeef> Generics exist
03:44:13FromDiscord<Patitotective> `stream: Stream or string`?
03:55:04FromDiscord<Elegantbeef> Or seperate procs for where you need the seperate logic
04:23:31FromDiscord<hovsater> In reply to @hotdog "Hey <@167708338589532162> welcome 🤗": Thanks! Appreciate it. 🙂
05:12:42FromDiscord<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:11FromDiscord<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:37FromDiscord<Elegantbeef> The limit for template depth is a compile time error
05:14:43FromDiscord<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:29FromDiscord<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:45FromDiscord<Elegantbeef> `of` branches have to be constants
06:35:26FromDiscord<sOkam!> ah didn't know
06:43:37*derpydoo joined #nim
07:01:42FromDiscord<sOkam!> is there a way to iterate a sequence in a way that each iteration value is modifiable?
07:02:40FromDiscord<Elegantbeef> `mitems`
07:03:33FromDiscord<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:07FromDiscord<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:31Amun-Ra##math?
07:56:36Amun-Raoh, discord
07:57:09FromDiscord<qb> Guess I've found something
07:57:19FromDiscord<qb> sent a code paste, see https://play.nim-lang.org/#ix=4dOz
07:58:31Amun-Rahttps://en.wikipedia.org/wiki/Centroid#Of_a_finite_set_of_points
07:58:52FromDiscord<Rika> There’s a lot of definitions for “centre” isn’t there
07:58:57Amun-Rayes
07:58:58FromDiscord<Rika> Centroid is one of them
08:02:30FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dOB
08:02:30FromDiscord<Elegantbeef> Doing the division in line might be right, i cannot be bothered to do the math
08:02:30FromDiscord<Elegantbeef> more likely wrong
08:06:12FromDiscord<dlesnoff> It is better in general to divide only at the end. It gives better numerical stability.
08:07:18FromDiscord<Elegantbeef> Think it might depend on how large your numbers are
08:07:25FromDiscord<Elegantbeef> But yea do it at the end like a normal person
08:21:35FromDiscord<sOkam!> Is there a way to lock a sequence to having a minimum on X items, and error otherwise?
08:23:06FromDiscord<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:16FromDiscord<qb> seems to work fine
08:26:18FromDiscord<qb> sent a code paste, see https://play.nim-lang.org/#ix=4dOC
08:26:55FromDiscord<Elegantbeef> It of course works but iterates 3 different types
08:27:04FromDiscord<Elegantbeef> For each axis
08:27:48FromDiscord<Elegantbeef> Just something to be conscientious of
08:36:23madpropsah i remember the beef game
08:36:26madpropsim gonna play it
08:36:38madprops)i would buy on steam)
08:41:13madpropshttps://i.imgur.com/eGQ2GpD.jpg
08:41:20madpropsstuck here and forgot what the objective is
08:41:23FromDiscord<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:04FromDiscord<Rika> In reply to @sOkam! "manual doesn't seem to": Yes
08:55:18*pro quit (Quit: pro)
08:58:51FromDiscord<sOkam!> kk ✍️
09:00:42FromDiscord<narimiran> NimConf is starting in one hour!!↵↵https://www.youtube.com/watch?v=aDi50K_Id_k&list=PLxLdEZg8DRwSQQaK0UVRd1DaetVc3lIwr
09:01:21madpropsnimconf?
09:01:28madpropsdo we get to see araq live
09:02:23madpropsevolution, not revolution
09:12:10*pro joined #nim
09:23:56*fanta1 joined #nim
09:48:04*pro quit (Quit: pro)
09:49:29FromDiscord<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:03PMunchNimConf 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:15FromDiscord<sOkam!> Is there an existing way to add to a seq only if the element is not already in it?
10:26:47FromDiscord<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:11FromDiscord<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:43FromDiscord<Rika> You lose ordering if you needed that
10:37:33PMunchIs there a playlist for this years conf?
10:37:48FromDiscord<Yardanico> yes
10:37:55FromDiscord<Yardanico> In reply to @PMunch "Is there a playlist": https://www.youtube.com/playlist?list=PLxLdEZg8DRwSQQaK0UVRd1DaetVc3lIwr
10:37:56PMunchNever mind, found it
10:38:11PMunchThe nimconf 2022 website still points to the old playlist..
11:10:30*jmdaemon quit (Ping timeout: 255 seconds)
11:21:33FromDiscord<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:18FromDiscord<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:18FromDiscord<aMOPel> sent a code paste, see https://play.nim-lang.org/#ix=4dPw
12:32:54FromDiscord<Rika> you cant make a ref from a nonref without a copy
12:33:01FromDiscord<Rika> otherwise, its called a pointer 😉
12:37:39FromDiscord<aMOPel> but that is possible in cpp right?
12:37:51FromDiscord<Phil> The copy would be of the obj from stack to heap right?
12:38:54FromDiscord<aMOPel> because nonrefs are on the stack and refs on the heap?
12:43:24FromDiscord<auxym> yes
12:44:03FromDiscord<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:08FromDiscord<Phil> You can have a ref to sth on the stack though, I recall as much
12:44:13FromDiscord<auxym> (edit) "in" => "if"
12:44:30FromDiscord<Phil> Though I might be mixing that up with using addr
12:47:03FromDiscord<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:04FromDiscord<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:14FromDiscord<auxym> yeah, that's a pointer
12:47:51FromDiscord<auxym> you can do it in nim with `.addr` (or `unsafeAddr`). But pointers are not managed by Nim's GC, unlike refs
12:48:41FromDiscord<aMOPel> thus I'd have to free the data before my last pointer goes out of scope right?
12:49:20FromDiscord<auxym> yes, and be careful about other bugs like use after free, etc
12:49:47FromDiscord<aMOPel> but in cpp you didn't always have to free manually when using & right?
12:49:51FromDiscord<auxym> if it's a stack allocated variable, then as soon as you return from that fuction, the pointer will be invalid
12:49:56FromDiscord<exelotl> Where you'd use `&` in cppcfor a parameter you can use a var param in Nim
12:50:04FromDiscord<exelotl> (edit) "cppcfor" => "cpp for"
12:50:42FromDiscord<auxym> In reply to @aMOPel "but in cpp you": indeed, if it's on the stack. stack is popped when function returns.
12:50:48FromDiscord<exelotl> ref objects in Nim are more like smart pointers or something? (Idk modern C++ so I might be wrong)
12:51:26FromDiscord<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:34FromDiscord<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:12FromDiscord<auxym> correct
12:55:28FromDiscord<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:49FromDiscord<aMOPel> especially when the passed objects get bigger
12:56:54FromDiscord<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:12FromDiscord<exelotl> (edit) "is" => "it's"
12:57:36FromDiscord<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:51FromDiscord<aMOPel> for all types? so I never even have to worry about that?^^
12:57:52*arkurious joined #nim
12:57:54FromDiscord<auxym> yes
12:58:10FromDiscord<aMOPel> pretty awesome 😄
12:58:31FromDiscord<dlesnoff> In reply to @auxym "passing is optimised by": Is that the treshold ? I have always wondered about it
12:58:39FromDiscord<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:01FromDiscord<exelotl> You can use the {.bycopy.} and {.byref.} pragmas to override this behavior if desired
12:59:03FromDiscord<auxym> In reply to @Rika "3 * sizeof float": but then I'd have to multiply numbers in my head before replying 😦
12:59:20FromDiscord<Rika> i dont remember if it was float size or int size though
12:59:29FromDiscord<Rika> probably int size for the threshold
12:59:44FromDiscord<dlesnoff> Aren't they both 64 bits on a 64 bit arch ?
12:59:51FromDiscord<auxym> yes, but not on 32 bit
13:00:22FromDiscord<auxym> for some reason I remember sizeof(float), but 🤷
13:00:52FromDiscord<Rika> the difference matters outside of desktop use ofc
13:01:38FromDiscord<aMOPel> In reply to @auxym "yes, but not on": is float always float64 and int could be either depending on arch?
13:01:59FromDiscord<Rika> yes
13:03:28FromDiscord<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:58FromDiscord<aMOPel> (edit) "matter" => "matter,"
13:04:30*derpydoo quit (Ping timeout: 250 seconds)
13:07:39FromDiscord<auxym> tuple is basically the same as an object/struct. just handled slightly different in type checks
13:09:18FromDiscord<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:35FromDiscord<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:30FromDiscord<aMOPel> Alright. Thank you all for your help 🙂
13:15:34FromDiscord<federico3> is fox0430 around?
13:24:38FromDiscord<untoreh> sent a code paste, see https://play.nim-lang.org/#ix=4dPL
13:25:32FromDiscord<Tanguy> Chronos should support arc & orc
13:27:08FromDiscord<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:15FromDiscord<untoreh> with arc just using `sleepasync` leaks memory, but this stacktraces are from segfaults
13:28:16FromDiscord<Tanguy> The interesting line in your backtrace is "scorperZhttpZstreamserver", the crash is coming from this
13:31:09FromDiscord<untoreh> scorper does seem to do some gcsafe casts, that could be maybe
13:37:54FromDiscord<Rika> what in gods name is that stacktrace
13:39:08FromDiscord<Bung> yeah, there's one place https://github.com/bung87/scorper/blob/ac56dcce0462198babb2aeea05643ecd9c041e6d/src/scorper/http/streamserver.nim#L132↵(@untoreh)
13:39:33FromDiscord<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:45FromDiscord<Rika> ah so its not from nim okay
13:47:48FromDiscord<sOkam!> What should I use for documenting Nim code, in a way that can then be converted into web documentation?↵Any recommendations?
13:53:43FromDiscord<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:06FromDiscord<exelotl> Mainly, enum & object types aren't rendered properly, and cross-references to types in function signatures don't work
13:57:31FromDiscord<exelotl> You're probably best off sticking to the built-in docgen of the Nim compiler
13:58:12FromDiscord<exelotl> Unless you desparately want to break free from the way it groups things, like I did
14:12:35FromDiscord<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:57FromDiscord<sOkam!> What made you want to break free from it, btw? any specifics?
14:27:19FromDiscord<exelotl> sent a long message, see http://ix.io/4dQ7
14:29:16FromDiscord<exelotl> (edit) "https://paste.rs/s2C" => "http://ix.io/4dQ8"
14:31:39FromDiscord<exelotl> I don't think Nim's built-in docgen works with readthedocs
14:32:37FromDiscord<exelotl> Maybe there's a way to make it work
14:55:03FromDiscord<dlesnoff> In reply to @exelotl "The built in doc": I also wish that docs actually did group overloaded functions
14:55:33FromDiscord<dlesnoff> It could number them, and print the text documentation of each overloaded functions
14:56:25FromDiscord<dlesnoff> Thus showing how many overloaded functions there is, and the type changes between these
15:08:08FromDiscord<sOkam!> @exelotl I really like the look of your natu project docs. Really really neat
15:08:51FromDiscord<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:32FromDiscord<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:54FromDiscord<exelotl> I haven't used Sphinx for C but mixing 2 languages in the same project can definitely work
15:25:14FromDiscord<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:42FromDiscord<sOkam!> But just learning the doc infrastructure is what stops me really. Sphynx seems intimidating
15:34:30FromDiscord<exelotl> sent a long message, see http://ix.io/4dQs
15:37:38FromDiscord<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:05FromDiscord<sOkam!> it works for python too? 👀↵well, seems like I will be learning sphynx soon then
15:47:46FromDiscord<sOkam!> hows working with rst compared to md, btw. I'm very very used to md, so hoping its not too different
15:49:10FromDiscord<Tom> Hi! How do I make a new object based on an old one? Like `{...a, b: 5}` in JS, for example.
15:58:30FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4dQy
15:59:00FromDiscord<Phil> Both var to demonstrate that the deepCopy most certainly generates a full copy
15:59:48FromDiscord<Phil> Though something like the spread operator I don't think wehave
16:00:19FromDiscord<Rika> Would have copied even if you didn’t deep copy because nothing in that object has ref semantics
16:01:03FromDiscord<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:50FromDiscord<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:53FromDiscord<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:02FromDiscord<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:14FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dR3
17:45:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dR4
17:46:36FromDiscord<sOkam!> ty, yeah seems like that worked. it compiled 🙂
17:48:21FromDiscord<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:24FromDiscord<leorize> chronos does have something for that iirc
17:51:57FromDiscord<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:06FromDiscord<Zoom> they have `selectors2.nim` and it's the same problem - only sockets and user events for Windows.
17:56:46FromDiscord<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:21FromDiscord<Elegantbeef> You mean wait for a process started to end?
17:57:33FromDiscord<leorize> technically that's what you do on windows too
17:57:53FromDiscord<Elegantbeef> You can use async since the process is not blocking
17:58:15FromDiscord<Elegantbeef> It's not in the stdlib, but it's not overly complicated
18:01:45FromDiscord<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:16FromDiscord<Bung> I think Zoom want some like goroutine
18:02:22FromDiscord<Elegantbeef> Async is just thread sharing, you give up your cpu at designated points `poll` `await` and so forth
18:02:44FromDiscord<Elegantbeef> saying goroutine are green threads?
18:03:21FromDiscord<Require Support> what do i do if there is an ambiguous calls between two nimble packages -.-
18:03:34FromDiscord<Bung> I have no idea
18:03:35FromDiscord<Elegantbeef> You do `myPackage.myProcedure`
18:03:47FromDiscord<Elegantbeef> or `import x except myProcedure`
18:05:19FromDiscord<Require Support> (edit) "calls" => "call"
18:07:19FromDiscord<sOkam!> how do you convert a `char` to `string`? 🧩
18:07:30FromDiscord<Elegantbeef> `$` like 99% of other types
18:07:38FromDiscord<sOkam!> oh, me dummie
18:09:11FromDiscord<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:12FromDiscord<Elegantbeef> https://github.com/pietroppeter/nimibook/blob/main/src/nimibook/builds.nim#L5-L25
18:10:32FromDiscord<Elegantbeef> You're not wrong, it's just not overly complex to do it without threads in Nim
18:13:13FromDiscord<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:19FromDiscord<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:40FromDiscord<Elegantbeef> Dont look at me i use a single core like a good boy
18:15:44FromDiscord<Elegantbeef> I rarely use threading or async
18:17:03FromDiscord<Elegantbeef> I'll say the line for you "Fucking game devs"
18:23:38FromDiscord<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:43FromDiscord<Require Support> but you are always right
18:29:53*derpydoo quit (Ping timeout: 276 seconds)
18:51:08*derpydoo joined #nim
19:30:24FromDiscord<guttural666> how can I default strings in procedure signatures to "" = empty string without using an Option? thanks!
19:30:52FromDiscord<guttural666> empty double quotes seem to be immutable
19:32:40FromDiscord<guttural666> got proc do_stuff(from_dir, to_dir: var string = "") =
19:33:58FromDiscord<huantian> you may just want to use an overload
19:38:06*Guest30 joined #nim
19:38:08Guest30awd
19:40:33*Guest30 quit (Client Quit)
19:40:37FromDiscord<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:40FromDiscord<guttural666> thanks!
19:41:17*wallabra joined #nim
19:41:24FromDiscord<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:27FromDiscord<Phil> sent a long message, see http://ix.io/4dRH
20:14:05FromDiscord<Elegantbeef> the semantics are different in devel and stable
20:14:21FromDiscord<Elegantbeef> So if you're testing with stable of course it'll break
20:15:09FromDiscord<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:45FromDiscord<Elegantbeef> Uhh
20:15:46FromDiscord<Elegantbeef> Odd
20:16:16FromDiscord<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:33FromDiscord<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:47FromDiscord<Require Support> does valgrind work on windows binaries if im looking to find memory leaks?
20:21:19FromDiscord<Phil> Sadly can't say much about that as I don't really use it
20:21:59FromDiscord<Elegantbeef> valgrind + `-d:useMalloc`
20:24:08FromDiscord<Require Support> it works on EXEs?
20:24:22FromDiscord<Require Support> TIL
20:24:27FromDiscord<Elegantbeef> No clue i dont use windows
20:24:45FromDiscord<Require Support> oh ye from what i checked i dont think it does
20:28:58FromDiscord<dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4dRN
20:30:08FromDiscord<Elegantbeef> The above doesnt reimplement discard
20:30:16FromDiscord<Elegantbeef> Discard still runs the right hand
20:31:10FromDiscord<dlesnoff> Oh gosh, how could I overlooked this 😦
20:31:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dRO
20:34:20FromDiscord<dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4dRP
20:35:08FromDiscord<dlesnoff> The macro adds you s times the body's AST while the template adds the for loop and the body AST.
20:49:59FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4dRS
20:50:29FromDiscord<Elegantbeef> Templates substitute code, macros allow introspection
20:51:02FromDiscord<Phil> norm's `withDb` template is a nice example for where templates are useful
20:55:10FromDiscord<Bung> oh beef you re online like 24 hours
20:55:46FromDiscord<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:10FromDiscord<Bung> maybe he take rest when you ask
20:58:59FromDiscord<Phil> Oh wait, wouldn't also a very simple example be generating a dot expression?
20:59:19FromDiscord<Phil> Because if I could've done that via template I would've done so ages ago
21:01:04FromDiscord<Phil> sent a code paste, see https://paste.rs/omY
21:01:17FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4dRY" => "https://play.nim-lang.org/#ix=4dRZ"
21:01:52FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4dRZ" => "https://play.nim-lang.org/#ix=4dS0"
21:01:54FromDiscord<Bung> there is withmacro
21:02:15FromDiscord<Bung> help u write less
21:12:47FromDiscord<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:39FromDiscord<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:04FromDiscord<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:04PMunchJust a set?
21:27:07PMunchOr a bitset
21:27:13FromDiscord<Zoom> There's packedsets
21:27:59FromDiscord<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:02FromDiscord<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:42NimEventerNew thread by inv2004: Double pointer FFI to C, see https://forum.nim-lang.org/t/9541
21:31:42FromDiscord<Elegantbeef> Nah i sleep atleast 10 hours a day↵(@Bung)
21:32:16FromDiscord<Elegantbeef> you dont need to do `obj.value` cause the field is already that↵(@Phil)
21:32:33FromDiscord<Elegantbeef> Whoops
21:32:36FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSc
21:32:53FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSd
21:33:18FromDiscord<Elegantbeef> One day i'll write code that runs
21:33:59FromDiscord<Elegantbeef> There we go
21:34:03FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSf
21:34:22FromDiscord<Elegantbeef> And if you make it an object it'll be `a.fieldName`
21:34:41FromDiscord<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:06FromDiscord<Elegantbeef> You already have Nim bitsets
21:35:07FromDiscord<Elegantbeef> You already have what you want
21:35:23FromDiscord<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:55FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSg
21:36:16FromDiscord<Elegantbeef> See i never will write code that works... missing "]" on line 4
21:36:34FromDiscord<Elegantbeef> Yea phil i dont deal with strings so i dont know
21:37:29FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dSi
21:37:56FromDiscord<sOkam!> also, do you have to do `MyFlags[MyFlag.run]` to access the value? or how do you use it?
21:40:02FromDiscord<Elegantbeef> Wirth had a good idea with firstclass bitsets
21:40:08FromDiscord<Elegantbeef> Sad that no other major language uses them
21:41:51FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dS7
21:42:21FromDiscord<sOkam!> I guess it can be done with templates, but that's how my brain reasons about this type of idea
21:42:27FromDiscord<Elegantbeef> That's pointless though
21:42:37FromDiscord<Elegantbeef> Like what does `bitenum` give you?
21:42:45FromDiscord<sOkam!> how? the goal is to be able to use the bit as a bool
21:42:58FromDiscord<Elegantbeef> So literally a converter will suffice
21:43:06FromDiscord<sOkam!> without having to do `MyFlagGroup[Run]`
21:43:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSa
21:43:54FromDiscord<sOkam!> ah i guess, yeah
21:44:20FromDiscord<sOkam!> can you modify that way, though?
21:44:25FromDiscord<Elegantbeef> But that doesnt make any sense really cause why is run special
21:44:51FromDiscord<sOkam!> because if its part of a state machine, it will need to be changed a lot
21:45:03FromDiscord<Elegantbeef> I dont follow
21:45:23FromDiscord<Elegantbeef> If it's a state machine you likely will use an array or case statement to provide the logic you need
21:45:54FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dSe
21:46:07FromDiscord<Elegantbeef> So then why are you even wanting bitflags?
21:46:39FromDiscord<Elegantbeef> There is `setutils` that allows you to do `mySet[Jump] = true`
21:46:44FromDiscord<Elegantbeef> But i still dont see the point
21:47:14FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSh
21:47:57FromDiscord<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:08FromDiscord<sOkam!> in terms of the human brain, reasoning about it, not the machine
21:48:36FromDiscord<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:30FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dSk
21:49:45FromDiscord<Elegantbeef> I dont see the point of a bitset here if this is a single state you care about
21:49:47FromDiscord<sOkam!> write that with that set syntax, and it becomes really hard to read
21:50:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSl
21:51:00FromDiscord<Elegantbeef> If you only have a single state why you want bitflags is beyond me
21:51:15FromDiscord<sOkam!> excl is not an intuitive word. the point is searching for a way to make it intuitive
21:51:36FromDiscord<Elegantbeef> so then use setutils `myFlags[Running] = false`
21:51:52FromDiscord<sOkam!> the point is to use Running=false 🤦‍♂️
21:52:04FromDiscord<Elegantbeef> Ah yes global variables the best
21:52:07FromDiscord<sOkam!> while still be able to use Running as an index
21:52:08FromDiscord<Elegantbeef> Anyway have fun
21:53:47FromDiscord<sOkam!> why the sarcasm? im just trying to simplify the syntax
21:54:20FromDiscord<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:24arkanoidis I create a converter in a module and I don't export it, will it spread over to other modules?
22:13:11FromDiscord<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:25FromDiscord<Elegantbeef> `$ ord(myEnum)`
22:13:35*fanta1 quit (Quit: fanta1)
22:13:48FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSt
22:13:57FromDiscord<Elegantbeef> No it shouldnt ark, if it does it's due to a bug
22:16:43FromDiscord<Require Support> sent a code paste, see https://play.nim-lang.org/#ix=4dSv
22:16:46FromDiscord<guttural666> worked, thanks very much, now to find out what that does 😄
22:19:10FromDiscord<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:19FromDiscord<Elegantbeef> `ord` returns the ordinal value
22:19:22FromDiscord<Elegantbeef> which is `int`
22:19:53FromDiscord<guttural666> don't seem to need $ for the echo though
22:19:55FromDiscord<guttural666> yeah
22:19:58FromDiscord<guttural666> got it
22:20:06FromDiscord<Elegantbeef> Correct echo implicitly calls `$`
22:20:17FromDiscord<guttural666> ah, very interesting
22:20:22FromDiscord<guttural666> thanks!
22:20:39FromDiscord<guttural666> damn, Nim is so much fun
22:20:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSw
22:21:11FromDiscord<Elegantbeef> So in this case all calls to `echo` calls `$`
22:22:08FromDiscord<Elegantbeef> Yes↵(@Require Support)
22:22:09arkanoidnot 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:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSx
22:27:06FromDiscord<Elegantbeef> You likely are recursively calling the converter causing the compiler to lock up
22:27:40FromDiscord<Elegantbeef> Well i guess that's wrong cause this causes the compiler to stack overflow
22:28:40FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dSy
22:28:53FromDiscord<Elegantbeef> Nope
22:29:41FromDiscord<Bung> so problem here is it convert to closure
22:29:44FromDiscord<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:04arkanoidThanks!
22:30:10FromDiscord<Bung> as I notice the the code gen has env fields
22:30:47FromDiscord<Elegantbeef> Yea Bung the issue there is that `: ProcType = proc() = discard` doesnt properly raise it to a closure
22:32:37FromDiscord<Bung> wait , raise it to a closure ?
22:32:45FromDiscord<Elegantbeef> Sorry i didnt test the code
22:32:51FromDiscord<Bung> should be closure and not
22:34:26FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSB
22:34:29FromDiscord<Elegantbeef> Or NimNil if that exists
22:34:52FromDiscord<Elegantbeef> The constant closure doesnt generate an environment so it's incorrect to attempt to assign it to an environment
22:35:06FromDiscord<Elegantbeef> Alternatively you need to emit a the proper type for a closure procedure
22:36:43FromDiscord<Bung> it's like the compiler think it is closure, but not assign fields propertly?
22:38:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSE
22:38:52FromDiscord<Elegantbeef> It's attempting to copy the procedure to the address of `a`, but the two types are different
22:39:47FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSF
22:40:07FromDiscord<Elegantbeef> `colonanonymous_test_4` if unclear is just a procedure, whereas `atest_6` is a closure procedure(a struct in C)
22:40:52FromDiscord<Elegantbeef> So there needs to be special handling to set the environment to nil and the procedure to the pointer
22:41:20FromDiscord<Elegantbeef> Hopefully this makes sense
22:41:34FromDiscord<Bung> so `let arr: array[1, ProcType] = [something]` left is what , right is what
22:41:56FromDiscord<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:23FromDiscord<Elegantbeef> Left is an array of closures, right is an array of closures
22:42:34FromDiscord<Bung> right is `colonanonymous_test_4` left is `atest_6` ?
22:42:54FromDiscord<Elegantbeef> I used a smaller example sorry
22:42:55FromDiscord<Elegantbeef> And in that case you are correct
22:42:59FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSI
22:43:08FromDiscord<Elegantbeef> But it's the same problem the generated C needs to be specialised for constant closures
22:44:59FromDiscord<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:03FromDiscord<Bung> um, I didn't thought left will generate like that as it's new to compiler
22:45:43FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/search?q=ClE_0 might help you find the issue area
22:46:32FromDiscord<Bung> I thought it will generate same struct as runtime closure
22:46:44FromDiscord<Elegantbeef> I'm not testing on devel, so it might
22:46:56FromDiscord<Elegantbeef> It seems to only emit a procedure and no struct
22:47:21FromDiscord<Elegantbeef> Which makes sense as that's all required
22:48:00FromDiscord<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:24FromDiscord<Elegantbeef> I avoid the gen side of the compiler since it's just hell on earth 😛
22:48:55FromDiscord<Elegantbeef> Worth noting the generated code here is different depending on RCs vs Refc
22:49:39FromDiscord<Elegantbeef> Hmm this is like;y the real culprit https://github.com/nim-lang/Nim/blob/2f441ac6754e76f936900f4f4641587a82967f71/compiler/ccgexprs.nim#L355-L360
22:51:21FromDiscord<Bung> https://github.com/nim-lang/Nim/pull/20616 araq's one make me more confusing
22:51:32arkanoidI 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:36FromDiscord<Elegantbeef> What confuses you?
22:51:51FromDiscord<Elegantbeef> Just make the object a generic↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
22:51:56FromDiscord<Bung> `result.kind == nkTupleConstr and result[1].kind != nkNilLit:`
22:52:24FromDiscord<Elegantbeef> The compiler converts closures to `(procName, environment)`
22:52:48FromDiscord<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:00FromDiscord<Elegantbeef> Eventually i'll stop replying to IRC users again
22:53:05FromDiscord<Elegantbeef> Sorry discord/irc users 😄
22:53:24FromDiscord<Bung> ah, I understand now
22:54:47FromDiscord<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:31FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSP
22:56:09FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dSQ
22:56:12FromDiscord<Bung> oh yes, araq's one works
22:56:29FromDiscord<Elegantbeef> Wait it makes CGen not an issue?
22:57:01FromDiscord<Elegantbeef> Cgen should still be an issue
22:57:11FromDiscord<Bung> no, I just verify this test case https://github.com/nim-lang/Nim/pull/20597/files
22:58:41FromDiscord<Bung> yes, array constuct same error , as it has no env , will pass here
22:59:00FromDiscord<Elegantbeef> Yep it's just rewriting the C/Js gen to support this
22:59:42arkanoidis it possible to cast a ref object type to a non-ref object type with same fields in same order?
22:59:57FromDiscord<Elegantbeef> `myRef[]`
23:01:14FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dSU
23:14:23*jmdaemon joined #nim
23:19:18arkanoidwell, thanks, but apparently is not sufficient for what I am trying to do
23:20:13arkanoidnimpy 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:48FromDiscord<Bung> cgen part is complicated..
23:53:12*wallabra quit (Ping timeout: 250 seconds)
23:53:31FromDiscord<Bung> I think I can modify the assignment instead of generate same struct
23:53:43FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dSX
23:55:09*wallabra joined #nim
23:55:15NimEventerNew thread by bpr: Newbie first impressions, see https://forum.nim-lang.org/t/9542