00:02:52 | * | rockcavera joined #nim |
00:03:52 | FromDiscord | <sa-code> maybe I should just interop with go instead of cpp |
00:14:26 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4lYc |
00:14:33 | FromDiscord | <4zv4l> and when I'm on the server trying a slash command well↵it doesn't work |
00:16:04 | FromDiscord | <that_dude> In reply to @sa-code "I'm looking at the": https://scripter.co/binding-nim-to-c-plus-plus-std-list/ This article/blog may be of use to you |
00:16:29 | FromDiscord | <sa-code> thanks I'll have a look! |
00:34:39 | * | azimut joined #nim |
01:04:24 | FromDiscord | <Hourglass [She/Her]> In reply to @sa-code "maybe I should just": Good luck- I have a very terrible example of it actually |
01:04:38 | FromDiscord | <Hourglass [She/Her]> https://github.com/Mythical-Forest-Collective/GoNim |
01:04:46 | FromDiscord | <Hourglass [She/Her]> Is that not the repo? |
01:05:15 | FromDiscord | <Hourglass [She/Her]> Yep it is |
01:05:31 | FromDiscord | <Hourglass [She/Her]> But either way, it'll probably be a pain for bigger libraries aha |
01:47:01 | FromDiscord | <Gumbercules> Garbage collection might be an issue |
01:47:16 | FromDiscord | <Gumbercules> Depending on what you're attempting to do... |
02:09:17 | FromDiscord | <ajusa> getting a little philosophical here, but how do folks feel about exceptions vs options vs results? Eg, you have some function that has an edge case that it cannot handle, and that the caller should handle. Should that function return an Option with the return type wrapped, throw an exception and expect the parent to catch it, or return a Result (https://github.com/arnetheduck/nim-result) with a string error message? |
02:12:09 | FromDiscord | <Elegantbeef> It's down to your preference really. Results/Options allocate less and are conventionally faster, but enforce handling of errors. Exceptions do not enforce handling errors, and in my view have better semantics. |
02:13:32 | FromDiscord | <ajusa> I thought with arc/orc/goto exceptions that those were actually faster? |
02:14:16 | FromDiscord | <ajusa> I did rewrite some code to use Option[T] instead of exceptions and found that it became more difficult to reason about, though there is a function that propagates an exception which isn't explicit |
02:16:20 | FromDiscord | <Rika> I personally think options aren’t for error handling |
02:16:31 | FromDiscord | <Elegantbeef> Exceptions are generally slower due to how they work. They heap allocate and also require unwinding of the stack |
02:16:31 | FromDiscord | <Elegantbeef> I personally prefer using exceptions due to not forcing handling of errors and having better semantics |
02:17:38 | FromDiscord | <Elegantbeef> I agree with options |
02:17:38 | FromDiscord | <Elegantbeef> They're not error handling, they're whether a value is some or not 😄 |
02:17:53 | FromDiscord | <Rika> Bridge is slow today huh |
02:18:03 | FromDiscord | <Rika> Some significant delay there |
02:20:51 | FromDiscord | <demotomohiro> If exceptions allocate heap, how they work when out of memory? |
02:22:25 | arkanoid | it's funny how my head keeps fighting about using or not let/var blocks |
02:22:36 | FromDiscord | <Elegantbeef> oom causes a panci |
02:23:27 | FromDiscord | <demotomohiro> So exceptions are not used for oom? |
02:24:26 | arkanoid | oom is an OS thing, not application level thing, iirc |
02:24:33 | arkanoid | *if iirc |
02:24:49 | FromDiscord | <Elegantbeef> It's a program specific thing |
02:26:03 | FromDiscord | <Elegantbeef> `malloc` can return `nil` iirc which means "no memory left to allocate to" |
02:27:31 | arkanoid | not sure if that counts as oom. If that is so, how is called when memory pressure is too high and kernel goes killer-frenzy an shoots at processes. Dmesg shows OOM in that context |
02:27:35 | arkanoid | also android |
02:28:45 | FromDiscord | <pyolyokh> get rid of the this term 'oom' that you're using, and refer separately to the operation of the linux oomkiller and to allocators running out of memory. |
02:29:34 | FromDiscord | <pyolyokh> or talk about 'low memory conditions', because on I/O-overutilized servers, as you run dry on filesystem cache things are catching fire and dying well before you run out of memory |
02:32:45 | FromDiscord | <jtv> Wow, converters have an infinite recursion bug. And I was just so excited to learn that I could convert values to Options automatically, only to find it will fail in some external libraries, like Json 🙂 |
02:33:03 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lYt |
02:33:30 | FromDiscord | <pyolyokh> `new(int)` |
02:33:47 | FromDiscord | <sOkam!> and the value? how do you assign it? |
02:34:00 | FromDiscord | <pyolyokh> `let v = new(int); v[] = 1` |
02:34:08 | FromDiscord | <sOkam!> kk ty |
02:34:30 | FromDiscord | <pyolyokh> you have another example right there, `new[int](1)` |
02:37:04 | FromDiscord | <sOkam!> but that is not working |
02:37:17 | FromDiscord | <sOkam!> hence I asked, because it wasn't compiling |
02:38:14 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lYu |
02:39:11 | FromDiscord | <Elegantbeef> `new[int](2)` isnt a thing |
02:39:15 | FromDiscord | <Elegantbeef> you can make it if you want |
02:39:24 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lYv |
02:39:59 | FromDiscord | <Elegantbeef> Much easier 😄 |
02:40:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lYw |
02:40:56 | FromDiscord | <sOkam!> is there not a simpler way of doing things? |
02:41:24 | FromDiscord | <sOkam!> all i wanted is to store the same value in different objects, and be able to modify one to modify the others |
02:41:25 | FromDiscord | <pyolyokh> yeah, don't use refs |
02:42:09 | FromDiscord | <Elegantbeef> A ref is simple |
02:42:36 | FromDiscord | <Rika> What’s the issue with references |
02:43:09 | FromDiscord | <pyolyokh> the issue is that it's not that simple, apparently |
02:43:52 | FromDiscord | <jtv> Syntactically it's confusing to people because of the overloading of the square brackets I think. |
02:43:55 | FromDiscord | <sOkam!> by simpler i meant standard in the lang, without having to hack new functionality that doesn't exist for a basic type |
02:44:16 | FromDiscord | <Elegantbeef> is it really a hack |
02:44:30 | FromDiscord | <Elegantbeef> To be fair you can use pyo's method |
02:44:36 | FromDiscord | <pyolyokh> the two-line function isn't a hacked, or even needed. `new(int)` works well enough. And it even makes more sense than the 'hack' in your case of wanting to create multiple refs and assign them all to the same value |
02:44:36 | FromDiscord | <Elegantbeef> and just do `new 1` |
02:44:42 | FromDiscord | <sOkam!> well, if its not already there, i assume there is another standard way |
02:45:05 | FromDiscord | <Rika> Yes, the two liner is the standard way |
02:45:16 | FromDiscord | <sOkam!> kk |
02:46:06 | FromDiscord | <pyolyokh> rather, create one ref that's then copied to all these different places |
02:47:46 | FromDiscord | <tfp> is there a way to pass a preamble you'd like appended to all of your source files |
02:48:05 | FromDiscord | <tfp> like i want one file to be imported by default |
02:48:13 | FromDiscord | <Elegantbeef> `--import:...` |
02:48:19 | FromDiscord | <Elegantbeef> or `--include` |
02:48:50 | FromDiscord | <tfp> epic |
02:48:51 | FromDiscord | <tfp> thanks |
02:49:01 | FromDiscord | <tfp> will that work with nimsuggest |
02:50:46 | FromDiscord | <jtv> Can have everything refer to one ref object instance |
02:54:19 | FromDiscord | <pyolyokh> In reply to @jos "will that work with": if you put the flag in an appropriate nim.cfg, maybe |
02:55:00 | FromDiscord | <Elegantbeef> or config.nims |
02:55:55 | FromDiscord | <tfp> is nim a single pass compiler? |
02:56:04 | FromDiscord | <Elegantbeef> Yes |
02:56:26 | FromDiscord | <tfp> :gurasip: |
02:56:31 | FromDiscord | <tfp> really makes u think |
02:57:40 | FromDiscord | <Elegantbeef> Does it? |
02:57:54 | FromDiscord | <Rika> ? |
03:19:03 | * | rockcavera quit (Remote host closed the connection) |
03:20:41 | * | byanka joined #nim |
03:25:22 | FromDiscord | <tfp> https://media.discordapp.net/attachments/371759389889003532/1066921557194186834/Screenshot_2023-01-22_at_10.24.16_PM.png |
03:25:27 | FromDiscord | <tfp> is there a way to make this error show up here |
03:25:47 | FromDiscord | <tfp> i guess i can make my own diagnostics in the macro itself |
03:25:51 | FromDiscord | <Elegantbeef> Not using quote do |
03:25:57 | FromDiscord | <Elegantbeef> or `line` pragma |
03:26:29 | FromDiscord | <tfp> mmm |
03:26:33 | FromDiscord | <tfp> so i can like push line pragma |
03:26:54 | FromDiscord | <Elegantbeef> Actually line only works on exceptions |
03:27:36 | FromDiscord | <tfp> hmm |
03:27:56 | FromDiscord | <tfp> is there any other way to proxy it that u can think of or will i have to make my own diagnostic |
03:28:30 | FromDiscord | <tfp> maybe i can just make a macro that expands to project root? like import $root/whatever |
03:28:49 | FromDiscord | <tfp> import absify(/whatever) |
03:29:46 | FromDiscord | <tfp> nvm the macro doesn't expand there |
03:51:54 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lYC |
03:59:05 | FromDiscord | <tfp> u can just add the project to its own path? |
03:59:28 | FromDiscord | <tfp> i dont actually understand the example that well-- can u import user from foo/bar/example? |
03:59:33 | FromDiscord | <pyolyokh> nim has a list of search paths. You can add anything to them that works for you |
03:59:37 | FromDiscord | <tfp> or do u have to do ../../user |
03:59:49 | FromDiscord | <pyolyokh> you can 'import user' if b is in your search paths |
03:59:55 | FromDiscord | <tfp> why does nobody bring this up in like the 10 different discussions online about importing from absolute paths |
04:00:10 | FromDiscord | <tfp> is there some massive downside like duplicate symbols or something |
04:00:15 | FromDiscord | <pyolyokh> no. |
04:00:29 | FromDiscord | <tfp> that's weird man |
04:00:37 | FromDiscord | <tfp> why would nobody bring that up in those discussions |
04:00:42 | FromDiscord | <tfp> really makes u think |
04:00:52 | FromDiscord | <tfp> thanks |
04:03:50 | FromDiscord | <Tuatarian> when writing a custom destructor |
04:03:50 | FromDiscord | <pyolyokh> sent a long message, see http://ix.io/4lYF |
04:04:11 | FromDiscord | <Tuatarian> is there a way to destroy only certain fields? |
04:04:16 | FromDiscord | <Tuatarian> at the moment I have this |
04:04:27 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4lYH |
04:04:39 | FromDiscord | <Tuatarian> but I only want to destroy certain fields atm |
04:04:50 | FromDiscord | <Elegantbeef> `for name, field in n[].fieldPairs` |
04:05:00 | FromDiscord | <Elegantbeef> and `when name == "bleh"` |
04:05:14 | FromDiscord | <Elegantbeef> Though `fields` doesnt work with object variants |
04:19:14 | * | arkurious quit (Ping timeout: 246 seconds) |
04:28:02 | * | rockcavera joined #nim |
05:36:56 | * | byanka quit (Ping timeout: 252 seconds) |
05:41:54 | * | byanka_ joined #nim |
05:45:20 | FromDiscord | <avarez> Thank me later 👉↵https://t.me/+OuATQxCrsLkwY2Y0 |
05:52:25 | FromDiscord | <sOkam!> <@&371760044473319454> ^ spam |
06:08:31 | * | xet7 quit (Quit: Leaving) |
06:29:09 | * | xet7 joined #nim |
06:45:18 | FromDiscord | <lithiumfrost> Can anyone tell me how to get to the field of an underlying object given a ptr to a ptr array of obj? |
06:45:43 | FromDiscord | <lithiumfrost> (C API) |
06:45:44 | FromDiscord | <Elegantbeef> `myArray[index].field` |
06:46:07 | FromDiscord | <Elegantbeef> or `myPtr[][index].field` |
06:46:10 | FromDiscord | <Elegantbeef> Depends on your Nim type def |
06:47:00 | FromDiscord | <lithiumfrost> var data : ptr ptr PCREDENTIALW |
06:47:06 | FromDiscord | <lithiumfrost> So that second would be it |
06:48:10 | FromDiscord | <Elegantbeef> `let b = a.addr` i guess makes it more like what you have |
06:48:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lZ1 |
06:48:56 | FromDiscord | <Elegantbeef> You will need to cast it to a `ptr UncheckedArray[PCredentialW]` i assume |
06:49:16 | FromDiscord | <Elegantbeef> Guessing that name means winim so dont know if they have `[]` for ptrs there |
06:49:17 | FromDiscord | <lithiumfrost> Ok, that's the piece that I was missing |
06:49:27 | FromDiscord | <lithiumfrost> And it is winim |
06:49:36 | FromDiscord | <Elegantbeef> Yea Nim unlike C differentiates arrays from single elements |
06:49:52 | FromDiscord | <lithiumfrost> If they don't, how do I deference the ptr? |
06:50:03 | FromDiscord | <Elegantbeef> Cast it like i showed |
06:50:11 | FromDiscord | <lithiumfrost> Ah, ok, thanks |
06:50:43 | FromDiscord | <lithiumfrost> A little shaky on the C interop stuff yet |
06:56:56 | * | rockcavera quit (Remote host closed the connection) |
07:35:38 | FromDiscord | <Hourglass [She/Her]> In reply to @Gumbercules "Garbage collection might be": Yep, it sucks |
07:37:36 | FromDiscord | <Hourglass [She/Her]> But either way, if you're gonna use Go, might as well go the full way |
07:37:46 | FromDiscord | <Hourglass [She/Her]> It'll already add a lot of bloat |
07:39:41 | * | PMunch joined #nim |
07:53:53 | * | azimut quit (Ping timeout: 255 seconds) |
08:31:23 | FromDiscord | <abisxir> In reply to @abisxir "Guys I have a": Any easy solution for this dudes? |
08:32:09 | FromDiscord | <Elegantbeef> As leo said you have to use manual `x of Y` checks |
08:32:39 | FromDiscord | <Elegantbeef> Typedescs do not exist at runtime, so you either make manual `of` branches or use the typeinfo module to extract what you need |
08:36:29 | FromDiscord | <abisxir> Humm, thanks @ElegantBeef but I do not need typedesc actually, I need the type name and I do not need performance here, but has to be general for the future extended types. |
08:37:39 | FromDiscord | <Phil> And methods were out because you don't want your users to have to define them? |
08:38:22 | FromDiscord | <Elegantbeef> I actually dont think Nim's RTTI let's fetching of the type name without 'hacks' |
08:38:56 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/core/typeinfo.nim#L87↵https://github.com/nim-lang/Nim/blob/version-1-6/lib/system/hti.nim#L89-L107 |
08:39:03 | FromDiscord | <Phil> Honestly I think those were your best bets.↵After that all that's left is having a field on your object that contains the typename and then you need constructors that set that typename correctly all the time |
08:39:07 | FromDiscord | <Elegantbeef> Use these together and you can get the name 😄 |
08:39:19 | FromDiscord | <Phil> Which is more effort than just defining a method |
08:39:28 | FromDiscord | <Phil> Oh? hti? |
08:40:34 | FromDiscord | <Phil> Okay whatever solution that would offer looks darker than the night |
08:40:51 | FromDiscord | <Phil> I'd rather suggest going with the method and documenting that your users need to define those |
08:41:08 | FromDiscord | <Elegantbeef> Bleh it's not that bad |
08:41:58 | FromDiscord | <Phil> OR not bothering with inheritance in the first place, though then you can't do a seq of those models |
08:44:24 | FromDiscord | <abisxir> Hummm, so strange that it return B of A true but does know know the name 😁 fortunately I need it for a helper function to debugging, for now I just remove the function 🙂 |
08:46:26 | FromDiscord | <Elegantbeef> Lol so i was wrong anyway |
08:46:57 | FromDiscord | <Elegantbeef> `name` inside HTI still points to the current converted type's name |
08:53:05 | FromDiscord | <Phil> In reply to @abisxir "Hummm, so strange that": Note that "X of Y" will be true for all parts of the ancestral chain, so it'll be true for all parent classes AND your child class |
08:55:29 | FromDiscord | <Elegantbeef> Yea I dont think there is a runtime way of saying "Only this type, no parent or subtypes" |
08:56:39 | FromDiscord | <Phil> Hmm I mean it should be possible to build with x of y... well it would be if you could grasp all parents and sibling classes floating around in the context |
08:57:17 | FromDiscord | <Elegantbeef> You cannot do that of course |
08:57:53 | FromDiscord | <Phil> Then you can still do that in a specific case where you know the possible types at compiletime.... though I guess in that scenario you can also choose a different approach |
08:58:09 | FromDiscord | <Elegantbeef> Yea an object variant would be better there |
08:59:35 | FromDiscord | <Elegantbeef> Hmph i have to be wrong about not being able to get the base name |
09:00:14 | FromDiscord | <Elegantbeef> @ringabout any hacky way you know to get the name of a object converted to a parent type? |
09:00:33 | FromDiscord | <Elegantbeef> Figure given your work on the 2.0 dispatch you might know better than I 😄 |
09:49:17 | FromDiscord | <ringabout> I don't think there is an easy way. It needs to compile with `nimTypeNames`. Either use `importutils + privateAccess` to access name field or emit C code. |
09:50:51 | FromDiscord | <ringabout> Like https://github.com/status-im/nim-stew/blob/447b23d3bf6eb7be6531385e4db9124772c98068/stew/objects.nim#L70 |
09:50:53 | * | kenran joined #nim |
09:52:54 | FromDiscord | <Elegantbeef> Yea but that `name` field still fetches the name of the base not the child |
10:00:35 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4lZA |
10:00:58 | FromDiscord | <ringabout> prints "nim.test2.B:ObjectType" |
10:05:07 | FromDiscord | <Elegantbeef> @abisxir\: well there's a 'way' |
10:35:32 | * | om3ga quit (Read error: Connection reset by peer) |
10:36:46 | * | om3ga joined #nim |
11:04:48 | * | PMunch quit (Quit: Leaving) |
11:40:40 | FromDiscord | <justinn> sent a code paste, see https://play.nim-lang.org/#ix=4lZS |
11:41:43 | FromDiscord | <Rika> `p` is immutable; `addr` requires a mutable datatype |
11:43:39 | FromDiscord | <justinn> ahhh that does make a lot of sense, thanks! |
11:50:26 | FromDiscord | <Phil> nimble c is a thing?↵Huh |
11:52:05 | FromDiscord | <htac> salutations, can I have a template create a proc named by a string, or will I have to resort to a macro? |
11:56:18 | FromDiscord | <Hourglass [She/Her]> Even with a macro it's not that hard iirc |
11:56:24 | FromDiscord | <htac> sent a code paste, see https://play.nim-lang.org/#ix=4lZU |
11:56:35 | FromDiscord | <Hourglass [She/Her]> Yeah that'd be the macro code I think |
11:57:24 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lZV |
11:57:34 | FromDiscord | <htac> thank you, Hourglass |
12:01:13 | FromDiscord | <htac> sent a code paste, see https://play.nim-lang.org/#ix=4lZX |
12:02:33 | FromDiscord | <enthus1ast> sent a code paste, see https://paste.rs/1A9 |
12:02:35 | FromDiscord | <htac> how about this case? Obviously, this code does not work. But can I make it by a rather simple adujstment with quote, without falling back to working rather close to the AST? |
12:03:28 | FromDiscord | <htac> sent a code paste, see https://play.nim-lang.org/#ix=4lZZ |
12:04:10 | FromDiscord | <htac> (edit) "https://play.nim-lang.org/#ix=4lZZ" => "https://play.nim-lang.org/#ix=4m00" |
12:05:55 | FromDiscord | <Phil> In reply to @enthus1ast "<@180601887916163073>\: i think you": I'm wading my way through old jester code from somebody else that works under 1.6.10, just not 1.9.1 because I think the checks have gotten stricter |
12:06:46 | FromDiscord | <Phil> So it should work without the locks as well given that it worked before |
12:09:20 | FromDiscord | <Phil> God damn there is way too much global state in this code |
12:09:29 | FromDiscord | <Phil> Could've at least hidden it away in a separate module |
12:15:44 | FromDiscord | <enthus1ast> i think the lock is just for access control, the gcsafe make it compile |
12:18:35 | FromDiscord | <Phil> For now I'll focus on making it compile |
12:18:57 | FromDiscord | <Phil> It's a separate second step to refactor and in general reduce global state and introduce locks because by god |
12:19:10 | FromDiscord | <Rika> block {.gcsafe.} pragma iirc is equivalent to gcsafe cast |
12:19:14 | FromDiscord | <Phil> This thing has like 6 global state objects which all should be looked behind modules |
12:19:47 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m02 |
12:20:28 | FromDiscord | <Rika> no i mean the `{.gcsafe.}: ` is equivalentr to `{.cast(gcsafe).}:` its just an older version |
12:20:30 | FromDiscord | <Rika> iirc |
12:21:00 | FromDiscord | <Rika> i say block because proc use is different `proc ...(...) {.gcsafe.} =` |
12:21:24 | FromDiscord | <Phil> I'll try it out later, I recall having issues with just gcsafe in the past |
12:21:32 | FromDiscord | <Phil> first I'll get it to compile with what i know |
12:21:44 | FromDiscord | <Phil> (edit) "first I'll get it to compile with what i know ... " added "to work" |
12:23:10 | * | PMunch joined #nim |
13:04:08 | * | arkurious joined #nim |
13:20:06 | * | kenran quit (Remote host closed the connection) |
13:41:13 | * | azimut joined #nim |
13:42:14 | * | argonica joined #nim |
13:51:25 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m0e |
13:51:30 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4m0e" => "https://paste.rs/tuq" |
13:53:10 | * | argonica quit (Remote host closed the connection) |
13:54:49 | * | argonica joined #nim |
14:09:22 | FromDiscord | <Yasuke> when importing a text file and compiling it, it seems the executable still needs to be in the same location as the text file. Is there anyway to compile the project to include the text file so I can use the executable anywhere |
14:10:04 | FromDiscord | <Phil> In reply to @Yasuke "when importing a text": Static read is reading in a file at compile time |
14:10:12 | * | lumo_e joined #nim |
14:10:28 | FromDiscord | <Phil> That effectively causes it to be pulled into the binary into a variable |
14:10:38 | FromDiscord | <Yasuke> oooh how do I do this? |
14:10:48 | FromDiscord | <Yasuke> oh is ee |
14:10:54 | FromDiscord | <Yasuke> (edit) "is ee" => "i see thank you" |
14:10:57 | FromDiscord | <Phil> Check out staticRead for that, should be searchable in the docs |
14:11:10 | * | rockcavera joined #nim |
14:11:16 | FromDiscord | <Yasuke> just found! |
14:11:29 | FromDiscord | <Phil> It has the name I just gave as well as a weird alias, slurp I think |
14:16:21 | FromDiscord | <Yasuke> ok thank you |
14:21:26 | FromDiscord | <auxym> @Yasuke `const fileContents = staticRead("someFile.txt")` |
14:31:45 | FromDiscord | <Yasuke> thank you! |
15:09:21 | * | PMunch quit (Quit: Leaving) |
15:13:09 | FromDiscord | <pyryrin> how do i access the c files generated by nim? |
15:18:50 | FromDiscord | <auxym> In reply to @pyryrin "how do i access": They will be in nimcache: https://nim-lang.org/docs/nimc.html#compiler-usage-generated-c-code-directory |
15:19:32 | FromDiscord | <auxym> you can compile with eg. `--nimcache:nimcache` to create the files in the `./nimcache` dir inside your project, or something like that |
15:24:00 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1067102408469127179/image.png |
15:24:49 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1067102614187151400/image.png |
15:25:43 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1067102840620863568/image.png |
15:26:12 | FromDiscord | <pyryrin> where is nimbase.h located |
15:26:16 | FromDiscord | <Ntsékees> In spite of what this answer says, `m.get.captureBounds` doesn't work for me |
15:26:20 | FromDiscord | <Ntsékees> (edit) "me" => "me." |
15:26:58 | FromDiscord | <Ntsékees> (edit) "In spite of what this ... answer" added "StackOverflow" |
15:27:54 | FromDiscord | <Rika> In reply to @Ntsékees "In spite of what": Remove the get |
15:28:25 | FromDiscord | <Rika> Or actually the API for replace is completely different from the one on find I assume? |
15:33:05 | FromDiscord | <Ntsékees> removing `get` seems to improve things (but now I'm getting another error) |
15:33:37 | FromDiscord | <Ntsékees> (namely, ⟪Error: unhandled exception: index 2 not in 0 .. 1 [IndexError]⟫) |
15:34:14 | FromDiscord | <Ntsékees> Oj |
15:34:19 | FromDiscord | <Ntsékees> (edit) "Oj" => "Oh" |
15:34:33 | FromDiscord | <Ntsékees> (edit) "Oh" => "Oh, it was just a silly mistake of mine." |
15:34:43 | FromDiscord | <Ntsékees> Yes, removing `get` solves the problem. |
15:34:46 | FromDiscord | <Ntsékees> Thanks! |
15:43:08 | * | argonica quit (Remote host closed the connection) |
15:43:28 | * | argonica joined #nim |
15:54:58 | * | argonica quit (Remote host closed the connection) |
15:55:14 | * | argonica joined #nim |
16:21:17 | * | argonica quit (Quit: Leaving) |
16:42:12 | * | rockcavera quit (Remote host closed the connection) |
16:51:31 | FromDiscord | <auxym> In reply to @pyryrin "where is nimbase.h located": in the dir returned by this proc: https://github.com/EmbeddedNim/picostdlib/blob/master/src/piconim.nim#L102 |
17:01:49 | * | argonica joined #nim |
17:22:45 | FromDiscord | <Tuatarian> In reply to @Ntsékees "": what vscode theme is this? |
17:22:46 | FromDiscord | <Tuatarian> looks nice |
17:23:22 | FromDiscord | <Tuatarian> In reply to @Elegantbeef "Though `fields` doesnt work": is there a way to do this kind of thing with obj variants? |
17:23:38 | FromDiscord | <Tuatarian> well I guess I can literally just destroy all the fields |
17:23:56 | FromDiscord | <Tuatarian> or wait, no i can't right? |
17:23:59 | FromDiscord | <Elegantbeef> Use disruptek's assume |
17:24:05 | FromDiscord | <Elegantbeef> It has `typeIt` which lets you iterate fields of all objects |
17:24:19 | FromDiscord | <Tuatarian> I'd like to avoid external libs |
17:24:33 | FromDiscord | <Elegantbeef> Well then manually recreate the case statement |
17:25:25 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4m1m |
17:25:26 | FromDiscord | <Elegantbeef> Yes |
17:25:35 | FromDiscord | <Tuatarian> ok thanks |
17:27:08 | FromDiscord | <Tuatarian> and obviously, I should call `=destroy` on the discriminant itself afterwards |
17:28:12 | FromDiscord | <Elegantbeef> Is there a reason you're making a destructor? |
17:38:56 | * | rockcavera joined #nim |
18:00:03 | FromDiscord | <Phil> Anyone here that has developed on the nimforum a little bit? |
18:04:02 | FromDiscord | <enthus1ast> Elegantbeef\: in nimscripter, must i copy all the modules to the stblib folder? Or can i use the current installed nimble modules? |
18:04:45 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimscripter/blob/master/tests/tgeneral.nim#L150 |
18:14:52 | FromDiscord | <enthus1ast> then must i exportTo the procs? Or can i import in the script? |
18:15:31 | FromDiscord | <Elegantbeef> Search paths are used for the VM's importing |
18:15:49 | FromDiscord | <Elegantbeef> It's the nimscripter equivalent to `--nimblePath` |
18:16:15 | FromDiscord | <Elegantbeef> Adding nimble should make it so you can `import myNimblePackage` |
18:18:47 | FromDiscord | <Elegantbeef> Or not it seems 😄 |
18:19:45 | FromDiscord | <Elegantbeef> Does work |
18:19:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4m1z |
18:26:27 | FromDiscord | <enthus1ast> mh |
18:28:17 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4m1C |
18:29:10 | FromDiscord | <enthus1ast> i want to use the development version in my projects dir |
18:30:02 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m1D |
18:30:10 | FromDiscord | <Elegantbeef> `nimja/src` |
18:30:40 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m1E |
18:30:59 | FromDiscord | <enthus1ast> ok this changed the error message indeed |
18:31:45 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m1G |
18:32:06 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4m1G" => "https://play.nim-lang.org/#ix=4m1H" |
18:42:27 | FromDiscord | <enthus1ast> Mh why is this\:`Script Error: c:\users\david\.choosenim\toolchains\nim-1.6.10\lib\system\sets.nim:21:19 undeclared identifier: 'countBits64'` |
18:43:58 | FromDiscord | <Elegantbeef> I do not know |
18:46:01 | FromDiscord | <Elegantbeef> `countBits64` doesnt exist on the NimVm it seems |
18:46:14 | FromDiscord | <enthus1ast> yeah |
18:46:49 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/ebd1c678be5e0acee4fca67e1b7060234821ccf6/lib/system.nim#L2098 yep |
18:47:51 | FromDiscord | <federico3> https://blog.deckc.hair/2023-01-18-stop-building-on-corporate-controlled-languages.html |
18:50:54 | FromDiscord | <Elegantbeef> So i guess enthus you could make a PR to move that import into a `when notDefined(js)` |
18:51:57 | FromDiscord | <Nerve> Is there any way to convert JSON to a Datamancer DataFrame? Assuming a flat object topology of `"key": [array, ...]` pairs, I can't think of a way to switch the seq conversion of the JArray nodes on the data type of the elements. |
18:56:57 | FromDiscord | <Phil> In reply to @Nerve "Is there any way": Erm... I mean with jsony you can custom-write handlers that parse specific JSON structures into nim types, I assume a Datamancer DataFrame can be used as such? |
19:01:54 | FromDiscord | <enthus1ast> mhpf the nimvm feels much to fragile to be honest |
19:02:54 | FromDiscord | <Elegantbeef> Yea i mean wasm is just better 😄 |
19:07:24 | FromDiscord | <Nerve> In reply to @Isofruit "Erm... I mean with": Never mind, I figured it out. When unmarshalling JSON into a DataFrame, both are dynamic containers which can contain values of various types. The key is to not have an intermediate proc call which must then be typed. All the logic to unwrap the JSON arrays, convert to correctly typed seqs, and drop them into a new DataFrame must be within a single proc so there are no return type issues. |
19:08:02 | FromDiscord | <Nerve> I wanted to separate the concern of seq conversion to its own proc, but that may have been unwise, this way is much simpler. |
19:09:45 | FromDiscord | <Phil> Okay, so I figure out that the setup_nimforum file is failing with exit code 52 apparently |
19:09:57 | FromDiscord | <Phil> (edit) "Okay, so I figure out that the setup_nimforum file is failing with exit code 52 apparently ... " added "when executing" |
19:10:00 | FromDiscord | <Phil> No idea what that means |
19:10:02 | FromDiscord | <Elegantbeef> Phil always avoiding std/jsonutils 😄 |
19:10:21 | FromDiscord | <Phil> In reply to @Elegantbeef "Phil always avoiding std/jsonutils": 100% of the time |
19:10:28 | FromDiscord | <Phil> Just like I avoid building constructors 100% of the time |
19:10:37 | FromDiscord | <Phil> I dodge it like it's made of lethal poison |
19:11:07 | FromDiscord | <Phil> Now still, how the fuck is this script exiting with "52" as a returncode |
19:16:29 | FromDiscord | <Phil> Okay, this officially makes no sense↵I figured out that the thing that is leading to non zero exit codes is the echo/logging |
19:18:07 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4m1U |
19:18:22 | FromDiscord | <Phil> How is the exitCode dependant on the text that is being echo'd ?! |
19:20:43 | FromDiscord | <Phil> Is there a way to just force a nim binary to return exit code 0 even if this kind of echo nonsens is telling it otherwise? |
19:20:52 | FromDiscord | <Phil> Some kind of `setExitCode` ? |
19:22:41 | FromDiscord | <Phil> Found it, I can just force nim to shut up with wrong exit codes using `quit()` |
19:41:19 | om3ga | Hi! how one would set name of thread using system/threads? |
19:53:20 | FromDiscord | <Tuatarian> In reply to @Elegantbeef "Is there a reason": yes, the data structure is cyclic (each kid holds ref to parent) and I'd like to not use ARC |
19:53:23 | FromDiscord | <Tuatarian> ORC |
19:53:31 | FromDiscord | <Tuatarian> I'd like to use ARC |
20:01:38 | FromDiscord | <Phil> And just like that, we got a nimforum branch that can run on devel |
20:02:09 | FromDiscord | <Ntsékees> In reply to @iWonderAboutTuatara "what vscode theme is": It's not VSCode but Replit |
20:03:45 | FromDiscord | <Ntsékees> After a good hour of investigation on why a regexp didn't behave the same between Python and Nim, I concluded that `\s` captures non-breaking spaces with Python's `re` engine, but fails to do so with Nim's `nre`. |
20:10:36 | FromDiscord | <Tuatarian> oh I see |
20:12:49 | FromDiscord | <Tuatarian> if I have a nested object, and I want to kill the ref but not what it points to, how do I do that? |
20:13:02 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4m29 |
20:13:32 | FromDiscord | <Tuatarian> I would like to delete the ref n.parentalUnit, but not the parentalUnit itself |
20:14:22 | FromDiscord | <Tuatarian> if I call `=destroy n.parentalUnit` it will call this function recursively, right? |
20:14:32 | FromDiscord | <Tuatarian> I just want the field gone, not the data there (if that makes sense) |
20:15:07 | FromDiscord | <Tuatarian> before beef asks, the reason I'm writing a destructor at all is since the references to the children are cyclic and I would like to use ARC instead of ORC for collecting them |
20:21:10 | FromDiscord | <demotomohiro> `=destroy` is called when reference count is reached to 0. But if they are cyclic and you dont use ORC, ref count would never reach to 0 and `=destroy` is never called, isn' it? |
20:26:00 | FromDiscord | <Tuatarian> Yes, the idea is to kill it manually when I no longer need it |
20:26:21 | FromDiscord | <Tuatarian> I guess I don't need to call this thing `=destroy` then though |
20:26:35 | FromDiscord | <Tuatarian> Shouldn't make a difference either way right? |
20:26:50 | FromDiscord | <Tuatarian> Also, how do I delete the ref without deleting the data lmao |
20:32:45 | FromDiscord | <Elegantbeef> What? |
20:33:14 | FromDiscord | <Elegantbeef> The ref is heap allocated, if you kill the ref you lose the data, unless you move it to a different value |
20:34:36 | FromDiscord | <Elegantbeef> You do not need your own destructor here |
20:34:46 | FromDiscord | <Elegantbeef> The default destructor works fine |
20:37:24 | FromDiscord | <demotomohiro> I guess what @Tuatarian want is weak pointer so that `ASTNode` can have a reference to parent without cyclic. |
20:39:38 | FromDiscord | <Tuatarian> In reply to @Elegantbeef "The ref is heap": What the parentalunit field stores is a pointer to another ASTNode, right? |
20:40:12 | FromDiscord | <Tuatarian> How do I delete that pointer without deleting the thing it points to |
20:40:26 | FromDiscord | <Tuatarian> Ie, how do I clean up this ASTNode without touching anything else |
20:40:27 | FromDiscord | <Elegantbeef> You set the pointer to nil |
20:40:35 | FromDiscord | <Elegantbeef> Let Nim manage the memory |
20:41:27 | FromDiscord | <Tuatarian> Ok so in the `=destroy`, I do `n.parentalUnit = nil`? |
20:41:29 | FromDiscord | <Elegantbeef> That's the entire point of automatic memory management, you set a reference to nil and it cleans up if it's the last reference of it |
20:41:48 | FromDiscord | <Elegantbeef> I'm so confused |
20:42:07 | FromDiscord | <Tuatarian> The field itself is a pointer, the pointer is being stored somewhere in memory |
20:42:18 | FromDiscord | <Tuatarian> I wish to free that memory |
20:42:21 | FromDiscord | <Elegantbeef> The field is a reference |
20:42:48 | Amun-Ra | Tuatarian: you need custom =destroy only if you do alloc in init that's not traced by nim itself |
20:42:55 | FromDiscord | <Elegantbeef> What added behaviour are you adding to this destructor |
20:43:01 | FromDiscord | <Elegantbeef> You're remaking what nim already handles |
20:43:49 | FromDiscord | <Tuatarian> I need to also kill the children, which wouldn't happen by default since the parent holds a ref to them, and the parent doesn't get (automatically) freed since their children hold a ref to them |
20:43:57 | FromDiscord | <etra> sent a code paste, see https://play.nim-lang.org/#ix=4m2h |
20:44:06 | FromDiscord | <Elegantbeef> Orc handles cycle tuatara |
20:44:14 | FromDiscord | <Tuatarian> I don't want to use orc |
20:44:19 | FromDiscord | <Tuatarian> I know orc handles cycle |
20:44:25 | * | dv^_^ quit (*.net *.split) |
20:44:25 | * | Lord_Nightmare quit (*.net *.split) |
20:44:29 | * | blackbeard420 quit (*.net *.split) |
20:44:39 | Amun-Ra | so you more of elf's team |
20:44:40 | * | blackbeard420_ joined #nim |
20:44:43 | * | blackbeard420_ quit (Remote host closed the connection) |
20:44:44 | FromDiscord | <Elegantbeef> So then use `{.cursor.}` on the field |
20:44:55 | FromDiscord | <Elegantbeef> Since you dont want them incrementing the parent count i guess |
20:44:59 | * | blackbeard420 joined #nim |
20:45:04 | FromDiscord | <Tuatarian> What is that pragma? |
20:45:09 | * | dv^_^ joined #nim |
20:45:19 | * | Lord_Nightmare2 joined #nim |
20:45:20 | FromDiscord | <Elegantbeef> It's like a weak reference, it doesnt increment the counter of the reference |
20:45:33 | FromDiscord | <michaelb.eth> In reply to @iWonderAboutTuatara "What is that pragma?": https://nim-lang.org/docs/destructors.html#the-dotcursor-annotation |
20:46:10 | * | blackbeard420 quit (Remote host closed the connection) |
20:46:23 | * | blackbeard420 joined #nim |
20:46:29 | FromDiscord | <Tuatarian> Wasn't aware of this, thank you |
20:47:35 | FromDiscord | <Elegantbeef> I still dont see why you dont want to use orc |
20:47:43 | * | Lord_Nightmare2 is now known as Lord_Nightmare |
20:48:57 | FromDiscord | <Tuatarian> No good reason |
20:49:02 | FromDiscord | <demotomohiro> In reply to @etra "is this safe enough": It probably safe if Message is not ref/seq/string and you dont need to care about endianess. |
20:49:08 | FromDiscord | <Tuatarian> Want to get better at managing my memory |
20:49:30 | FromDiscord | <Tuatarian> Might be fun, might even be faster, at least in theory |
20:50:24 | FromDiscord | <Elegantbeef> Meh orc is plenty fast, it's better to not create cyclical garbage to begin with 😄 |
20:50:29 | FromDiscord | <Elegantbeef> Whether that's safe depends on what `newMessage` returns |
20:50:30 | FromDiscord | <demotomohiro> How about to turn off GC and manage all heap yourself for fun? |
20:50:34 | FromDiscord | <Elegantbeef> `newMessage` sounds like a reference |
20:50:52 | FromDiscord | <etra> In reply to @demotomohiro "It probably safe if": hmm now I wonder, the socket object receives a string buffer, is there a native way to convert some struct to a string with its bytes? |
20:50:56 | FromDiscord | <Tuatarian> Cyclical stuff is usually the best way to do trees |
20:51:52 | FromDiscord | <Tuatarian> Arrays/seqs might be faster, but they're much more painful and not really better when the size of the tree can change enormously, which is the case for what I'm doing |
20:51:53 | FromDiscord | <Elegantbeef> There is a send variant that uses `pointer, len` |
20:51:59 | FromDiscord | <Elegantbeef> so you can just do `send(myData.addr, sizeof(myData))` |
20:52:55 | FromDiscord | <Tuatarian> Just to confirm, I have a `var n = ASTNode(...)` as long as n is in scope, that's not going to ever get freed right? |
20:53:10 | FromDiscord | <Elegantbeef> Yes |
20:53:15 | FromDiscord | <Tuatarian> Ok thanks |
20:53:24 | FromDiscord | <Elegantbeef> It'd be dumb if it did get freed 😄 |
20:56:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4m2m |
20:57:14 | FromDiscord | <demotomohiro> In reply to @etra "hmm now I wonder,": There are `recv` and `send` that takes pointer and size:↵https://nim-lang.org/docs/net.html#recv%2CSocket%2Cpointer%2Cint↵https://nim-lang.org/docs/net.html#send,Socket,pointer,int↵So you can write `socket.recv(addr myObj, sizeof(myObj))`. |
21:07:17 | FromDiscord | <Tuatarian> In reply to @Elegantbeef "It'd be dumb if": Yeah it would, was just doing a sanity check lmao |
21:34:12 | arkanoid | I've ranamed my whole project folder and now I'm getting "Error: unhandled exception: packageparser.nim(344, 10) `fileExists(nf)` [AssertionDefect]". I've already edited nimble file accordingly, and deleted old cache folder. I don't know what else is missing |
21:34:40 | * | lumo_e quit (Ping timeout: 252 seconds) |
21:40:33 | arkanoid | I land here. I've renamed my nimble file too, so don''t know where is the problem https://github.com/nim-lang/nimble/blob/d13f3b8ce288b4dc8c34c219a4e050aaeaf43fc9/src/nimblepkg/packageparser.nim#L344 |
21:53:50 | arkanoid | got it, it was due to "Warning: The .nimble-link file is pointing to a missing file" |
22:33:42 | * | lumo_e joined #nim |
23:18:51 | * | argonica quit (Read error: Connection reset by peer) |
23:53:38 | FromDiscord | <hackeryarn> Hi, I am just starting out with nim. I got emacs mostly setup, but `flycheck-numsuggest`, the default checker always throws the above error. I've tried both stable and devel versions of nim with the same result. Has anyone else run into this? https://media.discordapp.net/attachments/371759389889003532/1067230659942289438/Screenshot_from_2023-01-23_17-44-00.png |