<< 24-12-2024 >>

02:20:47*SchweinD1 quit (Quit: WeeChat 4.6.0-dev)
02:23:28*SchweinDeBurg joined #nim
02:25:06FromDiscord<.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=xLiDbNRW
02:26:26FromDiscord<.tokyovigilante> ah crap I am dumb, I mean bitor
02:31:58FromDiscord<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:26FromDiscord<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:49FromDiscord<k0ts> Have you tried delayed imports
03:40:34FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/wiki/Code-snippets#delayed-imports for an example of that sleeves
03:40:35FromDiscord<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:32FromDiscord<albassort> is there a way to override the repr for floats
09:30:01FromDiscord<Elegantbeef> It's just a proc
09:30:13FromDiscord<albassort> i want to make sure my ;proc is used
09:30:28FromDiscord<Elegantbeef> Oh you mean for nested
09:30:33FromDiscord<Elegantbeef> Stop using repr and start using `$`
09:30:52FromDiscord<albassort> how do i control the proc that echo, and pretty use
09:31:07FromDiscord<Elegantbeef> echo uses `$`
09:31:15FromDiscord<Elegantbeef> I assume pretty uses the same
09:52:17Amun-Rareplacing $ is much easier, define nimPreviewSlimSystem and don't import std/formatfloat
09:58:26FromDiscord<Elegantbeef> Well you also can just define a `$` locally and it'll use that over system's
09:58:42FromDiscord<Elegantbeef> This really is where I want a "weak distinct"
10:59:04FromDiscord<xtrayambak> Does anyone know what the equivalent to `&ident` (or a non-NULL reference in C++) in Nim would be?
11:03:58FromDiscord<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:54FromDiscord<xtrayambak> Thank you so much!
11:05:02FromDiscord<demotomohiro> If I remember correctly, reference types in C++ can be Null.
11:05:05FromDiscord<xtrayambak> I've been scratching my head over this for the past day haha
11:05:24Amun-RaC++ reference type can't be null
11:09:26FromDiscord<demotomohiro> https://wandbox.org/permlink/zbnJNSJEVER6VgEd
11:09:35FromDiscord<xtrayambak> welp, c2nim just generated this 🥲 https://media.discordapp.net/attachments/371759389889003532/1321072277432832123/MteSdzC.png?ex=676be7ef&is=676a966f&hm=7dd36e301384b4dd1558ca601e854ce7fe8b2bb624eb53fbc425300ef3ebe852&
11:09:55FromDiscord<xtrayambak> time to check out how to make it not emit that
11:10:48FromDiscord<xtrayambak> (edit) "check" => "find"
11:13:37Amun-Rademotomohiro: segfault happens in line 8 during dereferencing null pointer
11:13:53Amun-Rademotomohiro: int& can only store int type
11:14:06Amun-Ratry int& foo = nullptr;
11:14:50Amun-Raxtrayambak: c2nim by default sets all symbols exportable
11:15:00FromDiscord<xtrayambak> No, not that
11:15:11FromDiscord<xtrayambak> It doesn't respect the case insensitivity rules of Nim
11:15:18FromDiscord<xtrayambak> so that generated code is technically wrong
11:15:30FromDiscord<xtrayambak> Nim counts it as a redefinition of the same value
11:15:46Amun-Raa, I see it; yes
11:16:16FromDiscord<xtrayambak> eh, I just got another file that does the same thing but without the symbol conflicts 😄
11:26:11FromDiscord<demotomohiro> @Amun-Ra `int&` in C++ can reference only lvalue and `p` is lvalue even if `p == NULL`.
11:52:05FromDiscord<k0ts> https://nim-lang.org/blog/2024/12/24/nim-2014-released.html
12:00:24FromDiscord<odexine> i was like "huh? 2014? when did i travel back a decade"
12:02:05FromDiscord<djazz> Merry Christmas and a Happy Nim Year
12:02:06FromDiscord<zumi.dxy> incidentally: https://nim-lang.org/blog/2014/12/29/version-0102-released.html
12:02:12FromDiscord<zumi.dxy> close enough, anyway
12:08:38Amun-Rademotomohiro: https://wandbox.org/permlink/CtVjomaucvxRSVHZ
12:08:45Amun-Racannot bind rvalue '(int)p' to 'int&'
12:08:48FromDiscord<narimiran> Nim 2.0.14 released: https://nim-lang.org/blog/2024/12/24/nim-2014-released.html
12:09:07Amun-Rafor the last time, int& can only contain int type
12:09:44FromDiscord<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:58Amun-Rademotomohiro: you were trying to assign 'int' to 'refp' by taking the 'int' from dereferencing pointer 'p'
12:13:08Amun-Raremove count like and it'll still segfault
12:16:56Amun-Rayou can only have nullptr if you reference a pointer, like here: https://wandbox.org/permlink/xzSN9xCfjiRhLdVK
12:24:30FromDiscord<k0ts> sent a code paste, see https://play.nim-lang.org/#pasty=jFnOAblq
12:26:38Amun-Rathe problem with that code is that line 5 is UB
12:26:53Amun-Ra*p is of int type
12:26:58FromDiscord<k0ts> I believe you
12:27:06FromDiscord<k0ts> but in the end we still have a reference to nullptr
12:27:13FromDiscord<k0ts> I think that's what demo was getting at
12:27:30Amun-Raand &refp in 6 is (int *)
12:27:44Amun-Rano
12:27:49FromDiscord<k0ts> ok
12:27:52Amun-Rawe never had reference to nullptr
12:27:56FromDiscord<k0ts> ok
12:28:15Amun-Raint* p = nullptr ← p is of (int *) type, and it contains null pointer
12:29:13Amun-Raint& refp = *p; ← p is (int *), dereferencing p makes it (int)
12:30:46Amun-Rahttps://wandbox.org/permlink/fC68wpNiLMnv6Etd
12:31:35Amun-Rahere refa is really reference to a, refp is really a reference do dereferenced value from pointer
12:33:19Amun-Rahttps://wandbox.org/permlink/1ClEGIL2bZee6q7N
12:35:11Amun-Raend 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:03Amun-Rabottom 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:39FromDiscord<requiresupport> `Warning: See corresponding Defect; IndexError is deprecated [Deprecated]`↵↵What to use instead of indexerror? 🤔
17:26:22*beholders_eye joined #nim
17:47:53FromDiscord<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:12FromDiscord<odexine> In reply to @requiresupport "`Warning: See corresponding Defect;": IndexDefect?
18:06:38FromDiscord<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:12FromDiscord<odexine> I was more under the impression that they were raising an error
18:14:14FromDiscord<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:08FromDiscord<thepotatochronicler> Sorry to bother, is there a way to get the build OS instead of the host OS?
19:53:11FromDiscord<bostonboston> Store it as a const string?
19:53:44Amun-Rahmm, I don't think there's sth like buildOS
19:54:22FromDiscord<thepotatochronicler> Huh, nimscript has buildOS 🤔
19:55:09FromDiscord<bostonboston> You can make a strdefine and in your nimble file call buildOS to fill it
19:55:48Amun-Raoh
19:55:50Amun-Rahttps://play.nim-lang.org/#pasty=KDYasYPJ
19:56:16FromDiscord<thepotatochronicler> system.buildOS also exists... apparently? 😵‍💫
19:56:23Amun-Rayes
19:56:31Amun-Raapparently :)
19:56:33Amun-RaTIL
19:57:14Amun-Raand there's also buildCPU
19:57:23FromDiscord<thepotatochronicler> Or that might have been only because I was running it in a .nims file mmm
19:58:06Amun-Raand there are handfull functions in pure/distros
19:59:32FromDiscord<demotomohiro> Here is how I get `buildOS`: https://github.com/demotomohiro/pathX/blob/main/src/pathX/base.nim#L19
20:01:01Amun-Ranice
20:04:42FromDiscord<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:21FromDiscord<thepotatochronicler> I tried std/pathnorm normalizePath, but it doesn't let me specify the second argument for some reason :
20:05:23FromDiscord<thepotatochronicler> (edit) removed ":"
20:05:31Amun-Raall modern OS-es understand / as path separators :)
20:06:10Amun-Rathepotatochron: std/paths got you covered
20:06:15FromDiscord<thepotatochronicler> In reply to @Amun-Ra "all modern OS-es understand": It turned it into \\, so I get \home\user\...
20:06:50FromDiscord<thepotatochronicler> Because I am trying to build on Linux and target Windows, so std/paths don't got me covered
20:07:09Amun-Rahmm, that should be cross-compiling aware
20:07:44FromDiscord<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:06Amun-Rathat should work at compile-time
20:08:28FromDiscord<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:18Amun-Rastd/private/osseps.nim
20:09:21FromDiscord<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:27Amun-Rayes, it should work when cross-compiling
20:09:41Amun-Rado you have "windows" defined?
20:09:57FromDiscord<thepotatochronicler> In reply to @Amun-Ra "do you have "windows"": It is defined because of cross-compiling
20:10:19FromDiscord<thepotatochronicler> But I need some paths for the build OS, for the `compile` pragma
20:10:59FromDiscord<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:10Amun-Rawhen defined windows: const somepath = r"foo\bar" else: const comepath = "foo/bar"
20:11:54Amun-Ra"foo/bar" will work on windows, too
20:12:07Amun-Rashould*
20:12:15FromDiscord<thepotatochronicler> std/pathnorm normalizePath should work, but for some reason, when I specify the directory separator, it causes a compile error
20:13:23Amun-Rawhat error?
20:13:53FromDiscord<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:08FromDiscord<thepotatochronicler> using?
20:14:24Amun-Rathat's default argument value
20:14:35FromDiscord<thepotatochronicler> In reply to @Amun-Ra "that's default argument value": Yes, but there is no type for the argument
20:14:36Amun-Rasomething like (x = 2)
20:14:47Amun-Ratype is derived from the value
20:14:57FromDiscord<thepotatochronicler> Okay, makes sense
20:15:02Amun-Ra(dirSep: string = DirSep)
20:15:19FromDiscord<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:26Amun-Rasorry, DirSep is char
20:15:32FromDiscord<thepotatochronicler> OH
20:15:42FromDiscord<thepotatochronicler> Now that makes sense
20:15:55Amun-Rayes, that's the culprit :>
20:16:19FromDiscord<thepotatochronicler> It magically works now, I love you
20:16:29Amun-Rathanks, I love /me too ;)
20:17:25Amun-Rathat automatic type derivation has an official name, but I can't recall it
20:17:47FromDiscord<demotomohiro> There are many difference between windows path and linux path. Case sensitive or not, has drive latter or not, etc.
20:21:09FromDiscord<thepotatochronicler> There is a way to specify the name/type of the c compiler, but not the path to the compiler 🥴
20:21:47Amun-Ra"type inference", that was it
20:22:08Amun-Rayou can specify full path to the compiler
20:22:32Amun-Ra--gcc.exe='/opt/3rdparty/gcc/bin/gcc' …
20:22:51Amun-Raand --gcc.linkerexe
20:23:08Amun-Raif you switch compiler to clang replace "gcc" with "clang"
20:24:57Amun-Rathe other option is --cc=env and setting relevant environment variables
20:26:35FromDiscord<thepotatochronicler> Ah, and compiler.cpp.exe for C++, we're almost home
20:26:44Amun-Rasure
20:27:02Amun-RaI keep forgetting about C++ compilers, I usually use C target by default
20:28:08FromDiscord<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:16Amun-Ramhm
20:28:58Amun-Rayou can interface js code on the same principle
20:29:11FromDiscord<thepotatochronicler> That's the second selling point
20:29:41Amun-RaI even compiler nim code for old Amiga OSes
20:29:44Amun-Racompiled*
20:30:59FromDiscord<demotomohiro> Here is how to interfaces C++ lib: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma
20:31:20Amun-RaI even played with wasm a little, https://retro.rocks/tmp/ronin/emscripten/
20:32:52FromDiscord<demotomohiro> There are experimental features to import more C++ code https://nim-lang.org/docs/manual_experimental.html#virtual-pragma
20:50:45FromDiscord<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:38Amun-Raspaces are fine
20:51:52Amun-Rahow did you provide these options?
20:52:36Amun-Rayou can pass any number of options with --passc (for the compiler) and --passl (for the linker)
20:52:44Amun-Rarepeat those as much as you like
20:52:48FromDiscord<thepotatochronicler> sent a code paste, see https://play.nim-lang.org/#pasty=vfkeCAOk
20:53:02FromDiscord<thepotatochronicler> The last part breaks it
20:53:16Amun-Rawhat's the error?
20:53:42FromDiscord<thepotatochronicler> https://media.discordapp.net/attachments/371759389889003532/1321219274236366848/image.png?ex=676c70d6&is=676b1f56&hm=442f31c2320e78afe6b2ec7ab08025cb08fafdb1b58206ea61585b739fa15c75&
20:53:59FromDiscord<thepotatochronicler> It thinks they are run arguments
20:54:32FromDiscord<Elegantbeef> It's easier to make a config.nims with a `when defined(windows): ....`
20:54:43FromDiscord<Elegantbeef> then you can `nimble build -d:windows` and call it a day
20:54:56FromDiscord<thepotatochronicler> Planning on that, just testing for now this way
20:54:59FromDiscord<Elegantbeef> rather `nimble build --os:windows`
20:55:09Amun-Raand -b=cpp to switch to c++ backend
20:55:11FromDiscord<Elegantbeef> Well I'd test it using `nim c` over `nimble`
20:55:54FromDiscord<thepotatochronicler> Nimble seems to have it's own quirks, so it seems to make sense to test using it mmm
20:56:04FromDiscord<Elegantbeef> Not if you plan on using a config
20:56:34FromDiscord<thepotatochronicler> Fair
20:57:59FromDiscord<Elegantbeef> You might be able to move the flags before `build`
21:04:52FromDiscord<thepotatochronicler> Now we're thinking with portals 😄
21:09:10FromDiscord<thepotatochronicler> One, hopefully last thing I am unsure of, preferred way to create C defines? `passc` with -DName?
21:09:48FromDiscord<Elegantbeef> Yea
21:09:56FromDiscord<Elegantbeef> You also can do it in your code if it's a C library you're binding
21:10:05FromDiscord<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:03FromDiscord<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:58FromDiscord<thepotatochronicler> Is there some kind of annotation or a pragma that says that a procedure returns a non-nil pointer?
22:19:57Amun-Rahttps://nim-lang.org/docs/manual_experimental_strictnotnil.html
22:20:22Amun-Raor just return non-ref object
23:16:44*beholders_eye joined #nim