<< 25-05-2023 >>

00:07:46FromDiscord<Elegantbeef> People deleting messages making me look crazy
00:23:45*azimut joined #nim
00:48:32FromDiscord<Arathanis> I was trying to figure out who you were responding to
00:48:57FromDiscord<Arathanis> In reply to @jmgomez "constructors decls almost there:": can you export nim types like this? what does that look like to C?
00:49:41FromDiscord<Elegantbeef> well `constructor` doesnt have C equivlent
00:50:02FromDiscord<Elegantbeef> `exportC` when compiling Nim just emits the struct with a name
00:50:11FromDiscord<Elegantbeef> That isnt mangled
00:52:00FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4wDZ
00:52:11FromDiscord<Elegantbeef> `NI z` but yea
00:52:33FromDiscord<Arathanis> if i had done `z: cint` would I have been correct?
00:52:46FromDiscord<Elegantbeef> Yes
00:52:49FromDiscord<Arathanis> thnx
00:53:16FromDiscord<Arathanis> are there similar mechanisms for exporting C++ classes?
00:53:23FromDiscord<Arathanis> i imagine that is a taller order.
00:53:26FromDiscord<Arathanis> especially methods.
00:53:43FromDiscord<Elegantbeef> That's what juan is working on partially
01:28:00madpropswhat am i doing wrong here ..
01:28:01madprops nre.match(line, re"strip").isSome
01:28:07madpropsjust want to check if regex matches
01:28:14madprops"strip"
01:28:26madpropsit's always false
01:28:54madpropshowever, re"\w" does match stuff
01:29:27madpropsguess it's a regex issue
01:30:35madpropshave to do this: re".*strip.*"
01:30:38madpropsnot sure why
01:30:44madpropsguess it's assuming beg and end
01:31:42madpropsok nre.find is better
01:32:09FromDiscord<Elegantbeef> Please tell me the actual usage is more than just "does my string contain strip" 😄
01:32:34madpropsthe regex can be anything
01:32:48madpropsim just testing
01:49:07*derpydoo quit (Read error: Connection reset by peer)
01:49:39madpropsweird.. it's finding \w and \d but not \n
01:50:04madpropsunless I escapeRe .. but if i do that, \w and \d don't work
01:50:53madpropsoh nvm escaping is turning it into a literal
01:50:55madprops\n string
01:51:38madpropsoh
01:51:57madpropsof course, it's processing one line at a time
02:12:44FromDiscord<Arathanis> just need to use the multiline flag?
02:45:40*derpydoo joined #nim
03:09:22madpropsarathanis not really ...
03:09:30madpropsthis program split into lines
03:09:33madpropsthen checks each one
03:09:42madpropsi'd have to change how it works
03:16:49FromDiscord<Prestige> Can I populate a table at compile time (static block?) that would be available at runtime to read from?
03:17:05FromDiscord<Elegantbeef> Yes
03:18:39FromDiscord<Prestige> I'll need to try making a minrepro of this later, getting a compiler error
03:20:24FromDiscord<Prestige> but basically I'm trying `var myTable {.compileTime.} = initTable[string, string]()`, populating it in a static block, then accessing values at runtime gives me a compiler error `getAddr: 3`
03:20:35FromDiscord<Prestige> I'll probably make a min repro in a few hours
03:23:23FromDiscord<Elegantbeef> You might need to make a `var myTable = static: myConstTable`
03:23:50FromDiscord<Elegantbeef> But `myTable[bleh]` where `myTable` is const should be fine
03:24:10FromDiscord<Prestige> wow that worked
03:24:14FromDiscord<Prestige> Idk why that is, but it worked
03:27:24*rockcavera quit (Remote host closed the connection)
03:49:23*krux02_ quit (Remote host closed the connection)
04:29:19*lucasta quit (Quit: Leaving)
05:09:31FromDiscord<Graveflo> I've read some conflicting information about how much heap space is pre-allocated for seqs. Is there a way to manually specify or hint what size you want to initially allocate without it necessarily being dependent on the initial len?
05:15:29FromDiscord<amadan> sent a code paste, see https://play.nim-lang.org/#ix=4wEA
05:16:21FromDiscord<Rika> Note that you cannot influence the resize factor though
05:16:25FromDiscord<Graveflo> Oh maybe I misread what the point of that is. I was under the impression that the data type would disallow the seq growing beyond the cap. If true, that would not work out unless I could cast to seq to break that rule
05:16:54FromDiscord<Rika> In reply to @Graveflo "Oh maybe I misread": No the cap procedure returns a regular sequence
05:17:17FromDiscord<Elegantbeef> capacity is just the amount of owned memory
05:17:30FromDiscord<Graveflo> oh ok. Thanks guys
05:17:36FromDiscord<Elegantbeef> It's not a fixed length
05:39:52*advesperacit joined #nim
06:54:50FromDiscord<ringabout> \
06:59:57*PMunch joined #nim
07:18:53FromDiscord<mratsim> In reply to @apropos "hmm that sounds fancy.": the programmer decides if it's safe or not, if you try to use a parallelFor loop to do `result = a[i]` you have undefined behavior and your result is just garbage.
07:19:31FromDiscord<mratsim> if you do `a[i] += b[i]` there is no data race since each threads is guaranteed to access different memory locations.
07:20:16FromDiscord<ieltan> Hello, anyone knows how to deal with predictable hashtable collisions ?
07:20:24FromDiscord<Arathanis> is it possible to make your own conversion proc in the same way the other typedesc work? like `10.uint` but for a custom type?
07:21:38FromDiscord<JJ> In reply to @mratsim "the programmer decides if": hmm i don't really understand that
07:22:21*Notxor joined #nim
07:23:05FromDiscord<mratsim> sent a code paste, see https://play.nim-lang.org/#ix=4wEL
07:24:06FromDiscord<mratsim> a naive parallel for will attribute to p threads the range [0, N/p) and [N/p, 2N/p) and [2N/pm 3N/p) ....
07:24:27FromDiscord<mratsim> there is no overlap in the data range accessed and written to by each thread
07:24:30FromDiscord<mratsim> so no data race
07:24:44FromDiscord<mratsim> so multiple threads can access the data without any synchronization
07:24:52FromDiscord<mratsim> so this is safe
07:25:44FromDiscord<JJ> i see. is that safe parallel for constructed automatically by the compiler or do you have to break it up yourself? also if you do something invalid like the example above, can the compiler detect and fail to compile / warn you about it?
07:26:12FromDiscord<mratsim> In reply to @apropos "i see. is that": There is the `parallel` statement that does this but it's being deprecated.
07:27:06FromDiscord<mratsim> see: https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn-parallel-statement
07:28:52FromDiscord<JJ> oh interesting. why is it being deprecated, did it not scale?
07:29:03PMunchieltan, yes but you have to be a bit more specific
07:29:42PMunchArathanis, sure, just make a proc which takes one type and return another. All procs can be called like that due to the UFCS
07:30:10FromDiscord<Arathanis> In reply to @PMunch "<@136570191038513152>, sure, just make": but the proc will need a different identifier than the type, huh?
07:30:18FromDiscord<Arathanis> `toMyType` kind of thing?
07:32:28PMunchOh right, that is correct. But you have the built in converter though: https://play.nim-lang.org/#ix=4wEM
07:32:51FromDiscord<Arathanis> ah ok, if I alias or use distinct i can use it just like its original type
07:38:26*derpydoo quit (Ping timeout: 246 seconds)
08:15:37FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4wEU
08:28:25FromDiscord<Rika> `set[1..640]`?
08:33:28FromDiscord<sOkam!> oh didn't know thats a thing. ty
08:36:50FromDiscord<sOkam!> also, probably should use an `IntSet` i imagine
08:39:13FromDiscord<Rika> yeah thats an 80 byte large set
08:46:17FromDiscord<sOkam!> would it be better to use `PackedSet[1..640]`, considering I don't need numbers over that?↵Seems like `IntSet` doesnt take parameters, and its basically a `PackedSet[int]`, but maybe im missing something
08:46:30FromDiscord<sOkam!> (edit)
08:53:22FromDiscord<jmgomez> In reply to @Arathanis "are there similar mechanisms": there is `virtual` now in devel https://nim-lang.github.io/Nim/manual_experimental.html#virtual-pragma which does exactly that plus mark the method as virtual. Although the work on `constructor` and `virtual` is aiming towards better interop than anything else
09:06:02*derpydoo joined #nim
11:10:59*derpydoo quit (Quit: derpydoo)
11:13:51PMunchCrap.. I think I got a bit nerd-sniped with fuzzy searching.. https://forum.nim-lang.org/t/10221
11:47:11*myrix joined #nim
12:11:43FromDiscord<JeanCareau> sent a long message, see http://ix.io/4wFK
12:12:41FromDiscord<JeanCareau> sent a long message, see http://ix.io/4wFM
12:13:21FromDiscord<JeanCareau> @michaelb.eth Now everything works.
12:20:47FromDiscord<JeanCareau> on the front page of nim-lang.org There are code examples. What is the color scheme called?
12:21:35FromDiscord<JeanCareau> I like the color scheme.
12:37:12FromDiscord<Ras> In reply to @JeanCareau "on the front page": https://nim-lang.org/assets/css/highlight/dracula.css
12:37:31PMunchJeanCareau, it's Dracula
12:37:32FromDiscord<Ras> link to the colour scheme in the comment at the top of the file
12:37:39PMunchAnd it is indeed a neat little theme
12:38:06FromDiscord<JeanCareau> @Ras Ah, thanks
12:38:15PMunchI'm not sure if it's stock Dracula though
12:38:42PMunchI seem to remember when colouring slides for some presentations that they didn't quite match up
12:39:33FromDiscord<Ras> in any case, the css file contains the exact values, but matching them back to the original colour definitions might be... tedious
12:42:38FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4wFV
12:45:36FromDiscord<ieltan> So, I know i'm probably misusing Tables like this but is there really no other way to know im deleting the right key ?
12:47:58FromDiscord<ieltan> What I could do is to wait until all values are inactive and then bulk delete them
12:48:19FromDiscord<ieltan> I think this may be a solution :think:
12:48:24FromDiscord<ieltan> (edit) ":think:" => "🤔"
13:02:21*rockcavera joined #nim
13:22:26*progranner joined #nim
13:27:22*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
13:27:42*progranner joined #nim
13:31:15*progranner quit (Client Quit)
13:33:50*progranner joined #nim
13:36:26*progranner quit (Client Quit)
13:37:52*Notxor quit (Quit: Leaving)
13:38:20*rockcavera quit (Remote host closed the connection)
13:39:31FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4wGf
13:39:57*rockcavera joined #nim
14:11:31*progranner joined #nim
14:11:52FromDiscord<Rika> https://nim-lang.org/docs/typeinfo.html#base%2CAny
14:12:13FromDiscord<Rika> i think?
14:12:14FromDiscord<Rika> not sure
14:12:36*progranner quit (Client Quit)
14:13:32FromDiscord<Ayy Lmao> Ah that looks like it. I figured out a way to not need it anyway but it's good to know.
14:13:47FromDiscord<Rika> it looks like it but it doesnt seem right
14:15:04FromDiscord<jmgomez> if it doesnt you could always use `getImpl` from the sym
14:21:34*progranner joined #nim
14:29:48*PMunch quit (Quit: Leaving)
14:37:27*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
14:40:29*progranner joined #nim
14:48:57*Notxor joined #nim
14:49:24FromDiscord<mratsim> In reply to @apropos "oh interesting. why is": because the road to provides good parallel support is much longer so rather than having a half-baked situation in the stdlib/compiler that kind of stifles innovation (mmmh this is somewhat in Nim, shhould I really create a package providing this?), you delegate that to 3rd parties
15:13:20*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:16:17*progranner joined #nim
15:34:42NimEventerNew thread by alexeypetrushin: Install Nimble package from specific branch and subdri?, see https://forum.nim-lang.org/t/10222
16:36:24FromDiscord<sOkam!> Whats different between `tuple[one: Type1, two: Type2, three: Type3]` and an object with those same fields?↵Any reasons to use tuple over the object in some circumstance?
16:37:03FromDiscord<jmgomez> structural vs nominal typing
16:37:54FromDiscord<sOkam!> what does that mean?
16:40:22FromDiscord<Elegantbeef> All tuples do not introduce a new distinct type
16:41:10FromDiscord<sOkam!> ah so they are technically just separate values, i assume?
16:41:13FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wGX
16:41:37FromDiscord<Elegantbeef> Tuples are typed by shape, if the data is the same shape it's the same type
16:41:47FromDiscord<sOkam!> oh
16:41:51FromDiscord<Elegantbeef> Using named tuples is a faux pas
16:42:07FromDiscord<sOkam!> yeah i can see why so
16:43:04FromDiscord<jmgomez> Sup beef, do you recall if there is a way to know get the symbol of a proc that from a macro that is called in that proc? I bet there isnt, asking to confirm
16:43:14FromDiscord<jmgomez> (edit) "know get" => "know/get"
16:43:30FromDiscord<jmgomez> (edit) "that" => ""
16:43:48FromDiscord<Elegantbeef> Nope unless you pass a parameter/variable declared inside the proc and use `owner`
16:44:21FromDiscord<Elegantbeef> That's the hack i generally do
16:44:22FromDiscord<Elegantbeef> Emit a macro that declares a variable that then passes that variable name to a macro
16:45:22FromDiscord<jmgomez> I was wondering if it can be made as a plugin, similar to locals. Wanted to look into it to then have a "super" macro to call on the parent for virtual/constructors
16:46:15FromDiscord<JJ> In reply to @mratsim "because the road to": makes sense. it seems like a very hard problem to solve
16:56:29*lucasta joined #nim
16:58:14FromDiscord<chmod222> If I have a `type Something = ptr object` and another `type SomeRef[T] = object ptr T`, will creating `Ref[Something] result in a `ptr ptr\`?
17:00:58FromDiscord<Elegantbeef> `object ptr T`?
17:01:39FromDiscord<chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4wH2
17:01:40FromDiscord<chmod222> Maybe more correct
17:01:50FromDiscord<Elegantbeef> Of course it'd be ptr ptr
17:02:07FromDiscord<chmod222> Makes sense, doesn't it?
17:02:22FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/2MDgT
17:02:45FromDiscord<chmod222> Alrighty, looks good to me
17:02:46FromDiscord<chmod222> Thanks!
17:09:27*jmdaemon joined #nim
17:29:17*arkurious joined #nim
17:48:01*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:58:05*progranner joined #nim
18:06:22*Notxor quit (Remote host closed the connection)
18:17:20*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
18:28:10*lucasta quit (Quit: Leaving)
18:31:42*arkurious quit (Quit: Leaving)
18:32:02NimEventerNew thread by elcritch: Platonic: core math concepts, see https://forum.nim-lang.org/t/10223
18:39:50*progranner joined #nim
18:45:27FromDiscord<sOkam!> @chmod222 how are the bindings going
18:53:40*Notxor joined #nim
19:00:53FromDiscord<chmod222> I'm fighting with curious segfaults in precisely the one area I need
19:01:11FromDiscord<chmod222> Battling the module system every other day
19:02:22FromDiscord<chmod222> The GDExtension documentation is not very helpful in the first issue because there is no GDExtension documentation
19:04:08FromDiscord<chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4wHr
19:05:00FromDiscord<chmod222> Especially for the cases of using `Ref[U]` where `Ref[T]` is expected, when `U = object of T`
19:07:09FromDiscord<Elegantbeef> There isnt really a way to get that converter to work, what's the mismatch look like?
19:07:42FromDiscord<guttural666> any idea, why this case statement complains that the argument is not known at compile time? https://media.discordapp.net/attachments/371759389889003532/1111370020040232990/image.png
19:08:00FromDiscord<Elegantbeef> case statements only can use static values
19:08:27FromDiscord<Elegantbeef> `parseEnum[TokenKind](lex.str)`
19:08:36FromDiscord<Elegantbeef> Or create your own non exceptionful version
19:08:55FromDiscord<guttural666> aren't those strings static?
19:09:01FromDiscord<chmod222> The precise mismatch is that I have a wrapped `DirAccess`, which is a Godot object that derives from `RefCounted`, which derives from `Object`, so I have on my side a `Ref[DirAccess]` type that I want to call with, in this case, a method like `proc get_reference_count(self: Ref[RefCounted])` because the method `get_reference_count` is defined on the `RefCounted` type
19:09:10FromDiscord<Elegantbeef> They are but `token_kind` isnt
19:09:12FromDiscord<chmod222> But this happens all over, because inheritance
19:09:24FromDiscord<Elegantbeef> `$token_kind` is a for loop variable that is not static
19:09:30FromDiscord<Elegantbeef> If we had a general unroll you could use that
19:09:38FromDiscord<chmod222> my mapped `DirAccess` of course derives from my mapped `RefCounted`, but that is lost with `Ref[]`
19:10:08FromDiscord<Elegantbeef> `proc getReferenceCount[T](r: Ref[T])` doesnt work?
19:10:10FromDiscord<guttural666> In reply to @Elegantbeef "`$token_kind` is a for": hm okay, but in theory the compiler could see that the string representations are in fact static, right?
19:10:22FromDiscord<Elegantbeef> Nope
19:10:24FromDiscord<Elegantbeef> that for loop runs at runtime
19:10:44FromDiscord<guttural666> In reply to @Elegantbeef "that for loop runs": okay, so an if statement it is
19:10:45FromDiscord<mratsim> sent a long message, see https://paste.rs/QBmP4
19:10:46FromDiscord<Elegantbeef> You're attempting to raise a runtime value to a static value
19:10:47FromDiscord<chmod222> It will probably work, but then I have to make every single method generic and that sounds like inviting trouble \:)
19:11:05FromDiscord<chmod222> But if that is the only way, I'll probably need that
19:11:06FromDiscord<Elegantbeef> It's not
19:11:20FromDiscord<Elegantbeef> It's the proper solution imo
19:12:33FromDiscord<chmod222> This causes a semantic issue of not forbidding, at compile time at least, calling `proc pet_cat(Ref[Cat])` with my `Ref[MainBattleTankLeopard2A4]`
19:12:34FromDiscord<Elegantbeef> You also could have a `type RefBase = object of RootObj` and implement `getRefCount` for that
19:12:57FromDiscord<Elegantbeef> It would forbid that
19:13:21FromDiscord<Elegantbeef> `pet_cat` would be `cat: Ref[Cat]`
19:13:23FromDiscord<Elegantbeef> you're defining a general procedure that all `Ref` share
19:13:45FromDiscord<chmod222> But with that solution I'd have to make everything a `Ref[T]`
19:13:54FromDiscord<Elegantbeef> Only the procedures that are general
19:14:17FromDiscord<Elegantbeef> `getRefCount` is a general procedure that all `Ref` should have
19:14:29FromDiscord<Elegantbeef> I might not understand godot's system if each type has it's own special `getRefCount`
19:14:37FromDiscord<chmod222> Godot suffers heavily from inheritance, so everything derives from something or other
19:14:52FromDiscord<chmod222> I think 600 of the \~900 classes are `RefCounted` descendants
19:14:56FromDiscord<Elegantbeef> Sure but Nim implicitly upcasts to inherited types on dispatch
19:15:03FromDiscord<chmod222> The others are `Object` descendants, which `RefCounted` also is
19:15:29FromDiscord<Elegantbeef> SO if you have `RefCount -> Node -> Sprite -> MyCustomSprite` and call `getRefCount(myCustomSprite)` it'll grab the base type's proc and dispatch
19:15:50FromDiscord<Elegantbeef> General operations can be implemented on the base type
19:15:55FromDiscord<Elegantbeef> Just as you do in other OOP languages
19:16:14FromDiscord<chmod222> I know, but that's just the problem here
19:16:52FromDiscord<chmod222> It all works right now with the naked types where I have `MyCustomSprite = object of Sprite` and `Sprite = object of Node`, but this chain is lost once wrapped inside `Ref`
19:17:05FromDiscord<chmod222> `Ref[MyCustomSprite]` no longer casts to `Ref[Sprite]`
19:17:53FromDiscord<chmod222> So following the logic, I'd have to make every single proc that is defined in a class that has children take a receiver of `Ref[T]` and not `Ref[Baseclass]` because otherwise the children could never call it
19:21:14FromDiscord<chmod222> Make it proper implementation detail
19:21:32FromDiscord<chmod222> Or using the power of my already present code generation, just generate explicit converters for specific Ref[] types of all parent types
19:21:35FromDiscord<Elegantbeef> Probably best to have the ref inside the object
19:21:41FromDiscord<Elegantbeef> Using converters is always meh
19:21:56FromDiscord<chmod222> I'd love to just handle the memory myself and use proper `ref` types, but godot is a diva
19:22:29FromDiscord<guttural666> @ElegantBeef what would be the solution for my problem then, something like this? https://media.discordapp.net/attachments/371759389889003532/1111373741478379580/image.png
19:23:03FromDiscord<Elegantbeef> `parseEnum`
19:23:06FromDiscord<Elegantbeef> Like i said
19:24:48FromDiscord<guttural666> In reply to @Elegantbeef "`parseEnum`": sorry, didn't see that, gonna take a look at that thanks!
19:34:57FromDiscord<guttural666> still excludes a for loop
19:35:48FromDiscord<guttural666> maybe a map between Token enums and a string representation?
19:51:59FromDiscord<jmgomez> @ElegantBeef do you know if you can convert a `PNode` to a `NimNode` somehow inside the compiler?
20:01:21*jmdaemon quit (Ping timeout: 268 seconds)
20:04:15FromDiscord<Elegantbeef> @jmgomez A PNode is a NimNode, no?
20:07:47FromDiscord<jmgomez> In reply to @Elegantbeef "<@726017160115126333> A PNode is": dunno, I thought the VM used some kind of mechanism to do the conversions
20:08:15FromDiscord<Sh1be> it feels like im new to programming again when i learn nim 😭
20:10:31FromDiscord<JJ> that's good! it means you're learning new concepts (unless it is not good and a problem with the documentation)
20:11:18FromDiscord<Elegantbeef> Yea IIRC you said you knew TS and C#
20:11:27FromDiscord<Elegantbeef> Nim is different to both those as it's a procedural language
20:11:30FromDiscord<juan_carlos> In reply to @jmgomez "<@145405730571288577> do you know": Would that bypass optimization, semchecking, etc etc of the compiler(?).
20:12:07FromDiscord<Elegantbeef> I realise now you mean a VM PNode to a compiler NimNode
20:15:02FromDiscord<Sh1be> In reply to @apropos "that's good! it means": im so used to writing C# and TS so I can do it without thinking and now im learning this new syntax, feels super weird
20:15:35FromDiscord<Elegantbeef> I came to Nim from C# and it was a bit odd at first, but it's not much nicer
20:15:36FromDiscord<Elegantbeef> now much\
20:16:48FromDiscord<JJ> oh yea you'll get the hang of it though. most people have some python under their belt before coming to nim i think
20:17:17FromDiscord<chmod222> I still have a love-hate relationship with Nim, for some reason I regularly hit the limits of the module system and it feels like it wants me to have a 30924 line main.nim
20:18:16FromDiscord<chmod222> Or maybe it's just this particular project that does that, because I have to work with a system that was not designed with nim in mind of course
20:20:37FromDiscord<chmod222> The good thing is that so far I have always found a way around some issue
20:20:55FromDiscord<Elegantbeef> It's a bit annoying with game dev, but I've also come to the conclusion that if think of modules as interfaces life is better 😄
20:22:29FromDiscord<chmod222> I have coped by separating all the type defs and really self contained declarations in classes/types/typename.nim for every type and all the procs (godot's class methods) in separate modules under classes/typename.nim, so every class's method can have dependencies on every other class type without it become too cyclic
20:23:14FromDiscord<chmod222> The worst is the requirement for `=destruct` and such to be within the same module as the type declaration, because some `=destruct` may need the methods and then everything falls apart
20:23:52FromDiscord<chmod222> But where there's a turing complete macro system capable of statically executing system programs and ordering a pizza via curl, there's a way
20:24:22FromDiscord<Elegantbeef> Right, I'd argue that most places that cyclic modules are required due to bad design, but I still am looking at my game logic and going "Yea cyclic imports would make this a tinge less awkward"
20:24:55FromDiscord<chmod222> `get_reference_count = 1`, sexiest sequence of chars I have read in 3 days
20:25:12FromDiscord<chmod222> It seems I finally figured something out
20:27:20FromDiscord<Nerve> In reply to @Sh1be "im so used to": You just need to use more languages. Once you've tried everything from Lisp to Ocaml to Smalltalk to Haskell to Prolog, syntax will become less of a something-I-have-to-learn pain point for you and more of a tool which enables certain types of abstractions and systems modeling.
20:27:44FromDiscord<Sh1be> In reply to @Nerve "You just need to": yeah that sounds reasonable
20:41:24*advesperacit quit ()
20:44:31*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
20:45:29FromDiscord<Ayy Lmao> Are cyclic imports ever on the roadmap for Nim? I remember reading somewhere that it's not possible with a programming language that has the metaprogramming capabilities of Nim but I don't remember where I read that.
20:45:58FromDiscord<chmod222> They are somewhat possible if you order your things correctly
20:46:27FromDiscord<Elegantbeef> They're planned eventually, we do have delayed imports
20:47:25FromDiscord<Ayy Lmao> That's nice at least. Having recently experimented with languages with cyclic imports I really wish I could do it in Nim.
20:47:49FromDiscord<Ayy Lmao> And what are delayed imports?
20:47:56FromDiscord<chmod222> Zig is really the gold standard in terms of that
20:48:06FromDiscord<chmod222> Top level lazyness is very convenient
20:48:11FromDiscord<Elegantbeef> Eh Zig's laziness is also a curse
20:48:28FromDiscord<Elegantbeef> Invalid code compiles until used like a generic that's not generic
20:48:29FromDiscord<chmod222> That too
20:48:52FromDiscord<chmod222> Or you may have 3049 errors in your code but don't know unless you force something to be evaluated
20:49:19FromDiscord<Elegantbeef> That's a delayed import
20:49:26FromDiscord<Ayy Lmao> In reply to @chmod222 "Or you may have": Isn't that the case with generics in Nim?
20:49:30FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/kVdap
20:49:35FromDiscord<Elegantbeef> Not really
20:49:49FromDiscord<Elegantbeef> Even Nim's generics do some sanity checks
20:50:39FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4wHV
20:51:20FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wHW
20:51:26FromDiscord<Ayy Lmao> I was messing around with Odin recently and everything inside a folder is aware of everything in that folder, which was nice but at the same time bad.
20:51:45FromDiscord<Ayy Lmao> Makes doing conditional compilation a pain.
20:52:10FromDiscord<Elegantbeef> In a generic of course that can error
20:52:41FromDiscord<Elegantbeef> But inside `proc doThing() = discard "bleh" + 10` it doesnt error
20:53:05FromDiscord<Elegantbeef> So suffice to say Zig's laziness can be nice for compile times, but it's awful for static typing
20:53:32FromDiscord<Elegantbeef> Even marking it `pub` doesnt make it semantically check the procedure
20:54:07FromDiscord<Elegantbeef> Odin is inspired by oberon which did some interesting/weird things
20:54:55FromDiscord<Ayy Lmao> I'm too addicted to the way Nim does universal function call syntax to use anything else I think.
20:55:09FromDiscord<chmod222> I really, really mostly wish Zig would drop the whole "unused is an error" bullshit
20:55:25FromDiscord<chmod222> It could be such a great language
20:55:29FromDiscord<Elegantbeef> Yea once you use UFCS it's missing from every other place
20:55:47FromDiscord<JJ> In reply to @Ayy Lmao "I'm too addicted to": yeah. rust does it a smidgen but far far from enough
20:56:32FromDiscord<Ayy Lmao> Beef your suggestions about using generics and mixins is working well so far. Thanks for that. It opened up a lot of possibilities for me.
20:56:40FromDiscord<Elegantbeef> Cheers
20:56:50FromDiscord<Elegantbeef> Did you go down the tuple route?
20:56:58FromDiscord<JJ> In reply to @Ayy Lmao "That's nice at least.": also yeah, no cyclical imports or types is rough. probably in my top five issues
20:57:16FromDiscord<JJ> (edit) "types" => "type declaration lookahead"
20:57:52FromDiscord<Elegantbeef> Like I said tuples really are magical features of code, even though i dislike how most use them
20:57:52FromDiscord<Elegantbeef> JJ I really think that in many cases generics trump cyclical imports, but I'm also a bit mad
20:58:16FromDiscord<Elegantbeef> Been toying with using Generics + inheritance to add functionality for GUI objects and aside from a compiler bug I fixed, it's working well
20:58:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wHZ
20:58:48FromDiscord<Ayy Lmao> In reply to @Elegantbeef "Did you go down": I had to deviate a bit because I still don't really know what I'm doing.
20:59:01FromDiscord<Ayy Lmao> And my example yesterday was very stripped down and there are some other considerations.
20:59:09FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wI1
20:59:37FromDiscord<Elegantbeef> This lets me inject my own fields for `Button`s both from `Element` and the ones declared there
20:59:47FromDiscord<Elegantbeef> It gives you a bit of multiple inheritance
21:00:35FromDiscord<Elegantbeef> Using this methodology I have the entire backend logic for my GUI in a library that has no idea what a `Vec3` or render backend is
21:01:09FromDiscord<Elegantbeef> So I can basically re-implement my entire GUI for any platform I want, be it TUI, opengl, sdl2, wgpu(sokam is interested)
21:02:57FromDiscord<Elegantbeef> I think replacing cyclical imports using generics is a bit odd initially, but it makes code more reusable 😄
21:03:08FromDiscord<Elegantbeef> Not that projectiles in my game really need to be reusable
21:03:10FromDiscord<Elegantbeef> But alas!
21:12:04FromDiscord<guttural666> is returning an Option[Token] the canonical way to deal with optionals?
21:12:21FromDiscord<Elegantbeef> That or you introduce a `tokenKind: None`
21:13:46FromDiscord<guttural666> that sounds good
21:15:04FromDiscord<JJ> In reply to @Elegantbeef "JJ I really think": wait, what, how? maybe i have no idea what i'm talking about because by cyclical imports i just mean being able to put my type declarations wherever and have things work
21:15:16FromDiscord<Elegantbeef> Exactly
21:15:27FromDiscord<JJ> that doesn't work with generics?
21:15:29FromDiscord<Elegantbeef> You make a generic type that consumes the type you want to insert
21:15:55FromDiscord<JJ> oh god what the fuck
21:16:08FromDiscord<JJ> >:-(
21:16:23FromDiscord<Elegantbeef> Lol
21:16:37*progranner joined #nim
21:18:48FromDiscord<Elegantbeef> It might not seem that smart intially, but hey it's more reusable, so... uhh checkmate
21:20:44FromDiscord<Elegantbeef> I'm also someone that wants to be able to do `import mymodule[SomeType: MyReplacementType]`
21:21:06FromDiscord<Elegantbeef> `import std/strutils[string: MyString]` is just such a grand idea, fite me
21:21:25*progranner quit (Client Quit)
21:28:28FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4wI5
21:29:09FromDiscord<Elegantbeef> `event: var Event`
21:29:35FromDiscord<Ayy Lmao> event doesn't need to be mutated, I mean like `sendProc` needs to do stuff that the `sendEvent` isn't aware of
21:30:03FromDiscord<Ayy Lmao> It needs to mutate state that isn't passed into the function but the module isn't aware of.
21:30:28FromDiscord<Elegantbeef> That means you need a closure
21:30:50FromDiscord<Ayy Lmao> I need to avoid allocation unfortunately
21:31:43FromDiscord<Ayy Lmao> I was doing this in Odin by passing in a userdata pointer as an argument but I was wondering if there was a better way in Nim.
21:32:05*Batzy_ joined #nim
21:32:30FromDiscord<Elegantbeef> Well a generic would be more ideal, or make `sendEvent` a template
21:33:39FromDiscord<Ayy Lmao> Can it be done with a generic? I know for sure I could do it with a template but I try to avoid exporting templates in modules. But maybe with the mixin thing I can do it better now.
21:34:06FromDiscord<Elegantbeef> I mean it really sounds like you want a template
21:34:52FromDiscord<Ayy Lmao> The only reason I've been avoiding it is because if you export a template that uses dependencies it requires exporting the dependencies, but maybe bind can solve that.
21:35:13FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wI6
21:35:36FromDiscord<Ayy Lmao> In reply to @Elegantbeef "But you could make": That's essentially what I was doing in Odin except with a pointer instead of a generic.
21:36:43FromDiscord<Elegantbeef> Uhh templates bind procedures
21:36:44FromDiscord<Elegantbeef> https://wandbox.org/permlink/czQjKaVKR8w5pXO5
21:37:12FromDiscord<Elegantbeef> Right when you do not have generics you use `pointer` cause type erasure is needed
21:37:25FromDiscord<Elegantbeef> Generics generally replace `pointer` in most places
21:37:36*dv^_^ quit (*.net *.split)
21:37:36*attah quit (*.net *.split)
21:37:36*Batzy quit (*.net *.split)
21:37:57FromDiscord<Ayy Lmao> In reply to @Elegantbeef "Uhh templates bind procedures": Interesting. I guess I've mostly been having problems with types then or something. I've somehow ran into issues before so I've avoided it.
21:38:49FromDiscord<Ayy Lmao> The thing is I also need to pass in arguments to `sendProc` and I think I would need to inject pragma them into scope with a template which seems messy.
21:39:14FromDiscord<Elegantbeef> It's not that messy
21:40:01FromDiscord<Elegantbeef> Regardless I'd just use a generic
21:40:01FromDiscord<Elegantbeef> Simplest and tool and all
21:40:10FromDiscord<Ayy Lmao> I would have to inject 5 variables into scope in this case.
21:40:44FromDiscord<Elegantbeef> Or just one tuple you force the user to unpack 😛
21:41:01FromDiscord<Ayy Lmao> Hmmm, that could work.
21:41:14FromDiscord<Elegantbeef> Just use the generic
22:04:49*dv^_^ joined #nim
22:04:49*attah joined #nim
22:05:01*dv^_^ quit (Max SendQ exceeded)
22:05:27*dv^_^ joined #nim
22:21:43*lucasta joined #nim
22:26:16*xet7 quit (Ping timeout: 268 seconds)
22:27:20*xet7 joined #nim
22:33:51FromDiscord<Ayy Lmao> Why aren't openArrays allowed outside of function parameters? If they are implemented as a pointer and a length why can't they be stored in a variable?
22:34:04FromDiscord<Elegantbeef> Cause that'd be memory unsafe
22:35:44NimEventerNew post on r/nim by Uwu_Uwu135: Std/net not sending properly., see https://reddit.com/r/nim/comments/13rvmh7/stdnet_not_sending_properly/
22:35:56FromDiscord<Ayy Lmao> Hmmm I guess it makes more sense in a language that dabbles a bit more in that unsafety. I didn't really think about that.
22:36:22FromDiscord<Elegantbeef> You need a borrow checker to enable that
22:36:25FromDiscord<Elegantbeef> Safely
22:36:57FromDiscord<Ayy Lmao> What exactly constitutes memory unsafe? I have an unclear idea about that.
22:37:48FromDiscord<Ayy Lmao> I guess reading or writing to freed data?
22:37:58FromDiscord<Elegantbeef> Dangling pointers, dereferencing nil pointers, anything that involves accessing invalid memory
22:38:00FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wIj
22:38:27FromDiscord<Elegantbeef> Nim aims to be memory safe
22:40:14FromDiscord<Ayy Lmao> I guess it makes sense. It could lead to very insidious bugs if not used properly.
22:40:25FromDiscord<Elegantbeef> This is why borrow checkers exist
22:45:10*krux02 quit (Read error: Connection reset by peer)
23:06:45FromDiscord<jmgomez> In reply to @Elegantbeef "I realise now you": I was thinking in a plugin for the compiler that returns a proc sym that can be read from a macro
23:08:29FromDiscord<jmgomez> In reply to @juan_carlos "Would that bypass optimization,": Not really, think of `locals`
23:09:11*xet7 quit (Quit: Leaving)
23:09:32*xet7 joined #nim
23:10:09FromDiscord<jmgomez> In reply to @Elegantbeef "Right, I'd argue that": 💯
23:18:00*Notxor quit (Remote host closed the connection)
23:28:37FromDiscord<JJ> @mratsim discovered that rayon's use case is exactly that kind of parallelism you were explaining to me earlier. i now understand why people i know have called it magic
23:30:04FromDiscord<JJ> i guess rust's explicit iterator types lend themselves to making that easier. but still, wow
23:30:31FromDiscord<JJ> (edit) "i guess rust's explicit iterator types ... lend" added "(though i don't like them 😉)"
23:32:08FromDiscord<Elegantbeef> Hmph wonder if my iterator change will allow `for x in myIter.parallel.mapIt(it 30).filterIt(it > 30):`
23:34:09FromDiscord<Ayy Lmao> What exactly is an iterator behind the scenes in Nim?
23:34:23FromDiscord<Elegantbeef> A closure iterator is a proc and environment
23:34:27FromDiscord<Elegantbeef> A inline iterator is a template
23:34:59FromDiscord<Ayy Lmao> So a closure iterator would be one defined inside a function?
23:35:07FromDiscord<Elegantbeef> Nope
23:35:16FromDiscord<Elegantbeef> A closure iterator is one that's declared with `{.closure.}`
23:35:39FromDiscord<Ayy Lmao> Does that pragma get added automatically if you try to capture something?
23:36:03FromDiscord<Elegantbeef> No clue I almost never declare anything inside a procedure
23:36:23FromDiscord<Ayy Lmao> So does an inline iterator allocate at all?
23:36:34FromDiscord<Elegantbeef> It's inline it's pasted as a 0 cost iterator
23:36:34FromDiscord<ieltan> Hello Can someone explain to me what is `mixins`
23:36:58FromDiscord<Elegantbeef> It tells the compiler to look at instantation aswell as declaration for a symbol
23:36:59FromDiscord<ieltan> I read the doc but I don't know what an "open symbol" is
23:37:10FromDiscord<Elegantbeef> https://www.jasonbeetham.com/codereuse.html explains it a bit
23:37:46FromDiscord<ieltan> In reply to @Elegantbeef "It tells the compiler": To look where?
23:37:46FromDiscord<Ayy Lmao> In reply to @ieltan "I read the doc": It allows the compiler to look for the symbol at the call site.
23:37:52FromDiscord<ieltan> Oh
23:38:09FromDiscord<ieltan> I see, thanks!
23:38:12FromDiscord<Elegantbeef> also known as instantiation site
23:38:28FromDiscord<Elegantbeef> They're are technically two different things 😄
23:38:31FromDiscord<ieltan> In reply to @Elegantbeef "https://www.jasonbeetham.com/codereuse.html explain": Hey, That's the concept blog post
23:40:33FromDiscord<Ayy Lmao> In reply to @Elegantbeef "It's inline it's pasted": This might solve my problem I was asking about before with the `sendEvents` thing.
23:40:52FromDiscord<Elegantbeef> No clue
23:41:20NimEventerNew post on r/nim by qtless: Pure Js In Nim 👀, see https://reddit.com/r/nim/comments/13rx57h/pure_js_in_nim/
23:41:30FromDiscord<Ayy Lmao> In reply to @Elegantbeef "No clue": My problem was essentially that I have this queue of events and I want the user to extract a portion of the events and do something with them but without allocating.
23:41:53FromDiscord<Elegantbeef> And passing arguments to a pointer proc didnt work why?
23:42:13FromDiscord<Ayy Lmao> It does work, but I think an iterator approach might be cleaner and more versatile.
23:42:30FromDiscord<Elegantbeef> Except you cannot pass iterators to a procedure that arent closures
23:42:57FromDiscord<Ayy Lmao> I don't need to pass the iterator, the `sendEvents` function itself becomes an iterator, and you can do whatever you want with the events when you iterate over them.
23:43:04FromDiscord<Elegantbeef> Ah
23:43:06FromDiscord<Elegantbeef> Then there you go
23:43:37FromDiscord<Ayy Lmao> My original idea was to return a sequence of events but when allocation is forbidden that's a problem.