<< 18-10-2025 >>

00:02:36*bcksl joined #nim
00:07:50*end joined #nim
01:20:57*rockcavera joined #nim
01:23:38*yeti quit (Ping timeout: 248 seconds)
01:24:06FromDiscord<microssd.> how to put compile options in .nimble?
01:25:35FromDiscord<janakali> @heysokam↵https://nim-lang.org/docs/ctypes.html#BiggestInt https://nim-lang.org/docs/dollars.html#%24%2Cint64↵https://github.com/nim-lang/Nim/tree/version-2-2/lib/system/dollars.nim#L44
01:35:59*yeti joined #nim
01:45:11FromDiscord<janakali> sent a code paste, see https://play.nim-lang.org/#pasty=aZjsLAKc
01:46:31FromDiscord<janakali> `nimble foo` for running the task, but if you want `nimble build/install` to work correctly use `config.nims`
01:48:14FromDiscord<janakali> (edit) "task, but" => "task.↵But" | "work correctly" => "see the flags -"
01:50:27FromDiscord<microssd.> where is config.nims?
01:56:50FromDiscord<microssd.> oh I see I have to create it
01:58:09FromDiscord<janakali> usually in the project folder, but can be in any parent folder or beside the entry point file. Yes you need to create it
02:00:59FromDiscord<janakali> see "NimScript as a configuration file":↵https://nim-lang.org/docs/nims.html
02:17:29FromDiscord<microssd.> In reply to @janakali "usually in the project": how do I run config.nims ?
02:27:46FromDiscord<microssd.> I did it like this: https://media.discordapp.net/attachments/371759389889003532/1428932541691334747/image.png?ex=68f44ca2&is=68f2fb22&hm=c5e9dae29082de8f626bfe95381c5292a5d1a5e6da8fff0d246c63e562187e0c&
02:28:17FromDiscord<microssd.> but I cant run it
02:32:12FromDiscord<microssd.> even if I put config.nims above src
02:32:48*Guest13 joined #nim
02:35:20*Guest13 quit (Client Quit)
02:37:44FromDiscord<microssd.> is there a documentation for this?
02:57:57FromDiscord<janakali> sent a code paste, see https://play.nim-lang.org/#pasty=SPpjfZRg
03:02:32FromDiscord<janakali> tasks go in `.nimble`↵flags go in `config.nims` (at least that's what I do)↵↵`.nimble` is read only by `nimble` command, `config.nims` is read by nimble and compiler e.g. you can do `nim c main.nim` and it will pull flags from config.
03:12:48FromDiscord<janakali> In reply to @microssd. "is there a documentation": https://discord.com/channels/371759389889003530/371759389889003532/1428925796336275567
04:21:15*SchweinDeBurg quit (Quit: WeeChat 4.8.0-dev)
04:21:51*SchweinDeBurg joined #nim
07:06:33FromDiscord<kiloneie> Freaking gremlins dude. Code i made yesterday, not working, copy paste what i put into issue after 5-8 min of O,O, now it works... i wish i knew what was different...
07:07:59FromDiscord<kiloneie> o.O https://media.discordapp.net/attachments/371759389889003532/1429003057508651018/Screenshot_2025-10-18_09-07-34.png?ex=68f48e4e&is=68f33cce&hm=8c556554bfb2c7e79048de2cc852d0b324b16265124b7b469b196997e8400d4a&
07:08:45FromDiscord<kiloneie> This is like how i was setting up today's workout on my phone in bed this morning, apparently your breath makes touch screen go nutz <.<.
07:11:17FromDiscord<kiloneie> Idk, maybe somehow the runnable example was not indented enough, the error message was "The expression has not type", which tells me nothing...
07:18:39Amun-Raalways git commit your code :>
07:32:29FromDiscord<nnsee> In reply to @kiloneie "o.O": well it looks like the indentation was wrong
07:32:37FromDiscord<nnsee> so the body was not in the scope of the template you defined
07:32:50FromDiscord<nnsee> copy-pasting probably pasted it with the correct indentation
07:44:19FromDiscord<janakali> In reply to @Amun-Ra "always git commit your": I have persistent history with backups in my neovim for that. I can literally go back to any point in time for every single file I was editing in the last ~2 years.
08:08:15Amun-Rajanakali: I store everything in my local repo, I can check the code difference between any days
08:27:49FromDiscord<kiloneie> Well, commit history has just so much, and i also 95% of the time copy paste my solutions into my issues on github.
08:27:59FromDiscord<kiloneie> So i got a pretty good history/backup i'd say
08:32:33FromDiscord<kiloneie> Is there a purpose to proc 2's tuple parameter ? https://media.discordapp.net/attachments/371759389889003532/1429024337205268632/Screenshot_2025-10-18_10-31-59.png?ex=68f4a21f&is=68f3509f&hm=5e695f7f5cf726ebf3929c6d2f86cda8ef340a613b64b7d2504247519dcaac6c&
08:36:56FromDiscord<alexander888alexander> I always wondered why python has tuples and frozen sets
08:37:03FromDiscord<alexander888alexander> why can't we just have constants
09:02:32FromDiscord<aethrvmn> In reply to @janakali "put flags into `config.nims`": Is this getting changed for Nim3?
10:10:45*zero` quit (Ping timeout: 256 seconds)
10:11:22FromDiscord<spotlightkid> @alexander888alexander\: Because Python is a dynamic language, i.e it has dynamic dispatch of methods, attributes etc. Making something immutable makes handling these objects more efficient, because the number of possible operations on/with them is much smaller.↵Why immutability is bound to the type rather than a variable qualifier like `const`. Because in Python variables are just labels and what they point to can be switched out
10:23:48*zero` joined #nim
11:42:18FromDiscord<.tokyovigilante> If I have a seq[float32], is there any better way to calculate RMS (root mean square) than `sqrt(foldl(values, a + b b) / values.len.float32)`↵`
11:51:01*zero` quit (Ping timeout: 264 seconds)
11:51:19*zero` joined #nim
12:19:57FromDiscord<ezic9276> sent a code paste, see https://play.nim-lang.org/#pasty=WzwPuPsE
12:20:42FromDiscord<ezic9276> (edit) "https://play.nim-lang.org/#pasty=rnZVWRXm" => "https://play.nim-lang.org/#pasty=PiZKivoI"
12:21:13FromDiscord<ezic9276> (edit) "https://play.nim-lang.org/#pasty=jBRaXdvs" => "https://play.nim-lang.org/#pasty=PMdvBDdY"
12:21:31FromDiscord<ezic9276> (edit) "https://play.nim-lang.org/#pasty=nqFMdtbL" => "https://play.nim-lang.org/#pasty=avVQUStk"
12:21:46FromDiscord<ezic9276> (edit) "https://paste.rs/74REE" => "https://paste.rs/hT5rb"
12:25:40*mahlon quit (Ping timeout: 244 seconds)
12:54:28FromDiscord<heysokam> In reply to @janakali "<@186489007247589376> https://nim-lang.org/docs/cty": ty. I arrived at the same files too, but they don't seem to add a `'i64` suffix 🤔 so I'm still puzzled by the error 🙁↵Maybe the error message itself is adding the suffix and its erroring for another reason? 🧩 its really confusing
12:57:28FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=naFzjTKV
13:00:19FromDiscord<ezic9276> So I have to name the attributes, right?
13:00:42FromDiscord<heysokam> a named tuple is still a tuple. I meant to make it a struct
13:08:38FromDiscord<ezic9276> so `object` keyword? but then I have to define [] myself, and I have to specify names, so 2 things that I want to avoid. Why is haveing MyType("a", 1) a bad idea?
13:09:41FromDiscord<ezic9276> (edit) "so ... `object``[]`" added "the" | "[]" => "`[]`" | "haveing" => "having"
13:10:18FromDiscord<ezic9276> (edit) "MyType("a", 1)" => "`MyType("a", 1)`"
13:22:26FromDiscord<heysokam> sent a long message, see https://pasty.ee/LIearMwL
13:23:41FromDiscord<heysokam> The "hack" part was referring to the unbounded nature of the function you described in your example↵`thing[3]` would crash, and your user would have no clue why
13:31:24FromDiscord<ezic9276> sent a code paste, see https://play.nim-lang.org/#pasty=XkCCCmMX
13:32:44FromDiscord<ezic9276> (edit) "https://play.nim-lang.org/#pasty=MUmUnBGg" => "https://play.nim-lang.org/#pasty=quswfXYT"
13:52:49FromDiscord<anuke> Are there any known libraries for LZF compression/decompression in Nim?
15:16:39FromDiscord<TFed> How to iterate a sequence from the end? Dont we have a `reverse()` or `mirror()` function, or iterator like `for i in seq from end:` to iterate the list in reverse
15:18:44FromDiscord<Robyn [She/Her]> In reply to @TFed "How to iterate a": `std/algorithm`
15:19:09FromDiscord<Robyn [She/Her]> Has `reversed` (returns a copy) and `reverse` (in-place)
15:31:41FromDiscord<lainlaylie> sent a code paste, see https://play.nim-lang.org/#pasty=qVAWWtcy
15:42:19FromDiscord<TFed> curious how to use `ritems` iterator 🤔, is it `for i in seq from end` or smth?↵(@lainlaylie)
15:42:49FromDiscord<TFed> oh got it\: `for i in seq.ritems()`
15:42:50FromDiscord<Laylie> just call it like any other iterator
15:42:52FromDiscord<Laylie> yeah that
15:42:59FromDiscord<TFed> thank you
15:44:08FromDiscord<TFed> thank you, also i was looking for reversing a table, however i think i can make the iterator myself now.↵(@Robyn [She/Her])
16:40:54Amun-Raanuke: pure lzf implementation or just a wrapper?
16:45:11FromDiscord<anuke> Either one, but at this point I gave up looking for a library and wrapped it myself <https://github.com/Anuken/nimlzf>
16:45:43Amun-Ranice
16:46:37Amun-Rayou could include errno in IO exception
16:47:01FromDiscord<anuke> errno?
16:47:09FromDiscord<anuke> The library only seems to return 0 as an error code
16:47:31FromDiscord<anuke> there don't seem to be any descriptive errors
16:47:31Amun-Rait stores error code in errno in that case
16:48:00FromDiscord<anuke> what is "errno"?
16:48:13Amun-Rahttps://en.wikipedia.org/wiki/Errno.h
16:48:43FromDiscord<anuke> does nim have an API for accessing errno?
16:49:19Amun-Rahttps://github.com/nim-lang/Nim/blob/devel/lib/std/syncio.nim#L166-L178
16:50:15Amun-Rait's a global variable that stores last function error
16:50:37Amun-Raand strerror in a C standard library that return its string description
16:50:45FromDiscord<anuke> should I copy-paste `errno {.importc, header: "<errno.h>".}: cint` and such into the code?
16:50:58FromDiscord<anuke> as it doesn't seem to be exported
16:51:53Amun-Rait's in standard library, it's safe to just include the line
16:52:11Amun-Rasame with strerror
16:53:05*rockcavera quit (Ping timeout: 256 seconds)
17:00:06FromDiscord<Elegantbeef> https://nim-lang.org/docs/oserrors.html#osLastError does exist
17:03:15Amun-Rasure, but iirc that calls GetLastError on wintendo, and liblzf does not
17:03:24FromDiscord<anuke> ~~too late, I implemented it with the errno imports~~
17:03:26FromDiscord<Robyn [She/Her]> In reply to @TFed "thank you, also i": for reversing a table, you can do `toSeq(tbl.pairs).reversed().initTable`
17:03:54FromDiscord<anuke> for some reason only decompression sets an error code, compression simply returns 0 upon failure
17:04:23FromDiscord<microssd.> hi. I have xml on a string, how do I process it?
17:04:30FromDiscord<Robyn [She/Her]> `pairs` is an iterator that returns the key and value of a table, we capture the data from the iterator with toSeq, reverse the sequence and initialise a new table with this value
17:04:31Amun-Raanuke: good, it wouldn't work as expected on windows if you did
17:04:48FromDiscord<Elegantbeef> Good, who the fuck uses windows! \:D
17:04:58Amun-Ratrue :P
17:05:03FromDiscord<Robyn [She/Her]> In reply to @microssd. "hi. I have xml": https://nim-lang.org/docs/xmlparser.html here
17:05:24FromDiscord<Elegantbeef> @Robyn [She/Her]Tables do not have an order do not encourage this
17:05:41FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "<@524288464422830095>*Tables do not have": I assumed they meant OrderedTable
17:05:49FromDiscord<Robyn [She/Her]> I forgot to use ordered table tho oops
17:06:16FromDiscord<Elegantbeef> You'd likely want to keep a concurrent list of the keys then just iterate those in reverse
17:06:18FromDiscord<Robyn [She/Her]> fixed
17:06:40FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "You'd likely want to": nabhh sequtils and algorithm go brrr
17:07:29FromDiscord<Elegantbeef> Though technically ordered tables should just have a built in iterator for reversed iterations
17:13:37FromDiscord<TFed> `toSeq(tbl.pairs).reversed()` worked as i just using the table for iterating.
17:14:14FromDiscord<anuke> In reply to @anuke "Either one, but at": is this worth adding to the package registry?
17:15:37FromDiscord<lainlaylie> i only glanced at it but it seems like a straight wrapper that still uses pointers and stuff?
17:16:00FromDiscord<lainlaylie> either way, you dont have to worry about being "good enough" for the registry, judging by the stuff that gets added there...
17:16:19FromDiscord<anuke> In reply to @lainlaylie "i only glanced at": there's a "high level" string wrapper similar to zippy
17:21:31Amun-Raanuke: can't see why not
17:24:51FromDiscord<lainlaylie> if it were me i'd like make it openarray[char] and/or openarray[byte] instead and maybe add something funky like a iterator that does chunked de/compress or something
17:32:48FromDiscord<anuke> I just assumed the zippy developer(s?) knew what they were doing and copied that. I don't really need anything fancier for my use case
17:34:39FromDiscord<anuke> Not sure what the stance is on `string` vs `openArray[byte]` vs `seq[byte]` vs `byte/uint8`, it seems very inconsistent across libraries
17:36:02Amun-RaI was never a fan of using string type for a buffer
17:36:30Amun-Raopenarray[byte] already includes seq[byte]
17:36:40Amun-Raand adds array[n, byte] for fre
17:36:42Amun-Rafree*
17:36:50FromDiscord<anuke> I'm aware, but I believe I've seen some libraries use seq instead of openArray
17:37:15Amun-Rahmm
17:37:28FromDiscord<anuke> In reply to @Amun-Ra "I was never a": string doesn't seem like the right data type for the job, yes, but as mentioned before, people still use it as such, so...
17:37:46Amun-Raanuke: so is nim stdlib ;)
17:37:56Amun-Raor so 'does'
17:38:26FromDiscord<anuke> augh
17:38:46FromDiscord<anuke> ~~Does nimv3/nimony address this?~~
17:39:02Amun-Radunno
17:40:09*mahlon joined #nim
17:45:01*mahlon quit (Ping timeout: 250 seconds)
17:45:06FromDiscord<Elegantbeef> `openarray[byte]` is the best cause it can accept all data without casting↵(@anuke)
17:45:09FromDiscord<Elegantbeef> `toOpenArrayByte` exists for `openArray[char]`
17:45:26FromDiscord<Elegantbeef> You may want to just do `openArray[byte | char]`
17:45:43FromDiscord<anuke> What about as a return type?
17:46:10FromDiscord<anuke> e.g. compression returns `string`, a new buffer
17:46:20FromDiscord<anuke> `seq[byte]`?
17:46:24FromDiscord<Elegantbeef> As an existential `string` or `seq[char]` due to the above reasons
17:47:05FromDiscord<Elegantbeef> You have to cast to send a `seq[byte]` to `openArray[char]`, so it's less than ideal
17:48:16Amun-RaI'm an old C fart and I tend to (over)use arrays when I can
17:48:20FromDiscord<anuke> how about `data: string | openArray[char] | openArray[byte]` as a parameter?
17:49:03Amun-RaYOU DON'T NEED THAT STRING PART
17:49:11Amun-Rasorry for those caps
17:49:15FromDiscord<anuke> why not?
17:49:26FromDiscord<Elegantbeef> nope that's just `openArray[char | byte]` but worse
17:50:00Amun-Ramy laptop suddenly entered the mode: "capslock off means caps"
17:50:11FromDiscord<Elegantbeef> Cause string -\> openArray[char] implicitly
17:50:24Amun-Ra^
17:50:38FromDiscord<anuke> ah I assumed it was explicit
17:51:36FromDiscord<Elegantbeef> `array[T, char]` `seq[char]` and `string` all pass to it without explicit conversion
17:51:52FromDiscord<Elegantbeef> Unless of course you have a `string` overload
17:52:03FromDiscord<Elegantbeef> Then `string` goes to `string`
17:53:42FromDiscord<anuke> this doesn't compile, what am I missing? https://media.discordapp.net/attachments/371759389889003532/1429165555968901181/image.png?ex=68f525a5&is=68f3d425&hm=1c4a685b64194a8469f8866d7b3b5ec6af7939e09646c51edfc96fdb70f4485c&
17:54:08FromDiscord<anuke> nim 2.0.8 (I refuse to upgrade because it doubles compile times)
17:55:38FromDiscord<anuke> requires an explicit `.toOpenArray(0, 2)`
17:59:03FromDiscord<demotomohiro> iirc, implicit type conversions doesn't work with type class parameters.
17:59:35FromDiscord<anuke> ...I think I'm just gonna stick to string for now
18:01:56FromDiscord<griffith1deadly> can't you make generic variants? T: openArray[char](data: T) ↵and then second for byte
18:04:51FromDiscord<Elegantbeef> You just do `data: openArray[byte | char]` and it should work
18:10:24FromDiscord<anuke> it does not https://play.nim-lang.org/#pasty=DKGvUGYQ
18:11:55FromDiscord<Elegantbeef> Silly compiler is silly
18:12:01FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=wSANMgcq
18:12:13FromDiscord<Elegantbeef> Both should logically be the same but generics r hard
19:12:05*mahlon joined #nim
20:26:46FromDiscord<.tokyovigilante> is it ORC-safe to pass an object that contains a `seq[float]` down a `Channel`? I have an audio app which needs to shuffle PCM chunks down a pipeline/graph, and was hoping to use threads/channels. I have a lock-free ringbuffer that I'm using for realtime ops, but would prefer to operate on sample chunks with metadata (timestamp etc).
20:27:37FromDiscord<.tokyovigilante> Docs say `TMsg` is deeply copied, so I assume yes, but then deep copying seems controversial? https://forum.nim-lang.org/t/9868
21:24:02FromDiscord<kubo39> I tried to use SRWLock for mutex on windows, but I found that Nim supports Windows XP and OS X 10.4(including ppc!!!) How maintain these?
21:24:53FromDiscord<kubo39> (edit) "I tried to use SRWLock for ... mutex" added "stdlib's"
21:30:46FromDiscord<kubo39> In reply to @kubo39 "I tried to use": FYI: python drops so often 😅 https://pythondev.readthedocs.io/platforms.html#windows
21:42:22*SchweinDeBurg quit (Ping timeout: 260 seconds)
21:43:11*SchweinDeBurg joined #nim
22:37:15*beholders_eye quit (Quit: WeeChat 4.6.3)