00:06:38 | FromDiscord | <!!sharpcdf!!> oh yea i guess i could just clear it before im finished with it |
00:06:54 | FromDiscord | <!!sharpcdf!!> in my case im running `illwillInit` and `illwillDeinit` several times |
00:07:54 | FromDiscord | <!!sharpcdf!!> weird, apparently im doing that already |
00:08:37 | FromDiscord | <!!sharpcdf!!> found a fix, had to place the clear in the loop, i was placing it after the loop |
00:51:56 | * | fallback quit (Quit: IRCNow and Forever!) |
00:59:21 | FromDiscord | <scipio> In reply to @T0lk1en "You guys in this": yup, I also appreciate a lot how helpful people in this Nim Discord are. |
00:59:45 | FromDiscord | <Elegantbeef> Except that beef guy, i hear he's a dick |
01:00:20 | FromDiscord | <scipio> Nah he's pretty decent too. Does have a sense of humour you need to be open to, and if you are, he's cool |
01:01:04 | FromDiscord | <scipio> If he tells you you're a scammer, just agree |
01:01:19 | FromDiscord | <Elegantbeef> Sounds like something a scammer would say |
01:03:00 | FromDiscord | <Rika> Beef is the most rude person you’d ever find in Canada |
01:03:12 | FromDiscord | <Elegantbeef> Sorry about that |
01:03:47 | FromDiscord | <Boston> Now did you say it sorry or sorry |
01:03:55 | FromDiscord | <scipio> In short, that Beef guy is pretty good. Yeah he's great/ He's like Jordan. Well he's not that good. He can misinterpret you. Or just give a plain wrong answer. He's pretty bad actually. He sucks. Booo @ElegantBeef |
01:04:00 | FromDiscord | <scipio> https://media.discordapp.net/attachments/371759389889003532/1063262099247210506/image.png |
01:04:09 | FromDiscord | <Elegantbeef> sore-y |
01:04:16 | FromDiscord | <Elegantbeef> Not sauri |
01:05:05 | FromDiscord | <scipio> Tauri not Sauri |
01:05:13 | FromDiscord | <Elegantbeef> We're not yanks we know how to say sorry |
01:05:22 | FromDiscord | <Elegantbeef> Nah i dont feel like stargate right now |
01:10:46 | * | fallback joined #nim |
02:13:10 | FromDiscord | <T0lk1en> Hey guys. I’m trying to take and array that holds data and “split it” in between places and stick new data there. |
02:13:41 | FromDiscord | <T0lk1en> Like if I have x = [1, 2, 4, 5] |
02:14:16 | FromDiscord | <T0lk1en> How could I make it where x = [1, 2, 9, 4, 5] |
02:14:26 | FromDiscord | <Rika> Has to be a sequence |
02:14:32 | FromDiscord | <T0lk1en> It is |
02:14:52 | FromDiscord | <T0lk1en> But how would I do it |
02:14:57 | FromDiscord | <Rika> Ah, sorry, array has a different connotation |
02:15:06 | FromDiscord | <T0lk1en> Mm gotcha |
02:15:21 | FromDiscord | <T0lk1en> I was just going for “universal programmer standard” syntax |
02:15:25 | FromDiscord | <Rika> There’s an insert procedure I believe in sequtils |
02:15:34 | FromDiscord | <T0lk1en> Aight lemme check it |
02:16:01 | FromDiscord | <Rika> Or maybe it was just in system, I don’t recall anymore |
02:16:20 | FromDiscord | <T0lk1en> Found it looks very helpful. |
02:16:29 | FromDiscord | <T0lk1en> It’s in system |
02:19:09 | FromDiscord | <T0lk1en> In reply to @Rika "There’s an insert procedure": Holy bro. You just made my life 100000 times easier |
02:22:39 | * | arkurious quit (Quit: Leaving) |
02:27:32 | FromDiscord | <Rika> Nice |
02:32:36 | FromDiscord | <T0lk1en> Yo Ik how to make a sequence equal to a string but how do I convert a sequence to a string |
02:32:57 | FromDiscord | <pyolyokh> `$theseq` |
02:33:16 | FromDiscord | <T0lk1en> Uhh could you give me an example?😅 |
02:33:22 | FromDiscord | <T0lk1en> Like |
02:33:32 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4l2G |
02:33:46 | FromDiscord | <T0lk1en> Aight |
02:37:08 | FromDiscord | <Rika> Tell us if this isn’t what you wanted lol because there’s two interpretations of what you said |
02:47:31 | * | deadmarshal_ quit (Quit: IRCNow and Forever!) |
02:54:49 | FromDiscord | <MadScientistCarl> If I debug Nim, can I step into C code? |
02:56:02 | FromDiscord | <Rika> Yeah but it won’t be pleasant I believe |
02:56:18 | FromDiscord | <MadScientistCarl> I mean if I use a C/C++ library |
02:56:25 | FromDiscord | <MadScientistCarl> Can I step into its source? |
02:56:46 | termer | you can |
02:56:51 | termer | it won't make much sense to you |
02:57:18 | termer | on linux systems, the C cache will be under ~/.cache/nim |
02:57:22 | termer | not sure where it would be on windows or another OS |
02:57:48 | FromDiscord | <MadScientistCarl> I don't mean the C generated by Nim. I mean step into the C/C++ library |
02:58:05 | termer | you mean interface with one? |
02:58:11 | termer | I'm not sure what you mean by stepping into the library |
02:58:54 | FromDiscord | <MadScientistCarl> Say I have a `liba.so`. This is an external library written in C, full with debug symbols and source. Now, I use this library in Nim. I would like to step into `liba`'s source, as well |
02:59:18 | FromDiscord | <Rika> Sure I think that’s possible |
02:59:25 | FromDiscord | <MadScientistCarl> Is it easy? |
02:59:47 | FromDiscord | <Rika> GDB has no knowledge that Nim code is Nim code, unless you configure it to |
03:03:01 | FromDiscord | <MadScientistCarl> ok |
03:08:15 | FromDiscord | <MadScientistCarl> Does nim have offline documentation? |
03:09:41 | * | deadmarshal_ joined #nim |
03:11:15 | FromDiscord | <Rika> Not sure |
03:11:26 | FromDiscord | <Rika> I think you can generate it yourself but I don’t know how |
03:11:35 | * | xet7 joined #nim |
03:11:44 | FromDiscord | <Rika> And I don’t know if it comes with it already generated either |
03:33:18 | FromDiscord | <j-james> try devdocs |
03:33:19 | FromDiscord | <j-james> https://devdocs.io/nim/ |
03:33:37 | FromDiscord | <j-james> it'll let you download them to your indexdb and then work offline |
03:34:18 | FromDiscord | <j-james> but i don't believe there's a `rustup docs` equivalent that i know of |
05:03:25 | * | rockcavera quit (Ping timeout: 260 seconds) |
05:04:41 | * | azimut quit (Ping timeout: 255 seconds) |
05:10:52 | FromDiscord | <Girvo> Anyone have any good references to using/managing inline assembly within Nim projects? I have vector instructions I want to use that don't have intrinsics at all (annoyingly). My idea is basically just write a .c/.h file with the inline assembly, and bind that from Nim, but figured I'd ask. (And as an aside, this is in a `--compileOnly` setup, sadly Nim isn't calling the C compiler directly [I hate CMake for this]) |
05:13:42 | FromDiscord | <pyolyokh> that or <https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma> should work. |
05:14:36 | FromDiscord | <Girvo> Oh yeah, I forgot about emit. That would be nicer frankly, unless we desperately need to call this from C as well -- but we've managed to remove _all_ first party C code from the project so adding more makes me sad haha |
05:15:26 | FromDiscord | <Girvo> Writing an `intrinsics.nim` module with a heap of emits would work well I reckon. Good call |
05:16:18 | FromDiscord | <pyolyokh> oh, there's also <https://nim-lang.org/docs/manual.html#statements-and-expressions-assembler-statement> |
05:16:59 | FromDiscord | <Girvo> Now _that_ is what I was looking for! I wonder how it plays with `--compileOnly`? I imagine it's codegen is just inline assembly itself, saving me from having to write that |
05:17:02 | FromDiscord | <Girvo> I'll test it out, dope |
05:17:04 | FromDiscord | <Girvo> Thanks mate |
05:18:46 | FromDiscord | <Girvo> As a complete aside, its still wild to me that the Xtensa LX7 we're using on this is a 24-bit instruction set lol |
06:45:05 | om3ga | wow, just noticed linter for vscode can lint nim.cfg |
06:45:22 | om3ga | accidentally typed --gc:cmake instead --gc:clang |
06:45:37 | om3ga | and it highlighted it |
06:46:38 | om3ga | not the "--gc", the "-cc" |
06:47:04 | om3ga | what about musl compiler option? would we have it in future as --cc parameter? |
06:47:39 | FromDiscord | <Elegantbeef> perhaps, no clue araq's view on it |
06:52:39 | om3ga | I hope he will agree :) only if absence of musl in osx will not cause the problem |
06:55:12 | om3ga | it can be compiled in osx anyway.. I remember they already had script for it... |
07:24:41 | FromDiscord | <jtv> What's the simplest way to test for whether I'm running code compile-time or not? |
07:25:26 | FromDiscord | <pyolyokh> <https://nim-lang.org/docs/manual.html#statements-and-expressions-when-nimvm-statement> |
07:25:50 | FromDiscord | <jtv> Perfect, thank you. |
07:26:50 | * | kenran joined #nim |
08:04:07 | FromDiscord | <enthus1ast> yes, all the module docs are in the toolchain folder (when you installed via choosenim)↵eg\: C\:\\Users\\david.choosenim\\toolchains\\nim-1.6.10\\doc\\html\\strutils.html↵(@MadScientistCarl) |
08:05:31 | FromDiscord | <enthus1ast> use them all the time while in train (germany has quite a lot dead spots) |
08:09:20 | FromDiscord | <christianl> Hi, I need to compile my code with different versions of the nim compiler (1.6 and latest devel). Unfortunately I have quite a lot of BareExcepts in third-party code, which I want to ignore if compiling with latest nim. But if I pass --warning\:BareExcept\:off, nim 1.6 fails with an "error\: unknown warning".↵How should I deal with this? Can I check for the nim version in config.nims somehow? How?↵Thank you. |
08:16:18 | FromDiscord | <pyolyokh> hmm, well there is a `NimVersion` constant |
08:17:51 | FromDiscord | <Elegantbeef> Yep that's the way to do it |
08:18:06 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4l3Q |
08:18:14 | FromDiscord | <Elegantbeef> `when (NimMajor, NimMinor) >= (1, 7): ...` |
08:18:23 | FromDiscord | <ringabout> There is also a define you can use |
08:18:37 | FromDiscord | <Elegantbeef> `nimHasBareExcept` i assume? |
08:18:59 | FromDiscord | <ringabout> yeah |
08:19:53 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4l3S |
08:21:49 | FromDiscord | <christianl> Great, thank you so much! |
08:22:48 | FromDiscord | <Elegantbeef> christian sadly matrix reacts do not land to those pesky discord users |
08:23:05 | FromDiscord | <Elegantbeef> the version of the bridge t2bot hosts doesnt have it |
08:23:32 | FromDiscord | <christianl> Thats not my problem 😜 but the thanks msg should have reached them neverthrless. |
08:42:24 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "perhaps, no clue araq's": Araq just expressed his dislike of replacing glibc |
08:44:59 | * | kenran` joined #nim |
08:46:29 | * | kenran quit (Ping timeout: 256 seconds) |
09:13:52 | FromDiscord | <christianl> Interstingly it is called\: nimHasWarnBareExcept but\: nimHasWarningImpicitTemplateRedefinition 🙈 |
09:39:44 | * | kenran` quit (Remote host closed the connection) |
10:00:51 | * | dv^_^ joined #nim |
10:57:42 | FromDiscord | <mratsim> In reply to @Girvo "Anyone have any good": use "asm": https://github.com/mratsim/finite-fields/blob/97e40060cefeb4e2ef5fc5a1c355977caae79674/add_carry.nim#L73-L91 |
11:02:19 | FromDiscord | <mratsim> and if you need significantly more inline assembly, I have implemented a compile-time macro-based inline assembler for x86 here you can use as inspiration: https://github.com/mratsim/constantine/pull/69 |
11:26:38 | * | PMunch joined #nim |
11:35:43 | PMunch | luteva, what exactly is it that you're trying to achieve with LSP? |
11:40:18 | Amun-Ra | is there a way to return from iterator early? something like python's raise StopIteration |
11:41:17 | Zevv | you can do just that, I guess |
11:41:22 | Zevv | rais something |
11:41:34 | Zevv | and put your for in a try: |
11:42:19 | Amun-Ra | the iterator has to have raises [] pragma |
11:43:07 | Amun-Ra | I reversed the logic and it works, but I was just curious |
11:43:10 | FromDiscord | <Rika> In reply to @Amun-Ra "is there a way": Return early is only achievable in iterators by hitting the end of the code block |
11:43:21 | FromDiscord | <Rika> So break out of your loops |
11:44:10 | Amun-Ra | I see, thank you |
11:45:24 | PMunch | Amun-Ra, you can just return as well.. |
11:45:34 | FromDiscord | <Rika> You can? I wasn’t aware |
11:45:39 | PMunch | Or maybe that's only closure iterators.. |
11:46:05 | Amun-Ra | PMunch: 'return not allowed here' |
11:47:09 | PMunch | Yeah, apparently that's only allowed for closure iterators for some reason: https://play.nim-lang.org/#ix=4l4D |
11:47:30 | PMunch | You can even have a return without a value |
11:48:45 | PMunch | Something like this works though: https://play.nim-lang.org/#ix=4l4E |
11:49:35 | PMunch | Of course in that case you could just break out of the for loop, but this is a more general solution (you could be multiple nested loops deep, or if you have two separate stages of your iterator it still works) |
11:52:01 | Amun-Ra | ah, block, iteresting |
12:01:54 | Amun-Ra | that's way better than reversing the logic, thanks PMunch |
12:12:13 | * | genpaku quit (Read error: Connection reset by peer) |
12:12:50 | PMunch | No problem, named block/break is a really under-appreciated feature :) |
12:12:54 | * | genpaku joined #nim |
12:42:53 | Amun-Ra | :> |
13:04:35 | FromDiscord | <luteva> In reply to @PMunch "<@954521401073754212>, what exactly is": I want to do "code visualization" and manipulation in a "kind of graph". it is not bound to a special language, so it is nice to be able to start different language servers fpr different programming languages and use them in the same manner (through the language sever protocol). |
13:05:10 | FromDiscord | <luteva> (edit) "fpr" => "for" |
13:10:57 | PMunch | Ooh, cool |
13:16:23 | FromDiscord | <luteva> 😄 |
13:16:46 | FromDiscord | <luteva> (edit) "😄" => "😃" |
13:35:51 | * | dnh joined #nim |
13:38:57 | * | argonica joined #nim |
13:40:16 | FromDiscord | <untoreh> does nim have something to override symbols from an imported C lib? |
13:43:52 | FromDiscord | <htac> Is there a way how I can prevent nimZeroMems (which are effectively memsets) from being applied to imported c++ objects? Not only are they unnecessary for classes/structs with a default constructor, they are also destructive since they mess with the internal representation which, for instance, will break std::string's char pointer, as I gather so far... |
13:46:39 | FromDiscord | <htac> on Nim's side, iterating over a for loop without indexing will partially fail, in comparison to a for i in 0 ..< loop . At least this seems to happen with my C++ codegen on MSVC |
13:48:30 | FromDiscord | <htac> see this e. g.: https://stackoverflow.com/questions/6877281/memset-structure-with-stdstring-contained |
13:49:53 | FromDiscord | <auxym> In reply to @untoreh "does nim have something": not sure what you mean by override symbols, but you can name your imported however you want in nim, like `var someVar: cint {.importc: "var_name_in_C"}` |
13:50:13 | FromDiscord | <auxym> (edit) "In reply to @untoreh "does nim have something": not sure what you mean by override symbols, but you can name your imported ... however"var_name_in_C".}`" added "symbols" | ""var_name_in_C"}`" => ""var_name_in_C".}`" |
13:56:41 | FromDiscord | <htac> I have isolated the issue here in this code snippet: https://discord.com/channels/371759389889003530/371759389889003532/1062700587835195475 |
14:07:32 | * | PMunch quit (Quit: Leaving) |
14:16:22 | * | azimut joined #nim |
14:39:59 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l5a |
14:46:26 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l5d |
14:47:29 | FromDiscord | <Rika> "nil" is a pointer with value 0 |
14:47:39 | FromDiscord | <Rika> What do you mean when you say you want a pointer to 0 |
14:48:19 | FromDiscord | <pyryrin> in which situations is it better to make a type a tuple rather than an object |
14:48:32 | FromDiscord | <Rika> In reply to @pyryrin "in which situations is": When you don’t want to make an object lol |
14:48:44 | FromDiscord | <enthus1ast> if you want to return it like this\:↵↵return ("foo", 1337) |
14:49:06 | FromDiscord | <pyryrin> i dont see any point for tuples other than multiple return values |
14:49:31 | FromDiscord | <enthus1ast> Tuples have unpacking for example |
14:50:08 | FromDiscord | <untoreh> In reply to @auxym "not sure what you": I want to override this `g_mmap_limit` but I don't think it's possible unless I recompile it, since it is not externed to C, and I am using leveldb through the `passl` flag↵https://github.com/google/leveldb/blob/fb644cb44539925a7f444b1b0314f402a456c5f4/util/env_posix.cc#L50 |
14:50:46 | FromDiscord | <4zv4l> In reply to @Rika "What do you mean": I just want NULL, but if `nil` is ok, then sure↵but I still get an error with my mmap and I don't see why↵any argument seems wrong ? |
14:50:58 | FromDiscord | <4zv4l> I changed the `fd` to `-1` also |
14:51:08 | FromDiscord | <Rika> nil is the same as NULL |
14:51:08 | FromDiscord | <4zv4l> `adr = mmap(nil, sizeof payload, PROT_READ or PROT_WRITE or PROT_EXEC, MAP_PRIVATE, -1, 0)` |
14:51:13 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4l5e |
14:51:37 | FromDiscord | <enthus1ast> this is not possible with objects |
14:51:47 | FromDiscord | <Rika> I am not familiar with mmap’s API and I don’t have time to familiarise |
14:53:50 | FromDiscord | <4zv4l> well now it works↵I can copy to it but not exec it seems xD |
14:53:58 | FromDiscord | <auxym> In reply to @untoreh "I want to override": yeah, if it's not accessible in C, it definitely won't be possible in nim |
14:54:56 | * | arkurious joined #nim |
15:07:03 | FromDiscord | <4zv4l> it works https://media.discordapp.net/attachments/371759389889003532/1063474262859591830/image.png |
15:07:05 | FromDiscord | <4zv4l> happy happy xD |
15:13:46 | FromDiscord | <4zv4l> I don't get why `const` array don't have 'addr' for Nim ? |
15:15:27 | FromDiscord | <auxym> In reply to @4zv4l "I don't get why": because consts are inlined at compile-time, they don't exist in memory at runtime |
15:15:32 | FromDiscord | <ambient> const is part of the program code, thus it won't have a heap address afaik |
15:15:58 | FromDiscord | <4zv4l> In reply to @auxym "because consts are inlined": it's in the rodata isn't it ? |
15:16:01 | FromDiscord | <4zv4l> just like literal string |
15:16:52 | * | dnh quit (Quit: Textual IRC Client: www.textualapp.com) |
15:17:37 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4l5y |
15:20:50 | FromDiscord | <4zv4l> In reply to @4zv4l "it works": hmmmm, alright so I can't set the array const ? |
15:22:14 | FromDiscord | <auxym> wdym? |
15:24:38 | FromDiscord | <auxym> you mean use `const` instead of `var` for payload? No, not if you want to use copymem. You can use `let` though for a runtime immutable value |
15:26:30 | FromDiscord | <4zv4l> they're all on the stack anyway right ?↵won't push it on the heap ? |
15:26:42 | FromDiscord | <4zv4l> since the size is known at compile time |
15:28:14 | FromDiscord | <auxym> yes, arrays are always on the stack |
15:28:34 | FromDiscord | <auxym> strings, seqs and `ref object`s only go on the heap |
15:29:17 | * | argonica quit (Quit: Leaving) |
15:29:20 | FromDiscord | <4zv4l> perfect, thank you ! |
15:42:31 | * | jmdaemon joined #nim |
16:09:35 | * | ehmry quit (Ping timeout: 260 seconds) |
16:10:50 | * | jmdaemon quit (Ping timeout: 272 seconds) |
16:16:31 | * | fallback quit (Remote host closed the connection) |
16:23:20 | * | jmdaemon joined #nim |
16:23:38 | FromDiscord | <MadScientistCarl> Are there any good editor support for Nim? There isn't one with basic rename supports |
16:27:38 | FromDiscord | <hotdog> In reply to @MadScientistCarl "Are there any good": Renaming symbols isn't supported by nimsuggest AFAIK, so you probably won't find any editors that can do it |
16:27:57 | FromDiscord | <hotdog> Most widely used editor for Nim is vscode with the nimsaem plugin |
16:29:26 | FromDiscord | <hotdog> If you are trying to find all instances of a symbol in a Nim project in order to rename them, Nimgrep (https://nim-lang.org/docs/nimgrep.html) might come in useful as it can search with style insensitivty |
16:29:30 | FromDiscord | <hotdog> (edit) "insensitivty" => "insensitivity" |
16:29:44 | FromDiscord | <MadScientistCarl> OK, though I don't think this works for renaming object fields |
16:30:04 | FromDiscord | <MadScientistCarl> In general, how well is Nim suited for real world programming now? |
16:31:51 | FromDiscord | <hotdog> In reply to @MadScientistCarl "OK, though I don't": Object fields are still just nim style insensitive symbols no? |
16:31:57 | * | ehmry joined #nim |
16:32:47 | FromDiscord | <hotdog> In reply to @MadScientistCarl "In general, how well": Depends what you mean by real world programming. There are several companies using it. The language is good, there's not a huge talent pool if you are hiring for a large company |
16:32:49 | FromDiscord | <choltreppe> Is there any kind of `arrayutils` package with all the goodies of `std/sequtils` (that are possible for arrays). I didnt find any on nimble, but maybe I didnt searched correctly |
16:33:03 | FromDiscord | <Gumbercules> In reply to @MadScientistCarl "In general, how well": What is real world programming? |
16:33:23 | FromDiscord | <Gumbercules> I think this is highly domain dependant |
16:33:42 | FromDiscord | <hotdog> sent a code paste, see https://play.nim-lang.org/#ix=4l5U |
16:33:53 | FromDiscord | <hotdog> Is there a proc you're trying to use that doesn't work for you with an array? |
16:34:08 | FromDiscord | <MadScientistCarl> In reply to @Gumbercules "What is real world": Let's say, writing quick CLI tools. Currently I use Go for this purpose. |
16:34:19 | FromDiscord | <Gumbercules> Yes it's ready for that |
16:34:25 | FromDiscord | <Gumbercules> And has been for years |
16:34:26 | FromDiscord | <hotdog> In reply to @MadScientistCarl "Let's say, writing quick": Nim is great for this. I use it for lots of cli tools myself |
16:34:59 | FromDiscord | <Gumbercules> Nim can do most things one would normally lean on language X for |
16:34:59 | FromDiscord | <MadScientistCarl> Are there "de facto" libraries for common tasks, like argument parsing, terminal UI, and maybe some GUI? |
16:35:11 | FromDiscord | <Gumbercules> Yes yes and yes |
16:35:59 | FromDiscord | <Gumbercules> I don't know about defacto - having choices and picking the best tool for the job is generally smiled upon I think. |
16:36:16 | FromDiscord | <choltreppe> In reply to @hotdog "From the top of": oh I missed that |
16:36:32 | FromDiscord | <MadScientistCarl> Or I should ask "stable and maintained" instead? |
16:36:42 | FromDiscord | <Gumbercules> If a Nim option doesn't exist, it's good that Nim has great C interop and not so great C++ interop |
16:37:34 | FromDiscord | <Gumbercules> No programming language has great cross platform GUI capabilities outside of C/C++ via qt |
16:37:48 | FromDiscord | <Gumbercules> And that's no panacea either |
16:37:56 | FromDiscord | <Gumbercules> It's not a programming language problem |
16:38:17 | FromDiscord | <MadScientistCarl> I understand that. But what about TUI? |
16:38:21 | FromDiscord | <Gumbercules> It's a problem created by operating system developers and their companies |
16:38:28 | FromDiscord | <auxym> In reply to @MadScientistCarl "Are there "de facto"": cligen and illwill, probably |
16:38:32 | FromDiscord | <Gumbercules> Yes Nim had nimwave for TUI I believe |
16:38:47 | FromDiscord | <Gumbercules> That's the most popular TUI lib tmk |
16:38:48 | FromDiscord | <auxym> the GUI situation in Nim is not great, IMO, unless you like GTK (gintro) |
16:38:54 | FromDiscord | <Gumbercules> It relies on illwill |
16:39:25 | FromDiscord | <Gumbercules> Well there are bindings to immediate mode GUI libraries |
16:39:36 | FromDiscord | <MadScientistCarl> I tried imgui but it's not statically linked |
16:39:43 | FromDiscord | <Gumbercules> Which I feel is the route most people end up going |
16:39:47 | FromDiscord | <MadScientistCarl> (I mean in Nim) |
16:39:53 | FromDiscord | <Gumbercules> I statically link it in my program |
16:40:15 | FromDiscord | <Gumbercules> But I also have my own bindings to most libraries I use |
16:40:33 | FromDiscord | <MadScientistCarl> It asks for `cimgui` library, which isn't present on my syste |
16:40:38 | FromDiscord | <MadScientistCarl> (edit) "syste" => "system" |
16:40:48 | FromDiscord | <Gumbercules> Probably need to build it yourself |
16:41:15 | FromDiscord | <Gumbercules> It's just a C99 API around dear imgui |
16:41:53 | FromDiscord | <MadScientistCarl> Yeah... every package I look at are like last commit months if not years ago |
16:45:26 | * | fallback joined #nim |
16:46:17 | * | fallback quit (Client Quit) |
16:51:11 | FromDiscord | <Gumbercules> Well if they're wrapping C libraries then they might not need to update that often |
16:51:36 | FromDiscord | <Gumbercules> And this is also why I recommend wrapping libraries yourself |
16:51:55 | FromDiscord | <Gumbercules> It's not hard. No one wants to be a maintainer of bindings |
16:52:07 | FromDiscord | <Gumbercules> (edit) "It's not hard. No one wants to be a maintainer of bindings ... " added "for other people." |
16:55:23 | FromDiscord | <enthus1ast> does someone know if the old donation system (salt) is defunct? |
16:55:24 | FromDiscord | <enthus1ast> salt / bountysource |
17:01:11 | * | jmdaemon quit (Ping timeout: 246 seconds) |
17:10:43 | * | jmdaemon joined #nim |
17:14:52 | FromDiscord | <pietroppeter> It appears so: https://github.com/nim-lang/website/issues/349 |
17:16:08 | FromDiscord | <pietroppeter> What’s the official take @narimiran ? |
17:17:54 | * | fallback joined #nim |
17:22:15 | FromDiscord | <pietroppeter> (There are also issues reported on PayPal broken and BTC address changed) |
17:25:37 | FromDiscord | <pyryrin> is there a performance difference between using `func` and `proc`? |
17:26:37 | FromDiscord | <m4ul3r> sent a long message, see http://ix.io/4l62 |
17:27:01 | FromDiscord | <jtv> No, I've mainly been doing import a except doSomething |
17:27:07 | FromDiscord | <jtv> You can still call a.doSomething |
17:29:04 | FromDiscord | <m4ul3r> i guess it would make sense, since it’s semantically identical to doSomething(a) |
17:35:17 | FromDiscord | <ezquerra> sent a long message, see http://ix.io/4l67 |
17:36:20 | FromDiscord | <MadScientistCarl> Does `std/db_sqlite` actually override `open`? Does that mean I can't open a regular file if I import this? |
17:41:09 | FromDiscord | <Phil> In reply to @MadScientistCarl "Does `std/db_sqlite` actually override": It doesn't and that's actually something that can only be done in very, very specific scenarios |
17:41:27 | FromDiscord | <MadScientistCarl> OK, I might be confused by the autocompletion |
17:41:58 | FromDiscord | <Phil> "Overriding" is the kind of thing that can happen when you have a fitting generic floating around and also an explicit proc, in that scenario the compiler will prefer the explicit proc over the generic |
17:42:23 | FromDiscord | <MadScientistCarl> Maybe I should say "shadow" instead of override |
17:42:25 | FromDiscord | <Phil> Generally when nim notices you have 2 procs with the same name and the same parameters, it'll throw a compiler error |
17:42:48 | FromDiscord | <MadScientistCarl> Ah, so procs can have the same name but different types? |
17:43:05 | FromDiscord | <jtv> 100% as long as those types don't conflict |
17:43:18 | FromDiscord | <Phil> Yeah, IIRC you can even have the same types and just different parameter names will do, I'd need to look that one up again |
17:43:38 | FromDiscord | <jtv> I don't think that's the case |
17:43:39 | FromDiscord | <Phil> Don't make use of that feature in particular so I'm flubby on that one |
17:46:03 | om3ga | I noticed nim does not like the numbers in fuctions and variable names |
17:46:26 | FromDiscord | <jtv> Not as the first character |
17:46:31 | FromDiscord | <jtv> No language does, it is ambiguous |
17:46:33 | om3ga | yes, as last |
17:46:58 | FromDiscord | <jtv> Well, I definitely have had numbers at the end of identifiers |
17:47:35 | om3ga | I had too, cant remember what exact case it was, but I had troubles with it |
17:47:57 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6b |
17:48:26 | FromDiscord | <jtv> And if you want to quote things, you can put basically anything in an identifier. Like I do a lot of : `let \`someVar?\` = blah` to represent an Option[someVar's type] |
17:48:38 | FromDiscord | <jtv> Ugh, discord's quoting sucks |
17:48:48 | FromDiscord | <jtv> let \`someVar?` = blah |
17:49:25 | FromDiscord | <MadScientistCarl> Ah |
17:49:56 | FromDiscord | <jtv> But `let argv0 = getAppName()` works just fine |
17:49:58 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/IDx |
17:49:59 | FromDiscord | <MadScientistCarl> Wait, that sounds like a terrible idea to have two functions distinguished just on mutability |
17:50:16 | * | jmdaemon quit (Ping timeout: 272 seconds) |
17:50:22 | FromDiscord | <jtv> Wow, that I really don't like. |
17:50:34 | FromDiscord | <MadScientistCarl> How would the compiler actually decide if it is x, or z, or var x? |
17:50:39 | FromDiscord | <Phil> The only reason it works is because of the explicit parameter assignment |
17:50:41 | FromDiscord | <jtv> Wonder how many times I've written the same function twice without noticing it |
17:50:47 | FromDiscord | <jtv> Yeah, the call site |
17:51:00 | FromDiscord | <jtv> And which one takes priority if you don't name the call site's variable x or z?? |
17:51:04 | FromDiscord | <jtv> Yuck |
17:51:23 | FromDiscord | <Phil> In reply to @MadScientistCarl "How would the compiler": by saying `print(x = x)` you say "the parameter named x should get the value of the variable x defined in this scope" |
17:51:29 | FromDiscord | <Phil> If you don't do this you get a compiler error |
17:51:34 | FromDiscord | <Phil> Because the compiler can't know which proc to choose |
17:52:03 | FromDiscord | <jtv> That's one of nim's uglier features, wow |
17:52:07 | FromDiscord | <Phil> By giving it `print(x=x)` you are revealting to the compiler that you mean a proc with the name "print" that must have only the parameter "x" |
17:52:16 | FromDiscord | <Phil> (edit) "revealting" => "revealing" |
17:52:19 | FromDiscord | <Phil> So it can figure it out again |
17:52:25 | FromDiscord | <Phil> In reply to @jtv "That's one of nim's": Yeah I don't make use of it either |
17:53:13 | FromDiscord | <jtv> I think the mutability overload is not great either, per @MadScientistCarl . Plenty of potential for unexpected semantics |
17:53:17 | FromDiscord | <Phil> I basically do it the way I've known it from java:↵Allow procs of the same name, as long as they have different types we're gucci |
17:53:32 | FromDiscord | <Phil> (edit) "I basically do it the way I've known it from java:↵Allow procs of the same name, as long as they have different types ... we're" added "or different order of types or different numbers of parameters" |
17:54:46 | FromDiscord | <Phil> In webdev I managed to get away with not running into issues around procs that do var or not var by just avoiding ref-types, which works for the most part...except for the ORM >_> |
17:55:10 | FromDiscord | <MadScientistCarl> And is this documented anywhere? |
17:55:44 | FromDiscord | <jtv> Yeah, it all tends to be briefly documented SOMEWHERE, but nothing about the documentation is great for an on-ramp. It's more focused on being a reference |
17:55:47 | FromDiscord | <MadScientistCarl> This sounds like something that should _really_ be written in a -nomicon book |
17:57:42 | * | rockcavera joined #nim |
17:58:43 | FromDiscord | <MadScientistCarl> So how does the compiler dispatch on var vs immutable? What if I have a `var x` and a pair of procedure `f(var x)` and `f(x)`, and I want to treat `x` as immutable because the first one writes to it? |
17:59:10 | FromDiscord | <jtv> It's based on the mutability of what you're passing in |
17:59:29 | FromDiscord | <jtv> ie, whether you declared it var or (let | const) |
17:59:37 | FromDiscord | <MadScientistCarl> Can I turn a `var` into a constant? |
17:59:57 | FromDiscord | <jtv> Meaning, change it from mutable to non-mutable?? |
18:00:00 | FromDiscord | <MadScientistCarl> You know, in Rust I can pass a mutable reference into a shared reference. Like "downgrading" it. |
18:00:05 | FromDiscord | <MadScientistCarl> Yes. |
18:00:07 | FromDiscord | <jtv> Constant means compile time here |
18:00:40 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6f |
18:01:09 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6h |
18:02:57 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6i |
18:03:10 | FromDiscord | <MadScientistCarl> No, that is not what I mean |
18:03:14 | FromDiscord | <MadScientistCarl> Let me give an example |
18:05:19 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l6m |
18:05:28 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6n |
18:05:35 | FromDiscord | <Phil> Which is what the reassignment does |
18:06:09 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4l6n" => "https://play.nim-lang.org/#ix=4l6o" |
18:06:35 | FromDiscord | <MadScientistCarl> Would copies be expensive for objects? |
18:06:49 | FromDiscord | <MadScientistCarl> Or do they point to the same object? |
18:06:51 | FromDiscord | <Phil> Depends on multiple factors, gimme a sec |
18:08:03 | FromDiscord | <Phil> Nim distinguishes both ref types and value types.↵If your object is a value type, it'll only be in stack-memory and copying it will be fairly fast.↵If the object itself is massive (say that one object takes up several kilo/megabytes of RAM), that could become a problem when you copy a lot. |
18:10:59 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6q |
18:11:15 | FromDiscord | <MadScientistCarl> Ah, I will go look up muse |
18:11:19 | FromDiscord | <MadScientistCarl> (edit) "muse" => "myself" |
18:11:57 | FromDiscord | <MadScientistCarl> I see nim by example uses `` in its object definition. Is that like a pointer? |
18:12:36 | FromDiscord | <Phil> No, `` always is the export symbol.↵On an object field it means that this field is not private |
18:12:45 | FromDiscord | <MadScientistCarl> Oh |
18:13:06 | FromDiscord | <Phil> If that object field doesn't have `` and you use that object in another module and try to access that field you'll get a compiler error, without `` it's private |
18:33:15 | FromDiscord | <jtv> Generally, I'm told Nim will be pretty lazy about copying, meaning even if your parameter isn't a 'var' parameter, no copy is likely to happen unless you assign |
18:42:47 | FromDiscord | <MadScientistCarl> When should I use `ref object` in type declaration? |
18:43:42 | FromDiscord | <jtv> That's a matter of style and personal preference to a large degree. The language is smart enough to avoid lots of copying, but many people come from languages where objects have reference semantics by default |
18:43:55 | FromDiscord | <<She>Horizon</Her>> Just had an amazing idea for a small game idea :) |
18:44:10 | FromDiscord | <MadScientistCarl> If I declare just `type A = object`, I am able to use `ref A` elsewhere. But if I declare `type A = ref object`, can I get otherwise? |
18:44:12 | FromDiscord | <<She>Horizon</Her>> Well, programming project |
18:44:15 | FromDiscord | <<She>Horizon</Her>> Snake in the terminal |
18:44:20 | FromDiscord | <jtv> So if you are used to mutable objects that people hold pointers to, use a ref object |
18:44:28 | FromDiscord | <MadScientistCarl> I see |
18:45:03 | FromDiscord | <etra> sent a code paste, see https://paste.rs/AOf |
18:45:21 | FromDiscord | <jtv> Well, it's clunky to go back and forth between the two explicitly, and it's not something you should need to do commonly., anyway |
18:45:23 | FromDiscord | <etra> (edit) "https://play.nim-lang.org/#ix=4l6w" => "https://play.nim-lang.org/#ix=4l6v" |
18:45:24 | FromDiscord | <etra> (edit) "https://play.nim-lang.org/#ix=4l6v" => "https://paste.rs/uIa" |
18:47:33 | * | jjido joined #nim |
18:48:08 | FromDiscord | <MadScientistCarl> How can I store a closure/lambda/etc in a field? |
18:48:29 | FromDiscord | <MadScientistCarl> It seems to have syntax error...? |
18:49:26 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6z |
18:49:37 | FromDiscord | <Phil> Basically [] is the dereferencing operator |
18:49:45 | FromDiscord | <MadScientistCarl> Ah, OK. Missed that part |
18:50:23 | FromDiscord | <Phil> In reply to @MadScientistCarl "How can I store": One sec, do you want to have OOP dynamic dispatch or do you just happen to want to throw a proc into an object? |
18:50:34 | FromDiscord | <MadScientistCarl> I want to store a proc into an object |
18:50:51 | FromDiscord | <MadScientistCarl> Nim says "first class functions", so I think this should be possible? |
18:50:56 | FromDiscord | <Phil> For OOP you can define `method`s, if you're not chasing after the OOP paradigm you can just define a proc-type same as a proc declaration and assign to it |
18:51:01 | FromDiscord | <Phil> One sec, let me cook up an example |
18:51:19 | FromDiscord | <jtv> It is, I do it all the time. Assignment generally works, but the calling convention is kind of a part of the type |
18:51:56 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l6A |
18:52:16 | FromDiscord | <jtv> Yes, and there's a module "sugar" to help you write more natural type signatures |
18:52:29 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4l6B |
18:52:50 | FromDiscord | <<She>Horizon</Her>> It'll accept a proc with one parameter with `int`, and a return type of int |
18:52:59 | FromDiscord | <<She>Horizon</Her>> Name is irrelevant |
18:53:00 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l6C |
18:53:03 | FromDiscord | <MadScientistCarl> With sugar |
18:53:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6D |
18:53:17 | FromDiscord | <<She>Horizon</Her>> Unsure about that one, don't use the sugar module |
18:53:50 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6E |
18:54:05 | FromDiscord | <jtv> Notice it's expecting a closure there. You can do: `x = myfunc`, but if myfunc is a proper proc, it's not a closure by default, it's a 'nimproc'. Usually the language automatically deals w/ it, but I've run into cases where it does NOT |
18:54:11 | FromDiscord | <MadScientistCarl> Is it true that I don't have to include the `std/` part of the import? |
18:54:28 | FromDiscord | <<She>Horizon</Her>> Yeah, but I'd say it's better for clarity |
18:54:30 | FromDiscord | <Phil> In reply to @MadScientistCarl "Is it true that": It is true, but for clarity of the imports personally I'd recommend using them |
18:54:40 | FromDiscord | <Phil> and use `./` for importing from your own project |
18:55:05 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4l6F |
18:55:15 | FromDiscord | <<She>Horizon</Her>> In reply to @Minaaa <3 "If you have multiple": (can also have it on a single line but i prefer this) |
18:55:23 | FromDiscord | <Phil> Personally I do `import std/[strutils, sugar]` |
18:55:25 | FromDiscord | <jtv> Yeah, I've also seen cases where, for less common modules, I'd get an error w/o the std/ |
18:56:11 | FromDiscord | <Phil> In reply to @jtv "Yeah, I've also seen": IIRC the std/ thing wasn't there from the start, so comparatively newer modules don't have a non-std link or whatever enables the import behaviour |
18:56:52 | FromDiscord | <<She>Horizon</Her>> Does Nim have a way to make fields in types read only, once the object has been initialised? |
18:57:56 | FromDiscord | <<She>Horizon</Her>> In reply to @Isofruit "Personally I do `import": Fair, i typically try to annotate the reason for why I'm importing each module though, which is why i prefer spreading it between lines |
18:57:59 | FromDiscord | <<She>Horizon</Her>> Helps for refactoring |
18:58:01 | FromDiscord | <jtv> No, it lacks a 'once' type capability for fields and functions both. 'let' is kind of like that for variables. |
18:58:24 | FromDiscord | <Phil> In reply to @Minaaa <3 "Fair, i typically try": Actually a solid idea, "import comments" in a sense |
18:58:47 | FromDiscord | <Phil> In reply to @jtv "No, it lacks a": I'd argue that it kind of does by keeping fields private |
18:58:56 | FromDiscord | <Phil> Assuming you don't provide procs that can mutate the field |
18:59:10 | FromDiscord | <<She>Horizon</Her>> In reply to @jtv "No, it lacks a": Sad, i wonder if a macro could be made for this? |
18:59:24 | FromDiscord | <<She>Horizon</Her>> It'd just mark the field as private but have an accessor proc |
18:59:35 | FromDiscord | <jtv> Yeah, of course. I do find the whole oberon-style visibility a bit inflexible, unobvious and clunky 🙂 |
18:59:54 | FromDiscord | <Phil> In reply to @Minaaa <3 "It'd just mark the": You'd need to code in the logic under which access is acceptable and when not |
18:59:59 | FromDiscord | <Phil> Which can be ugly to read |
19:00:00 | FromDiscord | <<She>Horizon</Her>> In reply to @Isofruit "Actually a solid idea,": Yep! I have many bad habits, better to at least try to make it clear xD |
19:00:03 | FromDiscord | <gibson> I decided to ask on the forum instead, since it was big. But my question is↵> How do you use Nim to incrementally convert a C or C++ project with the least friction?↵https://forum.nim-lang.org/t/9820#64780 |
19:00:28 | FromDiscord | <Phil> And you'd need to accept that you can only notice those access violations at runtime |
19:00:56 | FromDiscord | <MadScientistCarl> I wonder if you can do program analysis in macros |
19:01:00 | FromDiscord | <<She>Horizon</Her>> In reply to @Isofruit "You'd need to code": Write context lock could be similar to what importutils do, maybe? And read access should be everywhere |
19:01:26 | FromDiscord | <<She>Horizon</Her>> In reply to @Isofruit "And you'd need to": That's not a bad thing, is it? Plus, `-d:danger` exists for the brave who'd want to turn them off haha |
19:01:33 | FromDiscord | <Phil> In reply to @MadScientistCarl "I wonder if you": What kind of analysis do you want to do? |
19:01:59 | FromDiscord | <MadScientistCarl> Nope, just commenting if it is possible to use macro to implement the initialize-once thing |
19:02:20 | FromDiscord | <Phil> Because I used compile-time procs to do e.g. a fair bit of compile-time validation for an ORM whether an attempt to query a many-to-many relationship was valid or not |
19:02:22 | FromDiscord | <MadScientistCarl> I guess you can use getters and private fields... |
19:02:30 | FromDiscord | <jtv> I mean, for function calls yes, easily |
19:02:35 | FromDiscord | <jtv> And I have a macro like that |
19:02:51 | FromDiscord | <jtv> But I don't see how you would do it for arbitrary fields. |
19:03:03 | FromDiscord | <jtv> Not saying there isn't a way, I'm a relative nim newbie too |
19:03:08 | FromDiscord | <Phil> In reply to @Minaaa <3 "That's not a bad": Imo runtime errors are bad always and ever and should be avoided, the thing is that very often they can't be avoided |
19:03:52 | FromDiscord | <Phil> In order of badness from least to worst:↵Compile time error > Startup error > Runtime error↵I'll eat any of the first 2 happily, runtime errors I dislike with a passion because they have the capacity to be some of the most annoying assholes this side of the sun |
19:03:52 | FromDiscord | <<She>Horizon</Her>> Don't things like seqs have runtime checking? |
19:04:14 | FromDiscord | <<She>Horizon</Her>> And it's possible to turn it off with the danger flag? |
19:04:33 | FromDiscord | <Phil> Ah, that's separate from my gripe with runtime errors |
19:04:41 | FromDiscord | <Phil> And yeah they do, basically they do overflow checking IIRC |
19:04:48 | FromDiscord | <Phil> Actually, I might as well try this out |
19:04:52 | FromDiscord | <jtv> Yeah they do |
19:05:13 | FromDiscord | <<She>Horizon</Her>> In reply to @Isofruit "Ah, that's separate from": Also, why couldn't you make it a compile time error with some hacking? |
19:05:14 | FromDiscord | <jtv> That's pretty unavoidable unless you like crashes. You certainly cannot detect arbitrary array index errors statically |
19:05:46 | FromDiscord | <jtv> There will be programs where such an analysis cannot give an accurate result |
19:05:53 | FromDiscord | <<She>Horizon</Her>> Hm fair |
19:06:30 | FromDiscord | <MadScientistCarl> Can I not do `./[a, b]`? I get error saying file not found |
19:06:40 | FromDiscord | <jtv> No, that you cannot do |
19:06:43 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4l6J |
19:07:23 | FromDiscord | <<She>Horizon</Her>> Is that still not fixed in Nim 2.0? |
19:07:27 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4l6J" => "https://play.nim-lang.org/#ix=4l6K" |
19:07:32 | FromDiscord | <<She>Horizon</Her>> I remember that irritated me so much xD |
19:07:34 | FromDiscord | <Phil> The thing that it crashes at runtime for overflow? |
19:07:43 | FromDiscord | <<She>Horizon</Her>> No the `.` with multiple imports |
19:07:51 | FromDiscord | <jtv> Well it might be in 2.0 |
19:08:03 | FromDiscord | <<She>Horizon</Her>> In reply to @MadScientistCarl "Can I not do": You could do `"."` instead of `.`? |
19:08:12 | FromDiscord | <<She>Horizon</Her>> That seems to work for me |
19:08:13 | FromDiscord | <Phil> I'm on `1.9.1`, I wouldn't get my hopesup |
19:08:17 | FromDiscord | <<She>Horizon</Her>> Even if it feels gross |
19:08:24 | FromDiscord | <jtv> There have been so many changes and so many mem management issues I have stopped trying to keep my code working in both places until 2.0 stabilizes |
19:08:34 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4l6M |
19:08:45 | FromDiscord | <<She>Horizon</Her>> In reply to @jtv "There have been so": Totally understandable, probably a pain lol |
19:08:55 | FromDiscord | <Phil> Ohhh wait, you don't mean import for std lib like that but imports of your own stuff like that? |
19:08:56 | FromDiscord | <Phil> one sec |
19:09:05 | FromDiscord | <<She>Horizon</Her>> Yep |
19:09:17 | FromDiscord | <Phil> Nope, still crashes on 1.9.1 |
19:09:24 | FromDiscord | <<She>Horizon</Her>> Could hack into dot operators possibly? |
19:09:31 | FromDiscord | <<She>Horizon</Her>> But that's probably way less than ideal |
19:09:38 | FromDiscord | <<She>Horizon</Her>> Not probably, definitely lmao |
19:09:54 | FromDiscord | <MadScientistCarl> Isn't nim's latest version like 1.6? |
19:10:02 | FromDiscord | <Phil> In reply to @MadScientistCarl "Isn't nim's latest version": I'm on the devel branch of the compiler |
19:10:05 | FromDiscord | <<She>Horizon</Her>> In reply to @MadScientistCarl "Isn't nim's latest version": That's latest stable |
19:10:13 | FromDiscord | <Phil> 1.6.10 is basically official releases |
19:10:19 | FromDiscord | <MadScientistCarl> OK |
19:10:24 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
19:10:30 | FromDiscord | <Phil> Being on the devel compiler is like being on arch |
19:10:33 | FromDiscord | <Phil> (edit) "Being on the devel compiler is like being on arch ... " added "linux" |
19:10:53 | FromDiscord | <MadScientistCarl> Arch is actually fine |
19:10:55 | FromDiscord | <Phil> Except that arch has been somewhat more stable for me than the compiler 😛 |
19:11:27 | FromDiscord | <jtv> I still use 1.6.10 yes |
19:11:30 | FromDiscord | <Phil> Yeh, most of the time, has some oddities like that application behaviour gets wonky after updates sometimes but nothing a good reboot can't fix |
19:12:09 | FromDiscord | <MadScientistCarl> Hmmm, can I do `import ./a/[b,c,d]`? |
19:12:21 | FromDiscord | <Phil> Yes |
19:13:08 | FromDiscord | <Phil> Example of this kind of thing from my own application:↵`import ../utils/[jwtContext, customResponses, errorResponses, databaseUtils]` |
19:13:26 | FromDiscord | <MadScientistCarl> Do folders have any meaning for Nim? |
19:13:53 | FromDiscord | <Phil> they are part of the path.↵"utils" in my example is a folder for example |
19:14:11 | FromDiscord | <Phil> Beyond that, not really |
19:14:14 | FromDiscord | <MadScientistCarl> So there is no `init.py` or `mod.rs` equivalent? |
19:14:27 | FromDiscord | <jtv> No 😦 |
19:14:51 | FromDiscord | <Phil> Not enforced in any meaningful way.↵You can abide by that pattern yourself but it's not going to be as pretty |
19:14:51 | FromDiscord | <jtv> People basically tend to write newMyType() functions that instantiate and do initialization |
19:15:10 | FromDiscord | <Phil> In reply to @jtv "People basically tend to": I would like to very explicitly and strongly point out I use constructor |
19:15:22 | FromDiscord | <jtv> You're finding a lot of warts fast tho 🙂 |
19:15:46 | FromDiscord | <Phil> Because there is no way in the seven hells I'm writing constructor procs myself for 60+ model object types |
19:16:07 | FromDiscord | <Phil> Ain't nobody got time for that but beef's macro code that generates those procs for me |
19:17:28 | FromDiscord | <Phil> https://github.com/beef331/constructor For those not aware of it yet |
19:18:31 | FromDiscord | <Phil> Nim has a way to default initialize object in nim2.0, which is a pretty cool feature all things considered, but it still breaks for my very specific usecase so I'm still using constructor |
19:19:00 | FromDiscord | <Phil> That specific usecase being I have a distinct type of `DateTime`, if you don't have that you're good |
19:28:59 | FromDiscord | <<She>Horizon</Her>> ~~I should comment everything i do in my conlang now~~ |
19:29:01 | FromDiscord | <<She>Horizon</Her>> Oh my god that'd actually be kinda funny |
19:29:16 | FromDiscord | <Phil> conlang? |
19:29:37 | FromDiscord | <<She>Horizon</Her>> Constructed language |
19:29:46 | FromDiscord | <<She>Horizon</Her>> Basically a language I've thought up and stuff |
19:29:56 | FromDiscord | <<She>Horizon</Her>> With its own quirks and such |
19:30:05 | FromDiscord | <<She>Horizon</Her>> (Spoken language, btw) |
19:30:10 | FromDiscord | <<She>Horizon</Her>> (Like English and others) |
19:31:49 | FromDiscord | <MadScientistCarl> Is there a Nim formatter? |
19:32:35 | FromDiscord | <<She>Horizon</Her>> `nimpretty` but uh, from experience it's a wee bit broken |
19:32:40 | FromDiscord | <jtv> Yeah, it sucks |
19:33:02 | FromDiscord | <jtv> I stopped using it, I hate the formatting it does, and it's almost entirely NON configurable |
19:33:30 | FromDiscord | <jtv> It's crazy there isn't something better considering how w/ Nim it's easy to parse Nim 🙂 |
19:33:51 | FromDiscord | <MadScientistCarl> I wish every language has an LSP as good as Go's |
19:33:58 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4l6S |
19:34:05 | FromDiscord | <<She>Horizon</Her>> It keeps indenting it iirc |
19:34:23 | FromDiscord | <<She>Horizon</Her>> Did when i used it at least, let me check if it's still the case |
19:34:42 | FromDiscord | <jtv> Yeah, I've had some weird fights with it. Now as I go through old code I just manually format and wait until the day that I crack and write my own |
19:35:34 | FromDiscord | <<She>Horizon</Her>> Hm not an issue anymore |
19:35:42 | FromDiscord | <<She>Horizon</Her>> In reply to @jtv "Yeah, I've had some": Pfff fair |
19:36:31 | FromDiscord | <jtv> I had one file where it wouldn't respect my indent choice, full stop, no matter what almost. No clear reason why |
19:36:43 | FromDiscord | <jtv> And that's like the ONE thing you can configure |
19:38:50 | FromDiscord | <jos> is there a stable/popular image loading library in pure nim? |
19:39:49 | FromDiscord | <<She>Horizon</Her>> In reply to @jtv "I had one file": Yeah that's what i had the issue with, no idea why xD |
19:39:56 | FromDiscord | <<She>Horizon</Her>> In reply to @jos "is there a stable/popular": I think it's called Pixi? |
19:41:22 | FromDiscord | <tfp> interesting |
19:41:23 | FromDiscord | <tfp> pixie looks cool |
19:41:41 | FromDiscord | <tfp> kind of overkill for just loading images but the other features look useful too |
19:42:29 | FromDiscord | <MadScientistCarl> How do I take the object out of a `distinct` type? |
19:43:19 | FromDiscord | <<She>Horizon</Her>> In reply to @MadScientistCarl "How do I take": You can just cast it to the original |
19:43:29 | FromDiscord | <<She>Horizon</Her>> So `myDistinct.OriginalType` |
19:43:40 | FromDiscord | <<She>Horizon</Her>> Can also do `OriginalType(myDistinct)` |
19:43:53 | FromDiscord | <<She>Horizon</Her>> Or even `OriginalType myDistinct` |
19:44:00 | FromDiscord | <<She>Horizon</Her>> I prefer the first though for most situations |
19:44:01 | FromDiscord | <MadScientistCarl> Oh OK |
19:50:05 | FromDiscord | <Phil> In reply to @MadScientistCarl "Oh OK": That is basically type-casting, it works in an identical capacity when e.g. casting int32 to int64 or vice versa |
19:51:30 | FromDiscord | <MadScientistCarl> Hmm, the borrow pragma doesn't seem to work for comparison |
19:53:11 | FromDiscord | <Phil> Does for me for the most time, can you provide a minimal example? |
19:54:30 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l72 |
19:57:57 | Zevv | The operator is `<` |
19:58:05 | Zevv | the others are derived from that |
19:59:06 | FromDiscord | <MadScientistCarl> OK |
19:59:09 | Zevv | you need to borrow `<` and `<=`, you will get `>` and `>=` for free |
19:59:16 | FromDiscord | <MadScientistCarl> Yeah, it works |
19:59:16 | Zevv | the manual might not be explicit on that I think |
20:00:02 | FromDiscord | <Phil> Yeah that is the kind of implicit gotcha that I typically cuss out java for |
20:17:41 | * | krux02_ quit (Remote host closed the connection) |
21:02:42 | FromDiscord | <pyolyokh> the manual mentions that >= are templates (system/comparisons), but doesn't mention that the borrow pragma cares either way, and the error I don't get at all in this case. |
21:04:16 | FromDiscord | <pyolyokh> I think it should at least suggest that templating is a problem, and at best should have a list of system/comparisons templates that people are wont to borrow and give the advice above about them |
21:05:00 | FromDiscord | <Elegantbeef> I mean that specialisation doesnt make any sense |
21:05:11 | FromDiscord | <Elegantbeef> Cause the compiler doesnt have that information presently 😄 |
21:05:38 | FromDiscord | <Elegantbeef> Borrowing is done quite simply which results in a lacking diagnostic |
21:06:39 | FromDiscord | <tfp> i can't figure out how to make something an iterator |
21:06:47 | FromDiscord | <tfp> like i want my type to be an iterator |
21:06:49 | FromDiscord | <tfp> so i can do |
21:06:55 | FromDiscord | <tfp> var my_type = MyType() |
21:06:59 | FromDiscord | <tfp> for x in my_type |
21:07:03 | FromDiscord | <tfp> what am i missing |
21:07:10 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7l |
21:07:11 | FromDiscord | <Elegantbeef> implement `items` |
21:07:29 | FromDiscord | <tfp> ty |
21:07:33 | FromDiscord | <Elegantbeef> `iterator items(myType: MyType): YieldedType =...` |
21:14:42 | * | junaid_ joined #nim |
21:26:54 | * | junaid_ quit (Remote host closed the connection) |
21:30:36 | * | arkanoid joined #nim |
21:31:25 | FromDiscord | <tfp> that worked |
21:33:19 | FromDiscord | <Elegantbeef> I do enjoy the confirmation of my Nim knowledge |
21:33:41 | FromDiscord | <Elegantbeef> Would be funny if I couldnt walk someone through writing an items iterator |
21:35:22 | FromDiscord | <pyolyokh> you'd hear about that a year later in a presentation in some big conference,↵"Why did I leave Nim? It's just too hard of a language. Even Elegantbeef can't get iterators right." |
21:41:43 | arkanoid | I'm refactoring my multithreading app built with weave. I want to turn all the ptr arguments I'm passing to threaded funcs into a single ptr container object that brings the original fields. Basically something like this https://play.nim-lang.org/#ix=4l7v . Problem is that this little change goes SIGSEGV and I don't know why. What's the difference? |
21:42:21 | FromDiscord | <Elegantbeef> How are you allocating? |
21:42:41 | arkanoid | I've not changed how I run the thread. Just created a wrapper object type, filled with original non-ref and non-ptr values, and passed container.unsafeAddr instead |
21:42:57 | FromDiscord | <Elegantbeef> So you're passing a stack value |
21:43:22 | arkanoid | Elegantbeef, yes |
21:43:34 | FromDiscord | <Elegantbeef> Well that's wrong |
21:44:33 | arkanoid | why? |
21:44:38 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7z |
21:44:39 | FromDiscord | <4zv4l> like abstraction interface |
21:44:56 | arkanoid | the threading function is ending before the launching function goes out of scope |
21:45:28 | FromDiscord | <Elegantbeef> You should technically be capable of accessing another thread's stack, it's just generally considred incorrect |
21:46:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7A |
21:46:34 | FromDiscord | <Elegantbeef> Yea without more code that demonstrates the issue i cannot say much |
21:50:29 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7B |
21:50:40 | FromDiscord | <4zv4l> (edit) "https://play.nim-lang.org/#ix=4l7B" => "https://play.nim-lang.org/#ix=4l7C" |
21:50:56 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7D |
21:53:26 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7G |
21:53:26 | FromDiscord | <4zv4l> sounds good too ! |
21:54:14 | FromDiscord | <tfp> hmm i'm having trouble binding nim w/rust in a new scenario |
21:54:41 | arkanoid | Elegantbeef: here's a slightly longer example of what I've changed in my application https://play.nim-lang.org/#ix=4l7H |
21:55:01 | FromDiscord | <tfp> i think my issue is that i'm not importc'ing the object-- since i don't have a c struct for my rust structs, i'm not sure how to make it work |
21:55:18 | FromDiscord | <tfp> like there's no header file to importc from |
21:55:25 | arkanoid | the original (unwrapped, aka multi-arg threading function) works nicely, I've just added a container |
21:55:28 | FromDiscord | <tfp> the layout should be the same otherwise, but i'm getting invalid access |
21:56:54 | arkanoid | tfp, I don't know how rust packs it's objects, but nim requires packed pragma to avoid optimizing away with internal logic https://nim-lang.org/docs/manual.html#foreign-function-interface-packed-pragma |
21:57:57 | FromDiscord | <4zv4l> In reply to @jos "hmm i'm having trouble": you're interfacing with rust source code or with rust object file/dyn lib ? |
21:58:03 | FromDiscord | <tfp> rust static lib |
21:58:10 | FromDiscord | <Elegantbeef> Unless you need to access fields directly a `type MyObject = ptr object` is ideal |
21:58:13 | FromDiscord | <tfp> In reply to @arkanoid "tfp, I don't know": is there a way to print the layout too? i can print it in rust |
21:58:25 | FromDiscord | <tfp> if i can compare then i can probably figure it out |
21:58:52 | FromDiscord | <4zv4l> In reply to @jos "i think my issue": does nim has keyword for different type of struct ? like packed struct ? |
21:59:05 | FromDiscord | <tfp> there's the packed pragma that arkanoid mentioned |
21:59:12 | FromDiscord | <tfp> i've tried it before though |
21:59:14 | FromDiscord | <tfp> it didn't fix my issue |
21:59:16 | FromDiscord | <Elegantbeef> I swear some people dont read |
21:59:29 | FromDiscord | <Elegantbeef> Both Rust and Nim would need the packed annotation |
21:59:34 | FromDiscord | <tfp> i just wanna inspect the nim layout but i can't find a way to do it |
21:59:55 | FromDiscord | <tfp> the rust struct is using a lib called abi_stable that should guarantee a stable layout |
22:00:34 | arkanoid | tfp, print the object size and object position in memory, and find out? |
22:01:11 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7M |
22:01:20 | FromDiscord | <tfp> In reply to @arkanoid "tfp, print the object": i already checked the size and it's the same |
22:01:27 | FromDiscord | <tfp> sent a code paste, see https://play.nim-lang.org/#ix=4l7N |
22:01:28 | FromDiscord | <tfp> nim is so cool |
22:01:33 | FromDiscord | <tfp> i wish nim and rust had a baby |
22:01:55 | FromDiscord | <Elegantbeef> I mean Nim is basically a less invasive rust |
22:01:55 | arkanoid | please, no. I wish nim eats rust as a whole |
22:02:42 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7O |
22:03:01 | FromDiscord | <4zv4l> offset shows the 'index' of the field ?↵how does it show that |
22:03:04 | FromDiscord | <Elegantbeef> Offset gives you the offset from the start of the objet |
22:03:10 | FromDiscord | <Elegantbeef> addr gives you a pointer |
22:03:23 | FromDiscord | <Elegantbeef> The compiler knows the offset of the fields |
22:03:34 | FromDiscord | <Elegantbeef> Ah sorry the above wont work |
22:04:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7P |
22:04:51 | FromDiscord | <Elegantbeef> That should work |
22:04:54 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7Q |
22:05:05 | FromDiscord | <Elegantbeef> Likely not, but yes |
22:05:10 | FromDiscord | <Elegantbeef> That's the idea |
22:05:22 | FromDiscord | <4zv4l> for packed struct that's how it is supposed to be right ? |
22:05:23 | FromDiscord | <Elegantbeef> `type Test {.packed.} = object` would mean yes |
22:05:33 | FromDiscord | <4zv4l> okok alright |
22:06:32 | FromDiscord | <Elegantbeef> Arkanoid did that code you sent segfault? |
22:06:34 | FromDiscord | <Elegantbeef> It works fine here |
22:07:12 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4l7R |
22:07:41 | FromDiscord | <Elegantbeef> It takes in a typed expression which in this case is `myObject.fieldName` grabs the field symbol then gets the offset of it |
22:07:48 | arkanoid | Elegantbeef, surely not that code, I've represented just the change I've made logically to my code. Sadly to replicate exactly what happening I would need some libs installed in play.nim |
22:08:37 | FromDiscord | <Elegantbeef> Well i dont care about nim playground |
22:08:41 | FromDiscord | <Elegantbeef> I'm running the code locally to reproduce |
22:09:36 | arkanoid | Elegantbeef, btw it was just a curiosity, as I can workaround this problem easily by using the previous pattern: https://play.nim-lang.org/#ix=4l7T |
22:10:02 | FromDiscord | <4zv4l> In reply to @Elegantbeef "It takes in a": `a[^1]` is used for what ? why not use `a` ? |
22:10:04 | FromDiscord | <Elegantbeef> I still say not using the heap is a sin 😛 |
22:10:24 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l7V |
22:10:34 | FromDiscord | <Elegantbeef> > Returns the same result as system.offsetof if the offset is known by the Nim compiler. It expects a resolved symbol node from a field of a type. |
22:11:00 | FromDiscord | <Elegantbeef> `a` is a `dotExpr(myObject, fieldName)` `[^1]` gets `fieldName` |
22:11:16 | arkanoid | I don't the the issue with using ptr to stack allocated stuff. It compiles with arc and runs fine |
22:11:45 | FromDiscord | <Elegantbeef> You could check by using `nim doc`↵(@MadScientistCarl) |
22:11:53 | FromDiscord | <4zv4l> makes more sense, thanks |
22:11:54 | arkanoid | I'm not saying I am right, just don't know which foot I am hammering |
22:12:26 | FromDiscord | <Elegantbeef> I mean it's technically safe what you're doing |
22:13:04 | FromDiscord | <Elegantbeef> Taking an address to the stack is just always iffy cause it's so easy to fuck up |
22:13:07 | * | ltriant quit (Ping timeout: 252 seconds) |
22:15:00 | arkanoid | I've avoided system level programming languages for years, so I fear I have a long list of bullets to shoot in my leg left |
22:15:39 | arkanoid | I'm googling "why I should not pass references to stack allocated structs) |
22:16:54 | FromDiscord | <Elegantbeef> The reason is quite simple, there is no static analysis in Nim to ensure your usage does not outlive the allocation |
22:16:57 | FromDiscord | <ShalokShalom> ~ just don't know which foot I am hammering ~ |
22:17:04 | FromDiscord | <pyolyokh> the #1 issue is that you have to ensure that your references don't live longer than the data on the stack does. Function returns? Its stack is invalid. Thread dies? Its stack is invalid. |
22:17:05 | FromDiscord | <ShalokShalom> sounds like a nice slogan |
22:17:07 | FromDiscord | <Elegantbeef> If you validate that then you know it's safe |
22:17:11 | FromDiscord | <ShalokShalom> should put this on my wall 😄 |
22:17:39 | FromDiscord | <MadScientistCarl> Is it safe to use `ref Type` as table keys? |
22:17:48 | FromDiscord | <Elegantbeef> Yes |
22:17:50 | FromDiscord | <MadScientistCarl> Does it actually hash the object or does it use the address? |
22:18:05 | FromDiscord | <Elegantbeef> you need `-d:nimPreviewHashRef` |
22:18:25 | FromDiscord | <Elegantbeef> It hashes the pointer |
22:18:25 | FromDiscord | <Elegantbeef> `hash` should work the same as `==` |
22:19:42 | FromDiscord | <MadScientistCarl> Can I think of `Table` to be comparing structurally and `TableRef` to be comparing the same object? |
22:19:53 | FromDiscord | <Elegantbeef> No |
22:20:03 | FromDiscord | <Elegantbeef> `TableRef` is a reference table |
22:20:15 | FromDiscord | <Elegantbeef> It's the same as `Table` but has reference semantics on the actual table |
22:20:17 | FromDiscord | <MadScientistCarl> Oh, so it refs the table itself |
22:23:26 | FromDiscord | <MadScientistCarl> If I am not using `ref` types anywhere, would Nim actually copy a big struct all over the place? Or is the compiler smarter and does not actually do that? |
22:23:49 | FromDiscord | <Elegantbeef> Big objects are passed by reference |
22:24:09 | FromDiscord | <Elegantbeef> Copies can happen depending on the mm you're using |
22:24:18 | FromDiscord | <MadScientistCarl> Even if I do not define them as `ref object`? |
22:24:20 | FromDiscord | <Elegantbeef> Arc/Orc have move semantics so if a copy can be avoided it'll move memory |
22:24:28 | FromDiscord | <MadScientistCarl> Hmm, is Orc a 2.0 thing? |
22:24:33 | FromDiscord | <Elegantbeef> Nope |
22:24:46 | FromDiscord | <pyolyokh> the 2.0 thing is that they become the default |
22:25:06 | FromDiscord | <Elegantbeef> Nim passes by reference `seq` `string` and objects larger than 24bytes afaik |
22:25:12 | FromDiscord | <MadScientistCarl> OK |
22:25:18 | FromDiscord | <Elegantbeef> Or any object annotated with `{.byRef.}` |
22:25:21 | FromDiscord | <MadScientistCarl> Hmm, how do I enable ORC in nimble? |
22:25:36 | FromDiscord | <Elegantbeef> make a `config.nims` and `--mm:orc` |
22:25:43 | FromDiscord | <cow> In reply to @MadScientistCarl "Even if I do": don't `ref object`s never get copied, as they're only a pointer to the heap? |
22:25:53 | FromDiscord | <MadScientistCarl> I should probably really go understand the reference semantics of Nim |
22:26:05 | FromDiscord | <Elegantbeef> I mean reference semantics are just pointer semantics |
22:26:10 | FromDiscord | <MadScientistCarl> In reply to @cow "don't `ref object`s never": I think so? I am asking about `type A = object` situation |
22:26:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7X |
22:26:47 | FromDiscord | <Elegantbeef> That's all there is to references |
22:27:12 | FromDiscord | <Elegantbeef> They're heap allocated data types that can form many to one relationships |
22:27:13 | FromDiscord | <Elegantbeef> There's nothing else really special |
22:27:25 | FromDiscord | <MadScientistCarl> I know this |
22:27:58 | FromDiscord | <MadScientistCarl> I was asking whether Nim is smart enough to not copy a big struct defined _NOT_ as `ref object` if it is not being modified |
22:28:19 | FromDiscord | <Elegantbeef> Like i said it depends on MM for assignment |
22:28:29 | FromDiscord | <Elegantbeef> For procedures large objects are passed by reference |
22:28:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7Y |
22:29:04 | FromDiscord | <Elegantbeef> But in arc/orc that might not be if `someLargeObject` isnt used after the usage of `a` |
22:29:06 | FromDiscord | <MadScientistCarl> OK |
22:29:15 | FromDiscord | <Elegantbeef> If you're concerned about copies with objects you can disable the copy hook |
22:29:27 | FromDiscord | <MadScientistCarl> I see |
22:29:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l7Z |
22:29:52 | FromDiscord | <MadScientistCarl> Is there a difference between `--mm` and `--gc`? |
22:29:53 | FromDiscord | <Elegantbeef> That disables copies for your type |
22:29:55 | FromDiscord | <MadScientistCarl> Ah |
22:30:14 | FromDiscord | <Elegantbeef> No |
22:30:47 | FromDiscord | <Elegantbeef> The thing with arc/orc is you need to actually look at the code to understand if Nim will move resources |
22:30:59 | FromDiscord | <Elegantbeef> There's also cursor annotations |
22:31:08 | FromDiscord | <Elegantbeef> Which is like a weak reference in C++ |
22:31:33 | FromDiscord | <MadScientistCarl> OK... I will not touch `--mm` unless I have a problem with performance |
22:31:46 | FromDiscord | <Elegantbeef> I mean Orc/Arc are just better than refc |
22:32:08 | FromDiscord | <MadScientistCarl> I see it's going to be default? |
22:32:16 | FromDiscord | <pyolyokh> that's the 2.0 thing, yes. |
22:32:36 | FromDiscord | <cow> 2.0 will bring in all the (potentially) backwards compat breaking pending changes |
22:34:18 | FromDiscord | <MadScientistCarl> I am so new to the language that this is completely not an issue for me |
22:35:38 | * | jjido joined #nim |
22:36:24 | * | xet7 quit (Remote host closed the connection) |
22:38:04 | FromDiscord | <MadScientistCarl> Hmm, can I not have cyclic imports? |
22:38:39 | FromDiscord | <Elegantbeef> You need to delay imports to have cyclical |
22:38:46 | FromDiscord | <Elegantbeef> So it's a bit complicated and generally not what you want |
22:40:08 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/ZzgEjgKLfPNRHeK8 |
22:40:43 | FromDiscord | <Elegantbeef> an example of it here |
22:42:23 | FromDiscord | <MadScientistCarl> Looks like I can't have mutually defined types either |
22:42:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l82 |
22:44:37 | FromDiscord | <MadScientistCarl> Ah, OK. They have to be in the same type block |
22:53:47 | FromDiscord | <Elegantbeef> There is a plan to make it so both delayed imports and using the same typeblock are not required sometime in Nim 2.x |
23:09:25 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
23:18:17 | arkanoid | how can I create a ref bool? Do I need to create an alias type? |
23:18:28 | FromDiscord | <Elegantbeef> `new bool` |
23:19:11 | arkanoid | thanks |
23:19:47 | arkanoid | but how to set it to true or false? |
23:20:05 | FromDiscord | <pyolyokh> `b[] = true` |
23:20:23 | arkanoid | makes sense |
23:31:09 | FromDiscord | <MadScientistCarl> How do I make a reference out of an existing object? |
23:31:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l8i |
23:31:44 | FromDiscord | <Elegantbeef> You cannot raise a non ref to a ref |
23:31:48 | FromDiscord | <Elegantbeef> You need to allocate then copy |
23:31:53 | FromDiscord | <MadScientistCarl> Not this, but the other way around |
23:32:08 | FromDiscord | <MadScientistCarl> Oh, is it not possible? |
23:32:10 | FromDiscord | <Elegantbeef> `var myNonRef = myRef[]` |
23:32:32 | FromDiscord | <Elegantbeef> Nim's `ref` is a automatically managed heap allocated type |
23:32:41 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l8j |
23:32:55 | FromDiscord | <Elegantbeef> You mean how do you take the address of a value |
23:33:00 | FromDiscord | <Elegantbeef> `addr` or `unsafeaddr` |
23:33:03 | FromDiscord | <Elegantbeef> That gives you a `ptr T` |
23:33:18 | FromDiscord | <Elegantbeef> not a `ref` since Nim's ref is as i said memory safe |
23:33:30 | FromDiscord | <MadScientistCarl> OK... |
23:43:43 | FromDiscord | <<She>Horizon</Her>> In reply to @Elegantbeef "You need to delay": I still stand by the fact that true cyclic imports would be nice but i can see issues because, this ain't class based like Java for example, where all the code is contained nicely in some class/function |
23:43:55 | FromDiscord | <<She>Horizon</Her>> Though it could still be done i the |
23:43:57 | FromDiscord | <<She>Horizon</Her>> Think |
23:44:03 | FromDiscord | <<She>Horizon</Her>> In reply to @Elegantbeef "There is a plan": Oh that's epic |
23:44:09 | FromDiscord | <Elegantbeef> As i said it's planned for 2.x |
23:44:31 | FromDiscord | <MadScientistCarl> Now I wonder, should I use methods or should I store `proc` as a member |
23:44:40 | FromDiscord | <Elegantbeef> Depends what you need |
23:44:42 | FromDiscord | <Elegantbeef> Or want |
23:44:51 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4l8n |
23:45:01 | FromDiscord | <huantian> sent a code paste, see https://paste.rs/RXo |
23:45:19 | FromDiscord | <MadScientistCarl> No, that is making another copy of the object |
23:45:23 | FromDiscord | <Elegantbeef> Of course you cannot if `myOtherObj` is a value↵(@<She>Horizon</Her>) |
23:45:36 | FromDiscord | <<She>Horizon</Her>> Ah |
23:45:52 | FromDiscord | <ShalokShalom> how is your java backend going? 🙂 |
23:45:55 | FromDiscord | <<She>Horizon</Her>> But you could do `(ref MyObj)()` or something? |
23:46:03 | FromDiscord | <Elegantbeef> Yes |
23:46:07 | FromDiscord | <<She>Horizon</Her>> In reply to @ShalokShalom "how is your java": So, so burnt out on it aha |
23:46:10 | FromDiscord | <Elegantbeef> But the point was copying an existent object to the heap |
23:46:15 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4l8p |
23:46:21 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4l8q |
23:46:30 | FromDiscord | <Elegantbeef> You can do the same in Nim |
23:46:35 | FromDiscord | <<She>Horizon</Her>> It's a big project and got too over my head about it, though i do want to actually continue it asap, it'd be very neat |
23:46:44 | FromDiscord | <MadScientistCarl> But in Nim it has to be on the heap, unless I missed something |
23:46:45 | FromDiscord | <<She>Horizon</Her>> In reply to @Elegantbeef "But the point was": Ah fair |
23:46:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l8r |
23:46:59 | FromDiscord | <MadScientistCarl> That is not quite the same |
23:47:07 | FromDiscord | <Elegantbeef> Nim's reference is not like Rust's reference or C++'s |
23:47:23 | FromDiscord | <Elegantbeef> Nim's reference is explicitly more akin to rust's ref counted container |
23:47:31 | FromDiscord | <Elegantbeef> I cannot remember what it's called presently |
23:47:43 | FromDiscord | <MadScientistCarl> Proc taking `var` is like taking `&mut` in Rust. However, in the hypothetical situation I was asking, it should be just plain `ref` |
23:48:21 | FromDiscord | <ShalokShalom> In reply to @Minaaa <3 "So, so burnt out": bless you |
23:48:22 | FromDiscord | <Elegantbeef> No |
23:48:23 | FromDiscord | <Elegantbeef> `proc someProc(myType: MyType)` will pass by ref automatically in Nim if `MyType` is large enoguh |
23:48:25 | FromDiscord | <Elegantbeef> There is no reason to labour the programmer with having to manually take a reference |
23:48:27 | FromDiscord | <MadScientistCarl> Actually you can't do that in Rust either |
23:48:40 | FromDiscord | <MadScientistCarl> Never mind |
23:48:42 | FromDiscord | <Elegantbeef> Yea didnt think so but dont know rust enough to be 100% |
23:49:02 | FromDiscord | <MadScientistCarl> Yeah, in Rust you need `Rc` too, which is reference counting |
23:49:35 | FromDiscord | <MadScientistCarl> I guess plain objects are just like shared refs in Rust |
23:50:56 | FromDiscord | <Elegantbeef> Plain objects in Nim are just Rust structs |
23:51:05 | * | jjido joined #nim |
23:51:26 | FromDiscord | <Elegantbeef> They're value types that are allocated contiguously when capable |
23:52:09 | FromDiscord | <<She>Horizon</Her>> In reply to @Elegantbeef "`proc someProc(myType: MyType)` will": What counts as big enough? Also i wasn't aware of this behaviour before hm |
23:52:56 | FromDiscord | <MadScientistCarl> Is it possible to let Nimble build in another directory? I would rather not have to edit my `.gitignore` every time |
23:54:20 | FromDiscord | <<She>Horizon</Her>> I think `-o:location` is what you're looking for |
23:54:38 | FromDiscord | <<She>Horizon</Her>> Is it `-o`? Or was it `--out` |
23:54:42 | FromDiscord | <<She>Horizon</Her>> Or outfile |
23:54:56 | FromDiscord | <<She>Horizon</Her>> Can't remember rn, been a while since i touched any of Nim's flags |
23:55:21 | FromDiscord | <Elegantbeef> Bigger or equal to 24bytes i think |
23:55:28 | FromDiscord | <MadScientistCarl> Ah, I find a flag called `binDir` |
23:56:34 | FromDiscord | <MadScientistCarl> I set it to `build/`, and everything is good |
23:56:35 | FromDiscord | <Elegantbeef> Why do you need to edit your git ignore, just make it ignore all extensionless files, .exe and .out |
23:57:07 | FromDiscord | <MadScientistCarl> `build/` is just easier to manage, IMO |
23:57:17 | FromDiscord | <MadScientistCarl> If I don't want something, just delete the whole thing |
23:59:43 | * | oprypin quit (Quit: Bye) |