00:07:46 | FromDiscord | <Elegantbeef> People deleting messages making me look crazy |
00:23:45 | * | azimut joined #nim |
00:48:32 | FromDiscord | <Arathanis> I was trying to figure out who you were responding to |
00:48:57 | FromDiscord | <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:41 | FromDiscord | <Elegantbeef> well `constructor` doesnt have C equivlent |
00:50:02 | FromDiscord | <Elegantbeef> `exportC` when compiling Nim just emits the struct with a name |
00:50:11 | FromDiscord | <Elegantbeef> That isnt mangled |
00:52:00 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4wDZ |
00:52:11 | FromDiscord | <Elegantbeef> `NI z` but yea |
00:52:33 | FromDiscord | <Arathanis> if i had done `z: cint` would I have been correct? |
00:52:46 | FromDiscord | <Elegantbeef> Yes |
00:52:49 | FromDiscord | <Arathanis> thnx |
00:53:16 | FromDiscord | <Arathanis> are there similar mechanisms for exporting C++ classes? |
00:53:23 | FromDiscord | <Arathanis> i imagine that is a taller order. |
00:53:26 | FromDiscord | <Arathanis> especially methods. |
00:53:43 | FromDiscord | <Elegantbeef> That's what juan is working on partially |
01:28:00 | madprops | what am i doing wrong here .. |
01:28:01 | madprops | nre.match(line, re"strip").isSome |
01:28:07 | madprops | just want to check if regex matches |
01:28:14 | madprops | "strip" |
01:28:26 | madprops | it's always false |
01:28:54 | madprops | however, re"\w" does match stuff |
01:29:27 | madprops | guess it's a regex issue |
01:30:35 | madprops | have to do this: re".*strip.*" |
01:30:38 | madprops | not sure why |
01:30:44 | madprops | guess it's assuming beg and end |
01:31:42 | madprops | ok nre.find is better |
01:32:09 | FromDiscord | <Elegantbeef> Please tell me the actual usage is more than just "does my string contain strip" 😄 |
01:32:34 | madprops | the regex can be anything |
01:32:48 | madprops | im just testing |
01:49:07 | * | derpydoo quit (Read error: Connection reset by peer) |
01:49:39 | madprops | weird.. it's finding \w and \d but not \n |
01:50:04 | madprops | unless I escapeRe .. but if i do that, \w and \d don't work |
01:50:53 | madprops | oh nvm escaping is turning it into a literal |
01:50:55 | madprops | \n string |
01:51:38 | madprops | oh |
01:51:57 | madprops | of course, it's processing one line at a time |
02:12:44 | FromDiscord | <Arathanis> just need to use the multiline flag? |
02:45:40 | * | derpydoo joined #nim |
03:09:22 | madprops | arathanis not really ... |
03:09:30 | madprops | this program split into lines |
03:09:33 | madprops | then checks each one |
03:09:42 | madprops | i'd have to change how it works |
03:16:49 | FromDiscord | <Prestige> Can I populate a table at compile time (static block?) that would be available at runtime to read from? |
03:17:05 | FromDiscord | <Elegantbeef> Yes |
03:18:39 | FromDiscord | <Prestige> I'll need to try making a minrepro of this later, getting a compiler error |
03:20:24 | FromDiscord | <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:35 | FromDiscord | <Prestige> I'll probably make a min repro in a few hours |
03:23:23 | FromDiscord | <Elegantbeef> You might need to make a `var myTable = static: myConstTable` |
03:23:50 | FromDiscord | <Elegantbeef> But `myTable[bleh]` where `myTable` is const should be fine |
03:24:10 | FromDiscord | <Prestige> wow that worked |
03:24:14 | FromDiscord | <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:31 | FromDiscord | <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:29 | FromDiscord | <amadan> sent a code paste, see https://play.nim-lang.org/#ix=4wEA |
05:16:21 | FromDiscord | <Rika> Note that you cannot influence the resize factor though |
05:16:25 | FromDiscord | <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:54 | FromDiscord | <Rika> In reply to @Graveflo "Oh maybe I misread": No the cap procedure returns a regular sequence |
05:17:17 | FromDiscord | <Elegantbeef> capacity is just the amount of owned memory |
05:17:30 | FromDiscord | <Graveflo> oh ok. Thanks guys |
05:17:36 | FromDiscord | <Elegantbeef> It's not a fixed length |
05:39:52 | * | advesperacit joined #nim |
06:54:50 | FromDiscord | <ringabout> \ |
06:59:57 | * | PMunch joined #nim |
07:18:53 | FromDiscord | <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:31 | FromDiscord | <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:16 | FromDiscord | <ieltan> Hello, anyone knows how to deal with predictable hashtable collisions ? |
07:20:24 | FromDiscord | <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:38 | FromDiscord | <JJ> In reply to @mratsim "the programmer decides if": hmm i don't really understand that |
07:22:21 | * | Notxor joined #nim |
07:23:05 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#ix=4wEL |
07:24:06 | FromDiscord | <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:27 | FromDiscord | <mratsim> there is no overlap in the data range accessed and written to by each thread |
07:24:30 | FromDiscord | <mratsim> so no data race |
07:24:44 | FromDiscord | <mratsim> so multiple threads can access the data without any synchronization |
07:24:52 | FromDiscord | <mratsim> so this is safe |
07:25:44 | FromDiscord | <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:12 | FromDiscord | <mratsim> In reply to @apropos "i see. is that": There is the `parallel` statement that does this but it's being deprecated. |
07:27:06 | FromDiscord | <mratsim> see: https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn-parallel-statement |
07:28:52 | FromDiscord | <JJ> oh interesting. why is it being deprecated, did it not scale? |
07:29:03 | PMunch | ieltan, yes but you have to be a bit more specific |
07:29:42 | PMunch | Arathanis, 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:10 | FromDiscord | <Arathanis> In reply to @PMunch "<@136570191038513152>, sure, just make": but the proc will need a different identifier than the type, huh? |
07:30:18 | FromDiscord | <Arathanis> `toMyType` kind of thing? |
07:32:28 | PMunch | Oh right, that is correct. But you have the built in converter though: https://play.nim-lang.org/#ix=4wEM |
07:32:51 | FromDiscord | <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:37 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4wEU |
08:28:25 | FromDiscord | <Rika> `set[1..640]`? |
08:33:28 | FromDiscord | <sOkam!> oh didn't know thats a thing. ty |
08:36:50 | FromDiscord | <sOkam!> also, probably should use an `IntSet` i imagine |
08:39:13 | FromDiscord | <Rika> yeah thats an 80 byte large set |
08:46:17 | FromDiscord | <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:30 | FromDiscord | <sOkam!> (edit) |
08:53:22 | FromDiscord | <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:51 | PMunch | Crap.. 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:43 | FromDiscord | <JeanCareau> sent a long message, see http://ix.io/4wFK |
12:12:41 | FromDiscord | <JeanCareau> sent a long message, see http://ix.io/4wFM |
12:13:21 | FromDiscord | <JeanCareau> @michaelb.eth Now everything works. |
12:20:47 | FromDiscord | <JeanCareau> on the front page of nim-lang.org There are code examples. What is the color scheme called? |
12:21:35 | FromDiscord | <JeanCareau> I like the color scheme. |
12:37:12 | FromDiscord | <Ras> In reply to @JeanCareau "on the front page": https://nim-lang.org/assets/css/highlight/dracula.css |
12:37:31 | PMunch | JeanCareau, it's Dracula |
12:37:32 | FromDiscord | <Ras> link to the colour scheme in the comment at the top of the file |
12:37:39 | PMunch | And it is indeed a neat little theme |
12:38:06 | FromDiscord | <JeanCareau> @Ras Ah, thanks |
12:38:15 | PMunch | I'm not sure if it's stock Dracula though |
12:38:42 | PMunch | I seem to remember when colouring slides for some presentations that they didn't quite match up |
12:39:33 | FromDiscord | <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:38 | FromDiscord | <ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4wFV |
12:45:36 | FromDiscord | <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:58 | FromDiscord | <ieltan> What I could do is to wait until all values are inactive and then bulk delete them |
12:48:19 | FromDiscord | <ieltan> I think this may be a solution :think: |
12:48:24 | FromDiscord | <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:31 | FromDiscord | <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:52 | FromDiscord | <Rika> https://nim-lang.org/docs/typeinfo.html#base%2CAny |
14:12:13 | FromDiscord | <Rika> i think? |
14:12:14 | FromDiscord | <Rika> not sure |
14:12:36 | * | progranner quit (Client Quit) |
14:13:32 | FromDiscord | <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:47 | FromDiscord | <Rika> it looks like it but it doesnt seem right |
14:15:04 | FromDiscord | <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:24 | FromDiscord | <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:42 | NimEventer | New thread by alexeypetrushin: Install Nimble package from specific branch and subdri?, see https://forum.nim-lang.org/t/10222 |
16:36:24 | FromDiscord | <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:03 | FromDiscord | <jmgomez> structural vs nominal typing |
16:37:54 | FromDiscord | <sOkam!> what does that mean? |
16:40:22 | FromDiscord | <Elegantbeef> All tuples do not introduce a new distinct type |
16:41:10 | FromDiscord | <sOkam!> ah so they are technically just separate values, i assume? |
16:41:13 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wGX |
16:41:37 | FromDiscord | <Elegantbeef> Tuples are typed by shape, if the data is the same shape it's the same type |
16:41:47 | FromDiscord | <sOkam!> oh |
16:41:51 | FromDiscord | <Elegantbeef> Using named tuples is a faux pas |
16:42:07 | FromDiscord | <sOkam!> yeah i can see why so |
16:43:04 | FromDiscord | <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:14 | FromDiscord | <jmgomez> (edit) "know get" => "know/get" |
16:43:30 | FromDiscord | <jmgomez> (edit) "that" => "" |
16:43:48 | FromDiscord | <Elegantbeef> Nope unless you pass a parameter/variable declared inside the proc and use `owner` |
16:44:21 | FromDiscord | <Elegantbeef> That's the hack i generally do |
16:44:22 | FromDiscord | <Elegantbeef> Emit a macro that declares a variable that then passes that variable name to a macro |
16:45:22 | FromDiscord | <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:15 | FromDiscord | <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:14 | FromDiscord | <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:58 | FromDiscord | <Elegantbeef> `object ptr T`? |
17:01:39 | FromDiscord | <chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4wH2 |
17:01:40 | FromDiscord | <chmod222> Maybe more correct |
17:01:50 | FromDiscord | <Elegantbeef> Of course it'd be ptr ptr |
17:02:07 | FromDiscord | <chmod222> Makes sense, doesn't it? |
17:02:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/2MDgT |
17:02:45 | FromDiscord | <chmod222> Alrighty, looks good to me |
17:02:46 | FromDiscord | <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:02 | NimEventer | New thread by elcritch: Platonic: core math concepts, see https://forum.nim-lang.org/t/10223 |
18:39:50 | * | progranner joined #nim |
18:45:27 | FromDiscord | <sOkam!> @chmod222 how are the bindings going |
18:53:40 | * | Notxor joined #nim |
19:00:53 | FromDiscord | <chmod222> I'm fighting with curious segfaults in precisely the one area I need |
19:01:11 | FromDiscord | <chmod222> Battling the module system every other day |
19:02:22 | FromDiscord | <chmod222> The GDExtension documentation is not very helpful in the first issue because there is no GDExtension documentation |
19:04:08 | FromDiscord | <chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4wHr |
19:05:00 | FromDiscord | <chmod222> Especially for the cases of using `Ref[U]` where `Ref[T]` is expected, when `U = object of T` |
19:07:09 | FromDiscord | <Elegantbeef> There isnt really a way to get that converter to work, what's the mismatch look like? |
19:07:42 | FromDiscord | <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:00 | FromDiscord | <Elegantbeef> case statements only can use static values |
19:08:27 | FromDiscord | <Elegantbeef> `parseEnum[TokenKind](lex.str)` |
19:08:36 | FromDiscord | <Elegantbeef> Or create your own non exceptionful version |
19:08:55 | FromDiscord | <guttural666> aren't those strings static? |
19:09:01 | FromDiscord | <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:10 | FromDiscord | <Elegantbeef> They are but `token_kind` isnt |
19:09:12 | FromDiscord | <chmod222> But this happens all over, because inheritance |
19:09:24 | FromDiscord | <Elegantbeef> `$token_kind` is a for loop variable that is not static |
19:09:30 | FromDiscord | <Elegantbeef> If we had a general unroll you could use that |
19:09:38 | FromDiscord | <chmod222> my mapped `DirAccess` of course derives from my mapped `RefCounted`, but that is lost with `Ref[]` |
19:10:08 | FromDiscord | <Elegantbeef> `proc getReferenceCount[T](r: Ref[T])` doesnt work? |
19:10:10 | FromDiscord | <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:22 | FromDiscord | <Elegantbeef> Nope |
19:10:24 | FromDiscord | <Elegantbeef> that for loop runs at runtime |
19:10:44 | FromDiscord | <guttural666> In reply to @Elegantbeef "that for loop runs": okay, so an if statement it is |
19:10:45 | FromDiscord | <mratsim> sent a long message, see https://paste.rs/QBmP4 |
19:10:46 | FromDiscord | <Elegantbeef> You're attempting to raise a runtime value to a static value |
19:10:47 | FromDiscord | <chmod222> It will probably work, but then I have to make every single method generic and that sounds like inviting trouble \:) |
19:11:05 | FromDiscord | <chmod222> But if that is the only way, I'll probably need that |
19:11:06 | FromDiscord | <Elegantbeef> It's not |
19:11:20 | FromDiscord | <Elegantbeef> It's the proper solution imo |
19:12:33 | FromDiscord | <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:34 | FromDiscord | <Elegantbeef> You also could have a `type RefBase = object of RootObj` and implement `getRefCount` for that |
19:12:57 | FromDiscord | <Elegantbeef> It would forbid that |
19:13:21 | FromDiscord | <Elegantbeef> `pet_cat` would be `cat: Ref[Cat]` |
19:13:23 | FromDiscord | <Elegantbeef> you're defining a general procedure that all `Ref` share |
19:13:45 | FromDiscord | <chmod222> But with that solution I'd have to make everything a `Ref[T]` |
19:13:54 | FromDiscord | <Elegantbeef> Only the procedures that are general |
19:14:17 | FromDiscord | <Elegantbeef> `getRefCount` is a general procedure that all `Ref` should have |
19:14:29 | FromDiscord | <Elegantbeef> I might not understand godot's system if each type has it's own special `getRefCount` |
19:14:37 | FromDiscord | <chmod222> Godot suffers heavily from inheritance, so everything derives from something or other |
19:14:52 | FromDiscord | <chmod222> I think 600 of the \~900 classes are `RefCounted` descendants |
19:14:56 | FromDiscord | <Elegantbeef> Sure but Nim implicitly upcasts to inherited types on dispatch |
19:15:03 | FromDiscord | <chmod222> The others are `Object` descendants, which `RefCounted` also is |
19:15:29 | FromDiscord | <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:50 | FromDiscord | <Elegantbeef> General operations can be implemented on the base type |
19:15:55 | FromDiscord | <Elegantbeef> Just as you do in other OOP languages |
19:16:14 | FromDiscord | <chmod222> I know, but that's just the problem here |
19:16:52 | FromDiscord | <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:05 | FromDiscord | <chmod222> `Ref[MyCustomSprite]` no longer casts to `Ref[Sprite]` |
19:17:53 | FromDiscord | <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:14 | FromDiscord | <chmod222> Make it proper implementation detail |
19:21:32 | FromDiscord | <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:35 | FromDiscord | <Elegantbeef> Probably best to have the ref inside the object |
19:21:41 | FromDiscord | <Elegantbeef> Using converters is always meh |
19:21:56 | FromDiscord | <chmod222> I'd love to just handle the memory myself and use proper `ref` types, but godot is a diva |
19:22:29 | FromDiscord | <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:03 | FromDiscord | <Elegantbeef> `parseEnum` |
19:23:06 | FromDiscord | <Elegantbeef> Like i said |
19:24:48 | FromDiscord | <guttural666> In reply to @Elegantbeef "`parseEnum`": sorry, didn't see that, gonna take a look at that thanks! |
19:34:57 | FromDiscord | <guttural666> still excludes a for loop |
19:35:48 | FromDiscord | <guttural666> maybe a map between Token enums and a string representation? |
19:51:59 | FromDiscord | <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:15 | FromDiscord | <Elegantbeef> @jmgomez A PNode is a NimNode, no? |
20:07:47 | FromDiscord | <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:15 | FromDiscord | <Sh1be> it feels like im new to programming again when i learn nim 😠|
20:10:31 | FromDiscord | <JJ> that's good! it means you're learning new concepts (unless it is not good and a problem with the documentation) |
20:11:18 | FromDiscord | <Elegantbeef> Yea IIRC you said you knew TS and C# |
20:11:27 | FromDiscord | <Elegantbeef> Nim is different to both those as it's a procedural language |
20:11:30 | FromDiscord | <juan_carlos> In reply to @jmgomez "<@145405730571288577> do you know": Would that bypass optimization, semchecking, etc etc of the compiler(?). |
20:12:07 | FromDiscord | <Elegantbeef> I realise now you mean a VM PNode to a compiler NimNode |
20:15:02 | FromDiscord | <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:35 | FromDiscord | <Elegantbeef> I came to Nim from C# and it was a bit odd at first, but it's not much nicer |
20:15:36 | FromDiscord | <Elegantbeef> now much\ |
20:16:48 | FromDiscord | <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:17 | FromDiscord | <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:16 | FromDiscord | <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:37 | FromDiscord | <chmod222> The good thing is that so far I have always found a way around some issue |
20:20:55 | FromDiscord | <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:29 | FromDiscord | <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:14 | FromDiscord | <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:52 | FromDiscord | <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:22 | FromDiscord | <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:55 | FromDiscord | <chmod222> `get_reference_count = 1`, sexiest sequence of chars I have read in 3 days |
20:25:12 | FromDiscord | <chmod222> It seems I finally figured something out |
20:27:20 | FromDiscord | <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:44 | FromDiscord | <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:29 | FromDiscord | <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:58 | FromDiscord | <chmod222> They are somewhat possible if you order your things correctly |
20:46:27 | FromDiscord | <Elegantbeef> They're planned eventually, we do have delayed imports |
20:47:25 | FromDiscord | <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:49 | FromDiscord | <Ayy Lmao> And what are delayed imports? |
20:47:56 | FromDiscord | <chmod222> Zig is really the gold standard in terms of that |
20:48:06 | FromDiscord | <chmod222> Top level lazyness is very convenient |
20:48:11 | FromDiscord | <Elegantbeef> Eh Zig's laziness is also a curse |
20:48:28 | FromDiscord | <Elegantbeef> Invalid code compiles until used like a generic that's not generic |
20:48:29 | FromDiscord | <chmod222> That too |
20:48:52 | FromDiscord | <chmod222> Or you may have 3049 errors in your code but don't know unless you force something to be evaluated |
20:49:19 | FromDiscord | <Elegantbeef> That's a delayed import |
20:49:26 | FromDiscord | <Ayy Lmao> In reply to @chmod222 "Or you may have": Isn't that the case with generics in Nim? |
20:49:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/kVdap |
20:49:35 | FromDiscord | <Elegantbeef> Not really |
20:49:49 | FromDiscord | <Elegantbeef> Even Nim's generics do some sanity checks |
20:50:39 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4wHV |
20:51:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wHW |
20:51:26 | FromDiscord | <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:45 | FromDiscord | <Ayy Lmao> Makes doing conditional compilation a pain. |
20:52:10 | FromDiscord | <Elegantbeef> In a generic of course that can error |
20:52:41 | FromDiscord | <Elegantbeef> But inside `proc doThing() = discard "bleh" + 10` it doesnt error |
20:53:05 | FromDiscord | <Elegantbeef> So suffice to say Zig's laziness can be nice for compile times, but it's awful for static typing |
20:53:32 | FromDiscord | <Elegantbeef> Even marking it `pub` doesnt make it semantically check the procedure |
20:54:07 | FromDiscord | <Elegantbeef> Odin is inspired by oberon which did some interesting/weird things |
20:54:55 | FromDiscord | <Ayy Lmao> I'm too addicted to the way Nim does universal function call syntax to use anything else I think. |
20:55:09 | FromDiscord | <chmod222> I really, really mostly wish Zig would drop the whole "unused is an error" bullshit |
20:55:25 | FromDiscord | <chmod222> It could be such a great language |
20:55:29 | FromDiscord | <Elegantbeef> Yea once you use UFCS it's missing from every other place |
20:55:47 | FromDiscord | <JJ> In reply to @Ayy Lmao "I'm too addicted to": yeah. rust does it a smidgen but far far from enough |
20:56:32 | FromDiscord | <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:40 | FromDiscord | <Elegantbeef> Cheers |
20:56:50 | FromDiscord | <Elegantbeef> Did you go down the tuple route? |
20:56:58 | FromDiscord | <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:16 | FromDiscord | <JJ> (edit) "types" => "type declaration lookahead" |
20:57:52 | FromDiscord | <Elegantbeef> Like I said tuples really are magical features of code, even though i dislike how most use them |
20:57:52 | FromDiscord | <Elegantbeef> JJ I really think that in many cases generics trump cyclical imports, but I'm also a bit mad |
20:58:16 | FromDiscord | <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:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wHZ |
20:58:48 | FromDiscord | <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:01 | FromDiscord | <Ayy Lmao> And my example yesterday was very stripped down and there are some other considerations. |
20:59:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wI1 |
20:59:37 | FromDiscord | <Elegantbeef> This lets me inject my own fields for `Button`s both from `Element` and the ones declared there |
20:59:47 | FromDiscord | <Elegantbeef> It gives you a bit of multiple inheritance |
21:00:35 | FromDiscord | <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:09 | FromDiscord | <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:57 | FromDiscord | <Elegantbeef> I think replacing cyclical imports using generics is a bit odd initially, but it makes code more reusable 😄 |
21:03:08 | FromDiscord | <Elegantbeef> Not that projectiles in my game really need to be reusable |
21:03:10 | FromDiscord | <Elegantbeef> But alas! |
21:12:04 | FromDiscord | <guttural666> is returning an Option[Token] the canonical way to deal with optionals? |
21:12:21 | FromDiscord | <Elegantbeef> That or you introduce a `tokenKind: None` |
21:13:46 | FromDiscord | <guttural666> that sounds good |
21:15:04 | FromDiscord | <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:16 | FromDiscord | <Elegantbeef> Exactly |
21:15:27 | FromDiscord | <JJ> that doesn't work with generics? |
21:15:29 | FromDiscord | <Elegantbeef> You make a generic type that consumes the type you want to insert |
21:15:55 | FromDiscord | <JJ> oh god what the fuck |
21:16:08 | FromDiscord | <JJ> >:-( |
21:16:23 | FromDiscord | <Elegantbeef> Lol |
21:16:37 | * | progranner joined #nim |
21:18:48 | FromDiscord | <Elegantbeef> It might not seem that smart intially, but hey it's more reusable, so... uhh checkmate |
21:20:44 | FromDiscord | <Elegantbeef> I'm also someone that wants to be able to do `import mymodule[SomeType: MyReplacementType]` |
21:21:06 | FromDiscord | <Elegantbeef> `import std/strutils[string: MyString]` is just such a grand idea, fite me |
21:21:25 | * | progranner quit (Client Quit) |
21:28:28 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4wI5 |
21:29:09 | FromDiscord | <Elegantbeef> `event: var Event` |
21:29:35 | FromDiscord | <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:03 | FromDiscord | <Ayy Lmao> It needs to mutate state that isn't passed into the function but the module isn't aware of. |
21:30:28 | FromDiscord | <Elegantbeef> That means you need a closure |
21:30:50 | FromDiscord | <Ayy Lmao> I need to avoid allocation unfortunately |
21:31:43 | FromDiscord | <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:30 | FromDiscord | <Elegantbeef> Well a generic would be more ideal, or make `sendEvent` a template |
21:33:39 | FromDiscord | <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:06 | FromDiscord | <Elegantbeef> I mean it really sounds like you want a template |
21:34:52 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wI6 |
21:35:36 | FromDiscord | <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:43 | FromDiscord | <Elegantbeef> Uhh templates bind procedures |
21:36:44 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/czQjKaVKR8w5pXO5 |
21:37:12 | FromDiscord | <Elegantbeef> Right when you do not have generics you use `pointer` cause type erasure is needed |
21:37:25 | FromDiscord | <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:57 | FromDiscord | <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:49 | FromDiscord | <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:14 | FromDiscord | <Elegantbeef> It's not that messy |
21:40:01 | FromDiscord | <Elegantbeef> Regardless I'd just use a generic |
21:40:01 | FromDiscord | <Elegantbeef> Simplest and tool and all |
21:40:10 | FromDiscord | <Ayy Lmao> I would have to inject 5 variables into scope in this case. |
21:40:44 | FromDiscord | <Elegantbeef> Or just one tuple you force the user to unpack 😛 |
21:41:01 | FromDiscord | <Ayy Lmao> Hmmm, that could work. |
21:41:14 | FromDiscord | <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:51 | FromDiscord | <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:04 | FromDiscord | <Elegantbeef> Cause that'd be memory unsafe |
22:35:44 | NimEventer | New 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:56 | FromDiscord | <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:22 | FromDiscord | <Elegantbeef> You need a borrow checker to enable that |
22:36:25 | FromDiscord | <Elegantbeef> Safely |
22:36:57 | FromDiscord | <Ayy Lmao> What exactly constitutes memory unsafe? I have an unclear idea about that. |
22:37:48 | FromDiscord | <Ayy Lmao> I guess reading or writing to freed data? |
22:37:58 | FromDiscord | <Elegantbeef> Dangling pointers, dereferencing nil pointers, anything that involves accessing invalid memory |
22:38:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4wIj |
22:38:27 | FromDiscord | <Elegantbeef> Nim aims to be memory safe |
22:40:14 | FromDiscord | <Ayy Lmao> I guess it makes sense. It could lead to very insidious bugs if not used properly. |
22:40:25 | FromDiscord | <Elegantbeef> This is why borrow checkers exist |
22:45:10 | * | krux02 quit (Read error: Connection reset by peer) |
23:06:45 | FromDiscord | <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:29 | FromDiscord | <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:09 | FromDiscord | <jmgomez> In reply to @Elegantbeef "Right, I'd argue that": 💯 |
23:18:00 | * | Notxor quit (Remote host closed the connection) |
23:28:37 | FromDiscord | <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:04 | FromDiscord | <JJ> i guess rust's explicit iterator types lend themselves to making that easier. but still, wow |
23:30:31 | FromDiscord | <JJ> (edit) "i guess rust's explicit iterator types ... lend" added "(though i don't like them 😉)" |
23:32:08 | FromDiscord | <Elegantbeef> Hmph wonder if my iterator change will allow `for x in myIter.parallel.mapIt(it 30).filterIt(it > 30):` |
23:34:09 | FromDiscord | <Ayy Lmao> What exactly is an iterator behind the scenes in Nim? |
23:34:23 | FromDiscord | <Elegantbeef> A closure iterator is a proc and environment |
23:34:27 | FromDiscord | <Elegantbeef> A inline iterator is a template |
23:34:59 | FromDiscord | <Ayy Lmao> So a closure iterator would be one defined inside a function? |
23:35:07 | FromDiscord | <Elegantbeef> Nope |
23:35:16 | FromDiscord | <Elegantbeef> A closure iterator is one that's declared with `{.closure.}` |
23:35:39 | FromDiscord | <Ayy Lmao> Does that pragma get added automatically if you try to capture something? |
23:36:03 | FromDiscord | <Elegantbeef> No clue I almost never declare anything inside a procedure |
23:36:23 | FromDiscord | <Ayy Lmao> So does an inline iterator allocate at all? |
23:36:34 | FromDiscord | <Elegantbeef> It's inline it's pasted as a 0 cost iterator |
23:36:34 | FromDiscord | <ieltan> Hello Can someone explain to me what is `mixins` |
23:36:58 | FromDiscord | <Elegantbeef> It tells the compiler to look at instantation aswell as declaration for a symbol |
23:36:59 | FromDiscord | <ieltan> I read the doc but I don't know what an "open symbol" is |
23:37:10 | FromDiscord | <Elegantbeef> https://www.jasonbeetham.com/codereuse.html explains it a bit |
23:37:46 | FromDiscord | <ieltan> In reply to @Elegantbeef "It tells the compiler": To look where? |
23:37:46 | FromDiscord | <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:52 | FromDiscord | <ieltan> Oh |
23:38:09 | FromDiscord | <ieltan> I see, thanks! |
23:38:12 | FromDiscord | <Elegantbeef> also known as instantiation site |
23:38:28 | FromDiscord | <Elegantbeef> They're are technically two different things 😄 |
23:38:31 | FromDiscord | <ieltan> In reply to @Elegantbeef "https://www.jasonbeetham.com/codereuse.html explain": Hey, That's the concept blog post |
23:40:33 | FromDiscord | <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:52 | FromDiscord | <Elegantbeef> No clue |
23:41:20 | NimEventer | New post on r/nim by qtless: Pure Js In Nim 👀, see https://reddit.com/r/nim/comments/13rx57h/pure_js_in_nim/ |
23:41:30 | FromDiscord | <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:53 | FromDiscord | <Elegantbeef> And passing arguments to a pointer proc didnt work why? |
23:42:13 | FromDiscord | <Ayy Lmao> It does work, but I think an iterator approach might be cleaner and more versatile. |
23:42:30 | FromDiscord | <Elegantbeef> Except you cannot pass iterators to a procedure that arent closures |
23:42:57 | FromDiscord | <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:04 | FromDiscord | <Elegantbeef> Ah |
23:43:06 | FromDiscord | <Elegantbeef> Then there you go |
23:43:37 | FromDiscord | <Ayy Lmao> My original idea was to return a sequence of events but when allocation is forbidden that's a problem. |