<< 07-08-2025 >>

00:29:28FromDiscord<bosinski2023> hi, i struggle with smth wierd. I have a tiny nim-module, that uses one C-function and a -struct - it's header-only. And all is nice & fine, runs and results from C-land arrive. I put export-mark on the nim-type, and the nim-function and compile. When i import this module from another nim-module, the C-type is not there ? `error: unknown type name 'CompilerVI'` ? ↵Is it vaporized ? hiding somewhere ?
00:29:56FromDiscord<Elegantbeef> Did you forget to export?
00:29:56FromDiscord<bosinski2023> (edit) "export-mark" => "export-markers"
00:30:03FromDiscord<Elegantbeef> Oh wait nevermind misread
00:30:52FromDiscord<bosinski2023> i did explicit `export CompilerVI, readVI, version` additional to the export markers - no change ?
00:31:49FromDiscord<bosinski2023> I trie to import the whole module or the three parts - makes no difference..
00:31:59FromDiscord<Elegantbeef> How are you compiling the C code?
00:32:00FromDiscord<bosinski2023> (edit) "trie" => "tried"
00:33:03FromDiscord<bosinski2023> plain and simple `nim c -rf -d:debug` nothing special, the C-headerinfo is inside a `{.emit}` inside
00:33:19FromDiscord<bosinski2023> (edit) "`{.emit}` inside" => "`{.emit}`.."
00:33:38FromDiscord<Elegantbeef> Do you have the emit emitting at the type section?
00:34:19FromDiscord<bosinski2023> I tried making a lib before, via `-app:lib` and it popped out a `.dylib` as expected.
00:35:40FromDiscord<bosinski2023> sent a code paste, see https://play.nim-lang.org/#pasty=LonoINLC
00:35:58FromDiscord<Elegantbeef> You are funny
00:36:22FromDiscord<bosinski2023> In reply to @Elegantbeef "You are funny": :))) thx - is it so stupid - what i did ?
00:36:24FromDiscord<Elegantbeef> `{.importc: "CompilerVI", header: "../whichCompiler.h".}`
00:37:11FromDiscord<Elegantbeef> May also need a `{.passI`
00:37:18FromDiscord<bosinski2023> In reply to @Elegantbeef "`{.importc: "CompilerVI", header: "../whichCompiler": no, no - this is the part that works just nicely - it compiles and results come in..
00:37:20FromDiscord<Elegantbeef> whoops `{.passC:"-I".}`
00:37:31FromDiscord<Elegantbeef> Replace it with the actual way of doing it
00:37:43FromDiscord<Elegantbeef> Emit is a hack 99% of the time
00:39:56FromDiscord<bosinski2023> In reply to @Elegantbeef "Emit is a hack": ok, great, so - can i do `{.header :"./../whichCompiler.h".}` - good i just do it with `{.passC:"-I".}`
00:40:17FromDiscord<Elegantbeef> Well the `passC` is for if you need to include the path
00:40:33FromDiscord<Elegantbeef> You may not I don't recall what `header` actually causes Nim to emit
00:43:36FromDiscord<bosinski2023> In reply to @Elegantbeef "You may not I": gettin warmer : now thing does not compile and shows the same error, i had when importing : "Unknown type". Shall i put the `{.header: "".}` on the the type, too ?
00:43:49FromDiscord<Elegantbeef> The header goes on the type
00:44:07FromDiscord<Elegantbeef> Header only ever goes on types or procs to say "when you use this include the header"
00:45:56FromDiscord<bosinski2023> In reply to @Elegantbeef "Header only ever goes": ahhh, good - still getting more feedback :: "header file not found.."
00:47:14FromDiscord<bosinski2023> (edit) "found.."" => "found.."↵thx, fixed it - great,, the thing runs again..."
00:49:13FromDiscord<bosinski2023> In reply to @Elegantbeef "Header only ever goes": but some prrob remains - i still get linker-errors when i try to import it... Do i need to put the header on the C-func, too ?
00:52:38FromDiscord<bosinski2023> hmm, now it gettin scary : `nim-#devel/compiler/extccomp.nim(431, 13) compiler msg initiated here [MsgOrigin]↵duplicate symbol '_vi' in:` ?↵shall i clean my compile-cache ?
00:52:49FromDiscord<bosinski2023> (edit) "it" => "its"
01:04:59*tiorock joined #nim
01:04:59*tiorock quit (Changing host)
01:04:59*tiorock joined #nim
01:04:59*rockcavera quit (Killed (erbium.libera.chat (Nickname regained by services)))
01:04:59*tiorock is now known as rockcavera
01:07:07*tiorock joined #nim
01:07:07*tiorock quit (Changing host)
01:07:07*tiorock joined #nim
01:07:07*rockcavera is now known as Guest5746
01:07:07*Guest5746 quit (Killed (zirconium.libera.chat (Nickname regained by services)))
01:07:07*tiorock is now known as rockcavera
01:29:27FromDiscord<bosinski2023> @ElegantBeef sry, but i'm just guessing now.. when i compile the second module the linker complain about three duplicate symbols - thats all i have defined 🙂 `ld: 3 duplicate symbols for architecture x86_64`. How come module-1 works fine - but module-2 cannot use/import it ?↵It a simple preprocessor-thing - confused - https://play.nim-lang.org/#pasty=wAMxZxeY
02:20:29*shwouchk quit (Ping timeout: 240 seconds)
02:22:33*shwouchk joined #nim
02:24:26FromDiscord<benjamin_45476> sent a code paste, see https://play.nim-lang.org/#pasty=URIhOmEg
02:24:53FromDiscord<benjamin_45476> (edit) "https://play.nim-lang.org/#pasty=pZSQeYKt" => "https://play.nim-lang.org/#pasty=cYhALyHq"
02:26:00FromDiscord<Elegantbeef> No clue depends on your layout
02:28:14FromDiscord<Elegantbeef> Inheritance is a awful affair with serialization
02:35:17FromDiscord<benjamin_45476> I want to say these different structs need to implement the toTable and toJson interfaces/traits, which I would like to do without inheritance
02:39:42FromDiscord<Elegantbeef> What's the issue with just writing the procs?
02:51:22FromDiscord<benjamin_45476> It's mostly a desire to reduce boilerplate—depending on the user's command, data is fetched and deserialized into an object, and then it's serialized back depending on the specified format, either as a table or as JSON. I could easily add a serializeData proc after every fetchJson[T] call, but I was hoping to be able to do the serialization just once. But it would have to be where the data is held as some more generic type.
02:54:45FromDiscord<Elegantbeef> What's causing the boiler plate?
02:55:11FromDiscord<Elegantbeef> Like you could make a pragma to attach that string to a type then never have to write a `fetch` proc for it
03:11:25*rockcavera quit (Remote host closed the connection)
03:24:05FromDiscord<benjamin_45476> sent a code paste, see https://play.nim-lang.org/#pasty=CuFBkhjg
03:25:11FromDiscord<benjamin_45476> The pragma approach I have not considered/am not familiar with
03:35:08FromDiscord<Elegantbeef> https://play.nim-lang.org/#pasty=WjzBtpbe
03:35:55FromDiscord<Elegantbeef> If you want it even niftier use https://github.com/alaviss/union then you can even handle it at runtime using `unpack`
03:57:38*jailop joined #nim
03:58:58*jailop quit (Remote host closed the connection)
04:06:56FromDiscord<benjamin_45476> In reply to @Elegantbeef "https://play.nim-lang.org/#pasty=WjzBtpbe": This looks really cool—when I declare the different types as a union instead of with inheritance, looks like my previous `let data = case command` block doesn't like the different types returned by the different branches. So trying to understand the pragma/typedesc stuff that you put in there
04:07:17FromDiscord<Elegantbeef> Well yea cause it's generic
04:07:24FromDiscord<Elegantbeef> If you want multiple valid values use an object variant and the `field` iterator
04:40:00FromDiscord<benjamin_45476> OK, I'm seeing what you did with the typedesc, wondering if there's a way to translate from a string given on the command line to a typedesc like that
04:42:16FromDiscord<Elegantbeef> Not at runtime cause Nim is statically compiled
04:49:51FromDiscord<benjamin_45476> OK, I'll keeping looking at this—thanks for helping
05:05:42FromDiscord<ajusa> If I have two procs that call each other, my only option is still to forward declare them, right? We're coming up on 10 years since https://github.com/nim-lang/rfcs/issues/6 (I think nimony is promising to fix this), just want to make sure I'm not missing anything.
05:06:24FromDiscord<Elegantbeef> Yes
05:06:38FromDiscord<Elegantbeef> It's a shame it's fixing it! 😄
05:14:53FromDiscord<ajusa> why?
05:15:00FromDiscord<ajusa> can't tell if you are sarcastic or not
05:15:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=DhWjUtlQ
05:16:08FromDiscord<Elegantbeef> I like my code to be written in order of usage so that you can easily understand where things are where they're introduced
05:16:08FromDiscord<ajusa> Fair enough, being able to read top to bottom is important
05:17:25FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=vAApCPML
05:26:35*SchweinDeBurg quit (Quit: WeeChat 4.8.0-dev)
05:31:01*nils` quit (Ping timeout: 248 seconds)
05:39:01*skippy8 joined #nim
06:20:09*SchweinDeBurg joined #nim
06:36:01FromDiscord<albassort> how can i construct a file handler from an FD to get a pea --- wait i dont need to do this
06:36:06FromDiscord<albassort> hell fuck it how would i do it anyway
06:36:10FromDiscord<albassort> how do i get a path from a fd
06:37:25FromDiscord<Elegantbeef> There's no way in the stdlib and it's a platform dependant operation
06:38:08FromDiscord<albassort> good thing i dont need to do this!
06:47:26FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#pasty=JlZrHupt
06:47:30FromDiscord<albassort> how do you feel about this beef?
06:47:42FromDiscord<albassort> (edit) "https://play.nim-lang.org/#pasty=yKbaMNpx" => "https://play.nim-lang.org/#pasty=VNCHadBm"
06:47:46FromDiscord<Elegantbeef> Why is it so bad
06:48:02FromDiscord<albassort> couldn't think of an intermediate name for the cint-ification
06:48:04FromDiscord<Elegantbeef> `let fd = mkFifio(config.callbacks.namedPipe.path 0b000_110_110_110.cint)`
06:48:33FromDiscord<albassort> i was worried that it would have too many leading bits
06:48:51FromDiscord<Elegantbeef> How
06:48:52FromDiscord<albassort> idk if it would default to int64 or int16
06:49:13FromDiscord<Elegantbeef> But you're defining the low bits
06:49:38FromDiscord<albassort> yeah but what if it didn't round upt to the nearest log2 but instead just used my compilation target
06:50:01FromDiscord<Elegantbeef> It doesn't matter cause cint is 32bit so it'll mask the high 32 when converting
06:50:16FromDiscord<albassort> i didn't know thank you
06:50:29FromDiscord<Elegantbeef> Well they're low anyway
06:50:33FromDiscord<Elegantbeef> So there is no range issue either
06:51:10Amun-Raeven if cint was 16-bit pre-conversion to uint16 solves nothing
06:51:14FromDiscord<Elegantbeef> `0x0000_0000_0000_0000u8` is valid comically enough
06:51:53FromDiscord<Elegantbeef> It's even worse than that cause it's not a bit signature conversion
06:51:59*cornfeedhobo quit (Remote host closed the connection)
06:52:01FromDiscord<Elegantbeef> It's a value convert
06:52:16Amun-Ramhm
06:52:17FromDiscord<albassort> i was more wondering how you felt about using binary instead S_IRUSR and such
06:52:35FromDiscord<Elegantbeef> I'd prefer constants that are clear
06:52:45Amun-Raunix permission is that rare place I still use octals
06:52:55FromDiscord<albassort> do we have octals?
06:52:57FromDiscord<albassort> i forget
06:52:59Amun-Ra0o644
06:53:11FromDiscord<albassort> i didn't know about this i will use this instead
06:55:15FromDiscord<albassort> oh yeah and that is through, cint is of fixed size either way so using uint16 wouldn't save me lol
07:01:22FromDiscord<kentrid> sent a long message, see https://pasty.ee/EPfZIyLM
07:03:18FromDiscord<albassort> no
07:04:36FromDiscord<albassort> i like to code i don't like typing in my code to a trillion dollar corporation then fix the code it fucks up
07:35:06*_________ quit (Ping timeout: 252 seconds)
09:03:51*nils` joined #nim
09:13:36FromDiscord<lainlaylie> this
10:54:24*oz quit (Server closed connection)
10:55:09*ox joined #nim
10:55:47*nils` quit (Ping timeout: 272 seconds)
11:03:28FromDiscord<albassort> ambiguous call; both net.newSocket(domai↵n: cint, sockType: cint, protocol: cint, buffered: bool, inheritable: bool) [proc declared in /home/user/.choose↵nim/toolchains/nim-2.2.0/lib/pure/net.nim(282, 6)] and net.newSocket(domain: Domain, sockType: SockType, protoco↵l: Protocol, buffered: bool, inheritable: bool) [proc declared in /home/user/.choosenim/toolchains/nim-2.2.0/lib
11:03:37FromDiscord<albassort> var unixSocket = newSocket(AF_UNIX,SOCK_SEQPACKET, IPPROTO_IP)
11:03:39FromDiscord<albassort> what the compiler doin
11:03:53FromDiscord<albassort> (edit) "var unixSocket = newSocket(AF_UNIX,SOCK_SEQPACKET, IPPROTO_IP)" => "sent a code paste, see https://play.nim-lang.org/#pasty=RLWPqDir"
11:05:28FromDiscord<albassort> (edit) "ambiguous call; both net.newSocket(domai↵n: cint, sockType: cint, protocol: cint, buffered: bool, inheritable: bool) [proc declared in /home/user/.choose↵nim/toolchains/nim-2.2.0/lib/pure/net.nim(282, 6)] and net.newSocket(domain: Domain, sockType: SockType, protoco↵l: Protocol, buffered: bool, inheritable: bool) [proc declared in /home/user/.choosenim/toolchains/nim-2.2.0/lib" => "sent a code paste, see https://play.nim
11:06:17FromDiscord<albassort> so AF_UNIX are not undefined, no, they're actually None?
11:06:45FromDiscord<albassort> despite the fact that i imported nativesockets
11:12:21Amun-Ranativesocket's AF_UNIX differs from posix's AF_UNIX
11:16:07FromDiscord<albassort> ahhhhhhhhhhhhhhh
11:16:10FromDiscord<albassort> thank you
11:16:50FromDiscord<albassort> perhaps the compiler could be more evident about the ambiguous being that a variable is specifically ambigious
11:16:53FromDiscord<albassort> (edit) "ambigious" => "ambiguous"
11:19:12Amun-Ra(iirc) it notices the variable is ambiguous if the type is the same; here the proc signature was ambiguous
11:19:19Amun-Rabut I know what you mean
11:51:27*nils` joined #nim
12:01:50FromDiscord<TӨMΛ ☠> I wonder, can use of async/parallelism cause problems if it's done in lib? Like force usage of async in context lib user wouldn't like to have it?
12:02:05FromDiscord<TӨMΛ ☠> (edit) "cause problems" => "be problematic"
12:02:40FromDiscord<albassort> In reply to @toma400 "I wonder, can use": yes because sharing async futures between threads can have issues
12:03:06FromDiscord<albassort> i went as far to make my own http server based on the async one in the stdlib so i could share ie between threads
12:03:27FromDiscord<albassort> im using it right now actually, in two separate projects, so its very worth it to me
12:03:37FromDiscord<albassort> oh three
12:20:46*jn left #nim (#nim)
13:04:07*fabricio joined #nim
13:05:20FromDiscord<saint._._.> In reply to @kentrid "Got to try GPT-5": Interesting , when is it coming out?
13:05:34FromDiscord<saint._._.> What lsp are people using for nvim now? Anything changed?
13:05:51FromDiscord<saint._._.> (edit) "What lsp are people using for nvim now? Anything changed? ... " added "(separate question from the gpt-5 thing)"
13:22:32*skippy8 quit (Quit: WeeChat 4.6.3)
13:47:33*nils` quit (Ping timeout: 276 seconds)
13:57:29*fabricio quit (Ping timeout: 240 seconds)
13:58:04FromDiscord<aintea> In reply to @saint._._. "What lsp are people": The official one works the best
14:05:25*_________ joined #nim
14:05:42FromDiscord<saint._._.> In reply to @aintea "The official one works": Which is the official one, aren't there two
14:21:51*ox is now known as oz
14:45:47*nils` joined #nim
14:47:30FromDiscord<nasuray> In reply to @saint._._. "Which is the official": the one under nim-lang org .... https://github.com/nim-lang/langserver
14:48:13FromDiscord<saint._._.> Ohh okay
14:48:42FromDiscord<janakali> yes, nimlangserver + nimlsp plugin is pretty stable for me
14:50:22FromDiscord<janakali> nimlangserver + nvim-lspconfig plugin
14:50:38FromDiscord<saint._._.> Do you have to use coc.nvim
14:50:41FromDiscord<saint._._.> With nimlangserver
14:50:44FromDiscord<saint._._.> I think you don't right?
14:52:43FromDiscord<saint._._.> Okay yeah I think I can use lspconfig and mason_lsp to set it up
14:52:51FromDiscord<saint._._.> Idk why I switched bakc to nimls
14:53:01FromDiscord<saint._._.> I think there was some issue about like 100% cpu being used or something
14:53:10FromDiscord<saint._._.> Maybe that's resolved now
14:55:45FromDiscord<janakali> It's a choosenim issue and you might need to update it, but on windows it's not fixed↵You can also install grabnim instead: https://forum.nim-lang.org/t/13132
15:19:52*fabricio joined #nim
15:25:05*skippy8 joined #nim
19:07:32FromDiscord<hawkey5212> how to take the first N elements of an iterator? e.g. `foo.filterIt(...).take(4).mapIt(....)`?
19:07:59FromDiscord<hawkey5212> im using sequtils, but can't find any function using DDG or LLM that does this.
19:08:05FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=qfuYffwM
19:09:07FromDiscord<heysokam> In reply to @hawkey5212 "how to take the": have you tried `iterator_call()[ start .. end ]`?
19:09:46FromDiscord<hawkey5212> sent a code paste, see https://play.nim-lang.org/#pasty=nGjwsDoR
19:10:08FromDiscord<hawkey5212> In reply to @heysokam "have you tried `iterator_call()[": yes. doesn't work if the iterator is empty
19:10:41FromDiscord<heysokam> In reply to @hawkey5212 "can't answer your juestion,": that's dead code from a recent rename
19:10:57FromDiscord<heysokam> but yea, it doesn't match
19:11:09FromDiscord<heysokam> (edit) "but yea, it doesn't match ... " added "because of the renames/prototyping"
19:12:45FromDiscord<hawkey5212> does nim even _have_ a means to only take the first N elements of an iterator?
19:13:11FromDiscord<hawkey5212> it's a pretty basic thing, so I can't imagine it wouldn't, but I've seen stranger design decisions abound.
19:42:42FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=dPqtZTgn
19:44:09FromDiscord<Elegantbeef> private access in the scope
19:44:58FromDiscord<heysokam> isn't the file the scope?
19:45:18FromDiscord<Elegantbeef> No clue I never use it, it was made by timothee so it probably doesn't work properly
19:46:45FromDiscord<heysokam> It does work if I put it into each function separately, apparently 🤷‍♂️
19:47:39FromDiscord<Elegantbeef> Like I said it was made by Timothee
19:47:55*skippy8 quit (Quit: WeeChat 4.6.3)
19:48:24FromDiscord<heysokam> Who is that?
19:48:41FromDiscord<Elegantbeef> Someone that used to contribute to Nim and a lot of his code partially worked
19:49:34FromDiscord<heysokam> i see
19:49:47FromDiscord<Elegantbeef> `iterable` was also their doing
19:54:27FromDiscord<Elegantbeef> Not to say I don't use iterable, but it requires explicit `.items` for usage of sequences and arrays
19:54:46FromDiscord<Elegantbeef> It also only works in templates!
20:14:06FromDiscord<ollicron_53732> I made this chat server using only asynchronous operations 😄
20:14:29FromDiscord<ollicron_53732> I wanna show the whole world but it's not ready yet
20:14:53FromDiscord<ollicron_53732> (edit) "I made this chat server using only asynchronous operations ... 😄" added "in Nim"
20:15:30FromDiscord<ollicron_53732> sadly I don't know how to asynchronously access stdin and stdout in Windows 🤷‍♂️
20:26:45*fabricio quit (Quit: WeeChat 3.5)
20:38:25FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=AJCeMxFZ
20:40:54FromDiscord<ollicron_53732> sent a code paste, see https://play.nim-lang.org/#pasty=xWUqEadd
20:41:13FromDiscord<heysokam> In reply to @ollicron_53732 "use an iterator 🤷‍♂️": The iterator has to implement the answer to my question
20:43:46FromDiscord<ollicron_53732> In reply to @heysokam "The iterator has to": with an iterator you yield where values for important where it's not nil....sorry I'm not sure really just trying to help.
20:44:20FromDiscord<ollicron_53732> then on a for loop you know you do the if screen nbr ==0 etc
20:44:23FromDiscord<Elegantbeef> You're right so it's fine
20:44:57FromDiscord<heysokam> I don't want to implement an iterator. I just want to know how to convert the logic
20:45:11FromDiscord<heysokam> This is a simple for loop 🤷‍♂️
20:45:18FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=DOxoACtU
20:45:31FromDiscord<Elegantbeef> But it's just a while loop really
20:45:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=FEIQvVax
20:45:57FromDiscord<heysokam> when does each thing from this for looop happen, though 🤔
20:46:21FromDiscord<heysokam> important1/2 could go before or after the break, and that would change the behavior
20:47:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=wVYILRBa
20:47:21FromDiscord<heysokam> nvm, asked on a C group and they said it happens after the break
21:18:27*rockcavera joined #nim
22:09:40*xet7 quit (Remote host closed the connection)
22:47:02*jailop joined #nim
23:11:14*jailop quit (Ping timeout: 260 seconds)
23:11:26*jailop joined #nim
23:24:45*pmp-p quit (Ping timeout: 276 seconds)
23:26:14*jailop quit (Ping timeout: 245 seconds)
23:26:34*jailop joined #nim
23:30:27*pmp-p joined #nim