02:20:47 | * | SchweinD1 quit (Quit: WeeChat 4.6.0-dev) |
02:23:28 | * | SchweinDeBurg joined #nim |
02:25:06 | FromDiscord | <.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=xLiDbNRW |
02:26:26 | FromDiscord | <.tokyovigilante> ah crap I am dumb, I mean bitor |
02:31:58 | FromDiscord | <sleeves> Another likely dumb question\: is there a way to avoid recursive module dependency besides only having dependencies flow in one direction? I tried using from x import y on both ends but it still doesn't compile |
02:32:26 | FromDiscord | <sleeves> Another likely dumb question from me\: is there a way to avoid recursive module dependency besides only having dependencies flow in one direction? I tried using from x import y on both ends but it still doesn't compile |
02:53:49 | FromDiscord | <k0ts> Have you tried delayed imports |
03:40:34 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/wiki/Code-snippets#delayed-imports for an example of that sleeves |
03:40:35 | FromDiscord | <Elegantbeef> Nim's module system really prefers building up rather than building out |
05:58:11 | * | nils` quit (Ping timeout: 265 seconds) |
07:05:44 | * | nils` joined #nim |
07:10:24 | * | nils` quit (Ping timeout: 252 seconds) |
07:31:56 | * | nils` joined #nim |
07:45:49 | * | redj quit (Ping timeout: 245 seconds) |
07:46:27 | * | redj joined #nim |
07:54:59 | * | nils` quit (Ping timeout: 245 seconds) |
08:17:08 | * | coldfeet joined #nim |
08:37:27 | * | coldfeet quit (Ping timeout: 276 seconds) |
08:39:00 | * | coldfeet joined #nim |
09:03:19 | * | nils` joined #nim |
09:28:32 | FromDiscord | <albassort> is there a way to override the repr for floats |
09:30:01 | FromDiscord | <Elegantbeef> It's just a proc |
09:30:13 | FromDiscord | <albassort> i want to make sure my ;proc is used |
09:30:28 | FromDiscord | <Elegantbeef> Oh you mean for nested |
09:30:33 | FromDiscord | <Elegantbeef> Stop using repr and start using `$` |
09:30:52 | FromDiscord | <albassort> how do i control the proc that echo, and pretty use |
09:31:07 | FromDiscord | <Elegantbeef> echo uses `$` |
09:31:15 | FromDiscord | <Elegantbeef> I assume pretty uses the same |
09:52:17 | Amun-Ra | replacing $ is much easier, define nimPreviewSlimSystem and don't import std/formatfloat |
09:58:26 | FromDiscord | <Elegantbeef> Well you also can just define a `$` locally and it'll use that over system's |
09:58:42 | FromDiscord | <Elegantbeef> This really is where I want a "weak distinct" |
10:59:04 | FromDiscord | <xtrayambak> Does anyone know what the equivalent to `&ident` (or a non-NULL reference in C++) in Nim would be? |
11:03:58 | FromDiscord | <demotomohiro> In reply to @xtrayambak "Does anyone know what": var parameter or view types: https://nim-lang.org/docs/manual_experimental.html#view-types |
11:04:54 | FromDiscord | <xtrayambak> Thank you so much! |
11:05:02 | FromDiscord | <demotomohiro> If I remember correctly, reference types in C++ can be Null. |
11:05:05 | FromDiscord | <xtrayambak> I've been scratching my head over this for the past day haha |
11:05:24 | Amun-Ra | C++ reference type can't be null |
11:09:26 | FromDiscord | <demotomohiro> https://wandbox.org/permlink/zbnJNSJEVER6VgEd |
11:09:35 | FromDiscord | <xtrayambak> welp, c2nim just generated this 🥲 https://media.discordapp.net/attachments/371759389889003532/1321072277432832123/MteSdzC.png?ex=676be7ef&is=676a966f&hm=7dd36e301384b4dd1558ca601e854ce7fe8b2bb624eb53fbc425300ef3ebe852& |
11:09:55 | FromDiscord | <xtrayambak> time to check out how to make it not emit that |
11:10:48 | FromDiscord | <xtrayambak> (edit) "check" => "find" |
11:13:37 | Amun-Ra | demotomohiro: segfault happens in line 8 during dereferencing null pointer |
11:13:53 | Amun-Ra | demotomohiro: int& can only store int type |
11:14:06 | Amun-Ra | try int& foo = nullptr; |
11:14:50 | Amun-Ra | xtrayambak: c2nim by default sets all symbols exportable |
11:15:00 | FromDiscord | <xtrayambak> No, not that |
11:15:11 | FromDiscord | <xtrayambak> It doesn't respect the case insensitivity rules of Nim |
11:15:18 | FromDiscord | <xtrayambak> so that generated code is technically wrong |
11:15:30 | FromDiscord | <xtrayambak> Nim counts it as a redefinition of the same value |
11:15:46 | Amun-Ra | a, I see it; yes |
11:16:16 | FromDiscord | <xtrayambak> eh, I just got another file that does the same thing but without the symbol conflicts 😄 |
11:26:11 | FromDiscord | <demotomohiro> @Amun-Ra `int&` in C++ can reference only lvalue and `p` is lvalue even if `p == NULL`. |
11:52:05 | FromDiscord | <k0ts> https://nim-lang.org/blog/2024/12/24/nim-2014-released.html |
12:00:24 | FromDiscord | <odexine> i was like "huh? 2014? when did i travel back a decade" |
12:02:05 | FromDiscord | <djazz> Merry Christmas and a Happy Nim Year |
12:02:06 | FromDiscord | <zumi.dxy> incidentally: https://nim-lang.org/blog/2014/12/29/version-0102-released.html |
12:02:12 | FromDiscord | <zumi.dxy> close enough, anyway |
12:08:38 | Amun-Ra | demotomohiro: https://wandbox.org/permlink/CtVjomaucvxRSVHZ |
12:08:45 | Amun-Ra | cannot bind rvalue '(int)p' to 'int&' |
12:08:48 | FromDiscord | <narimiran> Nim 2.0.14 released: https://nim-lang.org/blog/2024/12/24/nim-2014-released.html |
12:09:07 | Amun-Ra | for the last time, int& can only contain int type |
12:09:44 | FromDiscord | <narimiran> In reply to @k0ts "https://nim-lang.org/blog/2024/12/24/nim-2014-relea": oh, i didn't notice you've already posted it |
12:11:58 | Amun-Ra | demotomohiro: you were trying to assign 'int' to 'refp' by taking the 'int' from dereferencing pointer 'p' |
12:13:08 | Amun-Ra | remove count like and it'll still segfault |
12:16:56 | Amun-Ra | you can only have nullptr if you reference a pointer, like here: https://wandbox.org/permlink/xzSN9xCfjiRhLdVK |
12:24:30 | FromDiscord | <k0ts> sent a code paste, see https://play.nim-lang.org/#pasty=jFnOAblq |
12:26:38 | Amun-Ra | the problem with that code is that line 5 is UB |
12:26:53 | Amun-Ra | *p is of int type |
12:26:58 | FromDiscord | <k0ts> I believe you |
12:27:06 | FromDiscord | <k0ts> but in the end we still have a reference to nullptr |
12:27:13 | FromDiscord | <k0ts> I think that's what demo was getting at |
12:27:30 | Amun-Ra | and &refp in 6 is (int *) |
12:27:44 | Amun-Ra | no |
12:27:49 | FromDiscord | <k0ts> ok |
12:27:52 | Amun-Ra | we never had reference to nullptr |
12:27:56 | FromDiscord | <k0ts> ok |
12:28:15 | Amun-Ra | int* p = nullptr ← p is of (int *) type, and it contains null pointer |
12:29:13 | Amun-Ra | int& refp = *p; ← p is (int *), dereferencing p makes it (int) |
12:30:46 | Amun-Ra | https://wandbox.org/permlink/fC68wpNiLMnv6Etd |
12:31:35 | Amun-Ra | here refa is really reference to a, refp is really a reference do dereferenced value from pointer |
12:33:19 | Amun-Ra | https://wandbox.org/permlink/1ClEGIL2bZee6q7N |
12:35:11 | Amun-Ra | end of the line is, unless `type` in (type&) reference can contain null pointer, there's no way to store a pointer, null one or not, to reference to `type` |
12:38:03 | Amun-Ra | bottom line* |
15:52:55 | * | beholders_eye joined #nim |
15:59:21 | * | beholders_eye quit (Ping timeout: 244 seconds) |
16:00:39 | * | coldfeet quit (Quit: Lost terminal) |
16:58:39 | FromDiscord | <requiresupport> `Warning: See corresponding Defect; IndexError is deprecated [Deprecated]`↵↵What to use instead of indexerror? 🤔 |
17:26:22 | * | beholders_eye joined #nim |
17:47:53 | FromDiscord | <Robyn [She/Her]> In reply to @requiresupport "`Warning: See corresponding Defect;": Check if the index is in range with an if statement |
17:53:12 | * | ensyde quit (Ping timeout: 276 seconds) |
17:55:12 | FromDiscord | <odexine> In reply to @requiresupport "`Warning: See corresponding Defect;": IndexDefect? |
18:06:38 | FromDiscord | <Robyn [She/Her]> In reply to @odexine "IndexDefect?": That's an error message for catching the error, catching the defect is gonna cause issues if panicking is on, might as well do good practices :p |
18:07:12 | FromDiscord | <odexine> I was more under the impression that they were raising an error |
18:14:14 | FromDiscord | <Robyn [She/Her]> Oh that could also be the case |
18:27:15 | * | xutaxkamay quit (Ping timeout: 252 seconds) |
18:37:59 | * | def- quit (Quit: -) |
18:40:32 | * | def- joined #nim |
19:33:34 | * | beholders_eye quit (Ping timeout: 265 seconds) |
19:43:27 | * | xutaxkamay joined #nim |
19:50:08 | FromDiscord | <thepotatochronicler> Sorry to bother, is there a way to get the build OS instead of the host OS? |
19:53:11 | FromDiscord | <bostonboston> Store it as a const string? |
19:53:44 | Amun-Ra | hmm, I don't think there's sth like buildOS |
19:54:22 | FromDiscord | <thepotatochronicler> Huh, nimscript has buildOS 🤔 |
19:55:09 | FromDiscord | <bostonboston> You can make a strdefine and in your nimble file call buildOS to fill it |
19:55:48 | Amun-Ra | oh |
19:55:50 | Amun-Ra | https://play.nim-lang.org/#pasty=KDYasYPJ |
19:56:16 | FromDiscord | <thepotatochronicler> system.buildOS also exists... apparently? 😵💫 |
19:56:23 | Amun-Ra | yes |
19:56:31 | Amun-Ra | apparently :) |
19:56:33 | Amun-Ra | TIL |
19:57:14 | Amun-Ra | and there's also buildCPU |
19:57:23 | FromDiscord | <thepotatochronicler> Or that might have been only because I was running it in a .nims file mmm |
19:58:06 | Amun-Ra | and there are handfull functions in pure/distros |
19:59:32 | FromDiscord | <demotomohiro> Here is how I get `buildOS`: https://github.com/demotomohiro/pathX/blob/main/src/pathX/base.nim#L19 |
20:01:01 | Amun-Ra | nice |
20:04:42 | FromDiscord | <thepotatochronicler> Well, one more thing then, can I specify what separators to use for a path? When I use the std/paths \`/\` and others, it uses the target OS separator, but I also do some path operations at compile time, which get turned into Windows paths because of this 🥴 |
20:05:21 | FromDiscord | <thepotatochronicler> I tried std/pathnorm normalizePath, but it doesn't let me specify the second argument for some reason : |
20:05:23 | FromDiscord | <thepotatochronicler> (edit) removed ":" |
20:05:31 | Amun-Ra | all modern OS-es understand / as path separators :) |
20:06:10 | Amun-Ra | thepotatochron: std/paths got you covered |
20:06:15 | FromDiscord | <thepotatochronicler> In reply to @Amun-Ra "all modern OS-es understand": It turned it into \\, so I get \home\user\... |
20:06:50 | FromDiscord | <thepotatochronicler> Because I am trying to build on Linux and target Windows, so std/paths don't got me covered |
20:07:09 | Amun-Ra | hmm, that should be cross-compiling aware |
20:07:44 | FromDiscord | <thepotatochronicler> I thought so too, but then someone might want to do target OS operations at compile time, and then noone would be happy |
20:08:06 | Amun-Ra | that should work at compile-time |
20:08:28 | FromDiscord | <thepotatochronicler> std/pathnorm has normalizePath which takes an argument for it, but for some reason, I can't specify it, it causes an error |
20:09:18 | Amun-Ra | std/private/osseps.nim |
20:09:21 | FromDiscord | <thepotatochronicler> I am not even sure about the syntax that is being used here, since the parameter has no type specified, only the default value |
20:09:27 | Amun-Ra | yes, it should work when cross-compiling |
20:09:41 | Amun-Ra | do you have "windows" defined? |
20:09:57 | FromDiscord | <thepotatochronicler> In reply to @Amun-Ra "do you have "windows"": It is defined because of cross-compiling |
20:10:19 | FromDiscord | <thepotatochronicler> But I need some paths for the build OS, for the `compile` pragma |
20:10:59 | FromDiscord | <demotomohiro> In reply to @thepotatochronicler "Well, one more thing": I dont think Nim's stdlib cover such a case. You need to use something like this: https://github.com/demotomohiro/pathX↵Or create new path library yourself. |
20:11:10 | Amun-Ra | when defined windows: const somepath = r"foo\bar" else: const comepath = "foo/bar" |
20:11:54 | Amun-Ra | "foo/bar" will work on windows, too |
20:12:07 | Amun-Ra | should* |
20:12:15 | FromDiscord | <thepotatochronicler> std/pathnorm normalizePath should work, but for some reason, when I specify the directory separator, it causes a compile error |
20:13:23 | Amun-Ra | what error? |
20:13:53 | FromDiscord | <thepotatochronicler> What is this syntax? There is no type, and I can't find it in the manual https://media.discordapp.net/attachments/371759389889003532/1321209255449202758/image.png?ex=676c6781&is=676b1601&hm=28e0bea957ad6e55194db4832c191ac141fc921992eee3f860e4f1b0b9510a59& |
20:14:08 | FromDiscord | <thepotatochronicler> using? |
20:14:24 | Amun-Ra | that's default argument value |
20:14:35 | FromDiscord | <thepotatochronicler> In reply to @Amun-Ra "that's default argument value": Yes, but there is no type for the argument |
20:14:36 | Amun-Ra | something like (x = 2) |
20:14:47 | Amun-Ra | type is derived from the value |
20:14:57 | FromDiscord | <thepotatochronicler> Okay, makes sense |
20:15:02 | Amun-Ra | (dirSep: string = DirSep) |
20:15:19 | FromDiscord | <thepotatochronicler> In reply to @Amun-Ra "what error?": Type error https://media.discordapp.net/attachments/371759389889003532/1321209613458341898/image.png?ex=676c67d6&is=676b1656&hm=2d963184b56da3b22d985414706dd960e397ae7793dcd125feee13f85fccfa1a& |
20:15:26 | Amun-Ra | sorry, DirSep is char |
20:15:32 | FromDiscord | <thepotatochronicler> OH |
20:15:42 | FromDiscord | <thepotatochronicler> Now that makes sense |
20:15:55 | Amun-Ra | yes, that's the culprit :> |
20:16:19 | FromDiscord | <thepotatochronicler> It magically works now, I love you |
20:16:29 | Amun-Ra | thanks, I love /me too ;) |
20:17:25 | Amun-Ra | that automatic type derivation has an official name, but I can't recall it |
20:17:47 | FromDiscord | <demotomohiro> There are many difference between windows path and linux path. Case sensitive or not, has drive latter or not, etc. |
20:21:09 | FromDiscord | <thepotatochronicler> There is a way to specify the name/type of the c compiler, but not the path to the compiler 🥴 |
20:21:47 | Amun-Ra | "type inference", that was it |
20:22:08 | Amun-Ra | you can specify full path to the compiler |
20:22:32 | Amun-Ra | --gcc.exe='/opt/3rdparty/gcc/bin/gcc' … |
20:22:51 | Amun-Ra | and --gcc.linkerexe |
20:23:08 | Amun-Ra | if you switch compiler to clang replace "gcc" with "clang" |
20:24:57 | Amun-Ra | the other option is --cc=env and setting relevant environment variables |
20:26:35 | FromDiscord | <thepotatochronicler> Ah, and compiler.cpp.exe for C++, we're almost home |
20:26:44 | Amun-Ra | sure |
20:27:02 | Amun-Ra | I keep forgetting about C++ compilers, I usually use C target by default |
20:28:08 | FromDiscord | <thepotatochronicler> I am trying to see how well nim interfaces with C++ libraries, that's one of the selling points that got me to try it out |
20:28:16 | Amun-Ra | mhm |
20:28:58 | Amun-Ra | you can interface js code on the same principle |
20:29:11 | FromDiscord | <thepotatochronicler> That's the second selling point |
20:29:41 | Amun-Ra | I even compiler nim code for old Amiga OSes |
20:29:44 | Amun-Ra | compiled* |
20:30:59 | FromDiscord | <demotomohiro> Here is how to interfaces C++ lib: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma |
20:31:20 | Amun-Ra | I even played with wasm a little, https://retro.rocks/tmp/ronin/emscripten/ |
20:32:52 | FromDiscord | <demotomohiro> There are experimental features to import more C++ code https://nim-lang.org/docs/manual_experimental.html#virtual-pragma |
20:50:45 | FromDiscord | <thepotatochronicler> Defines (atleast I think they are defines?) like --clang.cpp.options.always don't seem to accept spaces, atleast not thought `nimble build` mmm |
20:51:38 | Amun-Ra | spaces are fine |
20:51:52 | Amun-Ra | how did you provide these options? |
20:52:36 | Amun-Ra | you can pass any number of options with --passc (for the compiler) and --passl (for the linker) |
20:52:44 | Amun-Ra | repeat those as much as you like |
20:52:48 | FromDiscord | <thepotatochronicler> sent a code paste, see https://play.nim-lang.org/#pasty=vfkeCAOk |
20:53:02 | FromDiscord | <thepotatochronicler> The last part breaks it |
20:53:16 | Amun-Ra | what's the error? |
20:53:42 | FromDiscord | <thepotatochronicler> https://media.discordapp.net/attachments/371759389889003532/1321219274236366848/image.png?ex=676c70d6&is=676b1f56&hm=442f31c2320e78afe6b2ec7ab08025cb08fafdb1b58206ea61585b739fa15c75& |
20:53:59 | FromDiscord | <thepotatochronicler> It thinks they are run arguments |
20:54:32 | FromDiscord | <Elegantbeef> It's easier to make a config.nims with a `when defined(windows): ....` |
20:54:43 | FromDiscord | <Elegantbeef> then you can `nimble build -d:windows` and call it a day |
20:54:56 | FromDiscord | <thepotatochronicler> Planning on that, just testing for now this way |
20:54:59 | FromDiscord | <Elegantbeef> rather `nimble build --os:windows` |
20:55:09 | Amun-Ra | and -b=cpp to switch to c++ backend |
20:55:11 | FromDiscord | <Elegantbeef> Well I'd test it using `nim c` over `nimble` |
20:55:54 | FromDiscord | <thepotatochronicler> Nimble seems to have it's own quirks, so it seems to make sense to test using it mmm |
20:56:04 | FromDiscord | <Elegantbeef> Not if you plan on using a config |
20:56:34 | FromDiscord | <thepotatochronicler> Fair |
20:57:59 | FromDiscord | <Elegantbeef> You might be able to move the flags before `build` |
21:04:52 | FromDiscord | <thepotatochronicler> Now we're thinking with portals 😄 |
21:09:10 | FromDiscord | <thepotatochronicler> One, hopefully last thing I am unsure of, preferred way to create C defines? `passc` with -DName? |
21:09:48 | FromDiscord | <Elegantbeef> Yea |
21:09:56 | FromDiscord | <Elegantbeef> You also can do it in your code if it's a C library you're binding |
21:10:05 | FromDiscord | <Elegantbeef> https://github.com/beef331/wasm3/blob/master/src/wasm3/wasm3c.nim#L28-L62 A hideous example |
21:15:29 | * | coldfeet joined #nim |
21:27:29 | * | xutaxkamay_ joined #nim |
21:29:15 | * | xutaxkamay quit (Ping timeout: 246 seconds) |
21:29:15 | * | xutaxkamay_ is now known as xutaxkamay |
21:32:03 | FromDiscord | <thepotatochronicler> Forgot to change the linker to the cross-compiling one, now the errors are making sense :deadge: |
21:48:04 | * | coldfeet quit (Quit: Lost terminal) |
22:09:58 | FromDiscord | <thepotatochronicler> Is there some kind of annotation or a pragma that says that a procedure returns a non-nil pointer? |
22:19:57 | Amun-Ra | https://nim-lang.org/docs/manual_experimental_strictnotnil.html |
22:20:22 | Amun-Ra | or just return non-ref object |
23:16:44 | * | beholders_eye joined #nim |