<< 30-12-2022 >>

00:00:08FromDiscord<jtv> You have to index into s and then use []
00:00:26FromDiscord<Elegantbeef> There are libraries like ptr\_math
00:00:28FromDiscord<jtv> That makes it worse to steal the [] for deref imho πŸ™‚
00:00:37FromDiscord<Elegantbeef> But yes pointer arithmetic doesnt exist in Nim
00:00:54FromDiscord<Tony Rubak> gotcha, I can work with this. thanks.
00:01:13FromDiscord<Elegantbeef> The conventional thing to do is `cast[ptr UncheckedArray[T]](myPtr)`
00:01:18FromDiscord<jtv> But frankly, my view is, the day-to-day bits in Nim are so much better choices than other languages, that I don't mind some of the things like this... other languages are worse
00:01:59FromDiscord<jtv> So just cast it to an int array, then you can index it, makes sense
00:03:28*ltriant quit (Ping timeout: 272 seconds)
00:03:55FromDiscord<Tony Rubak> I'm liking parts of nim and disliking others just like everything else; trying to see how far I get on this thing before I get too annoyed and go do something else lol
00:05:02*ltriant joined #nim
00:05:24FromDiscord<Tony Rubak> the unit testing stuff annoyed me enough that I kinda gave up, but that's kinda 🀷
00:06:46FromDiscord<jtv> The stuff that nimble does by default?
00:07:35FromDiscord<Tony Rubak> I couldn't figure out how to make `nimble test` do anything other than say "there are no tests" or something like that lol
00:07:49FromDiscord<leorize> https://github.com/disruptek/balls \<- this project is my favorite unittest tool
00:07:55FromDiscord<Elegantbeef> It searches `tests` for files that start with `t.nim`
00:08:12FromDiscord<jtv> Yeah, and if you use nimble init to set up your project, it gives you examples
00:08:22FromDiscord<jtv> I'll check that out, leorize, thanks.
00:08:25FromDiscord<Tony Rubak> In reply to @jtv "Yeah, and if you": I did this and it did not
00:08:46FromDiscord<jtv> Nim also ships w/ Testament, which I haven't used yet, but seems decent (if underdocumented)
00:08:56FromDiscord<jtv> Odd, it's done it for me and I've set up a few projects already
00:09:08FromDiscord<Tony Rubak> the documentation for testament was so bad that I just immediately gave up on that one
00:09:11FromDiscord<jtv> But the nimble documentation has made me actively angry
00:09:45FromDiscord<Tony Rubak> In reply to @Elegantbeef "It searches `tests` for": I did not realize the filenames needed to begin with t. Thank you.
00:09:46FromDiscord<jtv> TBH, if the language itself weren't such a good fit for what I want in a language, the tooling and docs would have caused me to bounce pretty quickly
00:10:17FromDiscord<jtv> I've spent way too much time rtfc'ing instead of rtfm'ing
00:10:28FromDiscord<Tony Rubak> I'm a masochist; I was using the first public release of F# and as long as I can work around the tools it usually doesn't bother me too much
00:11:37*ltriant quit (Ping timeout: 252 seconds)
00:17:26*ltriant joined #nim
00:18:58FromDiscord<Smarc> sent a code paste, see https://play.nim-lang.org/#ix=4jUW
00:23:14FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jUZ
00:23:26FromDiscord<Elegantbeef> Obviously should use variables
00:25:16FromDiscord<Smarc> Also results in 418
00:27:41FromDiscord<Elegantbeef> Oh you also need the inverse
00:27:44FromDiscord<Elegantbeef> You need to check if a in b or b in a
00:29:09FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jV2
00:29:14FromDiscord<Elegantbeef> But that's identical to my code πŸ˜„
00:31:24FromDiscord<Smarc> what are a and b in this case?
00:31:46FromDiscord<Elegantbeef> `fstNumber[0].parseInt` and `fstNumber[1].parseInt` respectively
00:36:02*azimut joined #nim
00:36:49*ltriant quit (Ping timeout: 268 seconds)
00:37:38FromDiscord<Smarc> 418 all the way :D
00:46:33NimEventerNew thread by void09: Is flags={SocketFlag.Peek} buggy or am I missing something ?, see https://forum.nim-lang.org/t/9780
00:48:11*azimut quit (Ping timeout: 255 seconds)
00:48:35*azimut joined #nim
00:56:48*ltriant joined #nim
01:15:10*wallabra_ joined #nim
01:16:56*wallabra quit (Ping timeout: 272 seconds)
01:16:56*wallabra_ is now known as wallabra
01:23:39*ltriant quit (Quit: leaving)
01:26:03*krux02 quit (Remote host closed the connection)
01:36:38*derpydoo quit (Ping timeout: 268 seconds)
02:05:02FromDiscord<jtv> @voidwalker From the asyncnet docs: "Warning: The Peek flag is not yet implemented."
02:30:23*wallabra_ joined #nim
02:30:30FromDiscord<sOkam!> How would you avoid using `while true:` with a bunch of `if condition: return` in its body?
02:31:38*wallabra quit (Ping timeout: 260 seconds)
02:31:39*wallabra_ is now known as wallabra
02:34:33FromDiscord<jtv> What's the context?
02:35:44FromDiscord<jtv> If you can't refactor the logic to have all of the conditions execute at the beginning or end of the loop, you might not be able to
02:37:21FromDiscord<sOkam!> context:↡https://youtu.be/ajv46BSqcK4?t=1655
02:38:18FromDiscord<sOkam!> Probably doesn't help much, since the algo is fairly complex πŸ€·β€β™‚οΈ
02:39:40FromDiscord<jtv> Yeah, it's fine. In general, you may not be able to remove all if/break statements from a loop, it just depends.
02:46:35FromDiscord<sOkam!> is it possible to limit the size of sequence to X items?↡i was thinking of using arrays, since the size is known, but don't know how to get the non-init length of the array when first adding values
02:47:38FromDiscord<sOkam!> something like `seq[2,int]`
02:47:59FromDiscord<jtv> You mean you know what the eventual size will be but want to prealloc the right size?
02:48:24FromDiscord<sOkam!> i know the eventual size, but the values might not be init yet, and i would need to get the size of the currently init values
02:48:35FromDiscord<jtv> var s:seq[x] = newSeqOfCap(n)
02:48:44FromDiscord<jtv> Where x is the type of the sequence
02:48:51FromDiscord<jtv> And n is the number of items
02:48:55FromDiscord<sOkam!> yeah, but it doesn't allow that to be used in the type
02:49:10FromDiscord<Rika> You need to specify the generic type in the new procedure too no?
02:49:12FromDiscord<jtv> The size isn't part of the type
02:49:14FromDiscord<sOkam!> the max size is know at compile time, which is why i thought arrays are better... but
02:49:30FromDiscord<jtv> Even if it's generic,
02:49:55FromDiscord<sOkam!> how do i do `arrayVar.len`, without always getting `4` if i said `array[4, int]`?
02:50:03FromDiscord<jtv> proc doIt[T]() = ... s = newSeqOfCap[T](n) should do the right thing
02:50:28FromDiscord<Rika> In reply to @sOkam! "how do i do": You don’t.
02:50:33FromDiscord<jtv> I thought you said you know the number of elements up front??
02:50:52FromDiscord<sOkam!> i know the max number
02:51:12FromDiscord<jtv> If the size of the item varies by type, and you know the max number, then just newSeqOfCap[T](max)
02:51:15FromDiscord<sOkam!> (edit) "i know the max ... number" added "potential"
02:51:39FromDiscord<jtv> You can truncate later if you vastly overestimated
02:51:41FromDiscord<Rika> In reply to @jtv "If the size of": Really just do this
02:51:56FromDiscord<sOkam!> k
02:52:24FromDiscord<jtv> Generally doesn't cost you... even if you've overestimated by a lot, the memory you're not using is going to mainly sit on pages that are just forever swapped out b/c they're unused
02:56:06*xet7 joined #nim
02:57:14*azimut quit (Quit: ZNC - https://znc.in)
02:57:24*azimut_ joined #nim
03:00:09FromDiscord<sOkam!> i was "worried" more about the allocation, or access cost, since the max size is known at compile time↡but I guess its avoided by creating a constructor that allocates once, and the size is not changed anywhere else, maybe πŸ€·β€β™‚οΈ
03:04:20FromDiscord<Elegantbeef> Someone really needs to make a fixed size seq πŸ˜„
03:08:39FromDiscord<jtv> LOL
03:09:15FromDiscord<jtv> Yeah, you could just use an array πŸ˜‰ But pre-allocating the seq is not going to cost you anything
03:29:57*tiorock joined #nim
03:29:57*tiorock quit (Changing host)
03:29:57*tiorock joined #nim
03:29:57*rockcavera is now known as Guest4840
03:29:57*Guest4840 quit (Killed (copper.libera.chat (Nickname regained by services)))
03:29:57*tiorock is now known as rockcavera
04:02:07FromDiscord<jtv> There's not a more flexible code formatting tool than nimpretty in the ecosystem, is there?
04:04:27FromDiscord<sOkam!> morepretty is slightly better
04:05:01FromDiscord<sOkam!> could argue its close to being tie, though, when used to clang-format
04:05:14FromDiscord<sOkam!> (edit) "could argue its close to being tie, though, when used to clang-format ... " added "instead πŸ˜”"
04:06:04FromDiscord<sOkam!> (edit) "could argue its close to being tie, though, when used to ... clang-format" added "the customization of" | removed "instead"
04:06:04FromDiscord<jtv> Yeah, that's the problem. Every time I run nimpretty I cringe when I can't get the exact style I want, including aligning stuff into columns, etc :). I might be a little too ocd
04:06:15FromDiscord<sOkam!> ye same πŸ˜”
04:06:48FromDiscord<jtv> Thanks for the recommendation, checking it out now
04:08:59FromDiscord<jtv> BTW, I did also find this one that seems SLIGHTLY more configurable: https://github.com/FedericoCeratto/nimfmt
04:15:01FromDiscord<jtv> Tho, that one doesn't seem to build anymore, not sure I can be bothered to fix it. Ugh.
04:19:38*rockcavera quit (Remote host closed the connection)
04:20:06FromDiscord<m4ul3r> In reply to @jtv "BTW, I did also": yo thanks for recommending this, i really like black python module and this seems similar
04:21:41*xet7 quit (Remote host closed the connection)
04:22:10FromDiscord<jtv> Yeah, it's closer to what I would want, though it's clearly unmaintained and needs a bit of love I don't have time to give it
04:23:06*xet7 joined #nim
04:23:08FromDiscord<jtv> morepretty has changed the semantics of a repo I forked from someone else to the point of breaking the code pretty badly. Mangled a bunch of import statements.
04:24:21FromDiscord<sOkam!> ouch
04:28:42FromDiscord<jtv> It wasn't bad, but that's not good either πŸ™‚
04:37:58*arkurious quit (Quit: Leaving)
05:34:45*rockcavera joined #nim
07:06:16*rockcavera quit (Remote host closed the connection)
07:29:22*pro joined #nim
08:01:10FromDiscord<_ πŸŽ„> hi, how do i do a constant hashmap in nim?
08:14:33FromDiscord<voidwalker> What is your favourite bit array lib ? I found https://github.com/treeform/bitty/ , https://github.com/MarcAzar/BitVector , https://github.com/adokitkat/bitseqs , https://github.com/onecodex/nim-bitarray , https://github.com/YesDrX/bitarray
08:17:48FromDiscord<voidwalker> awesome nim has BitVector listed. Then again, treeform's code should be good. Too many options 😦
08:19:55*jmdaemon quit (Ping timeout: 248 seconds)
08:23:29FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4jVV
08:23:32FromDiscord<Phil> sent a long message, see http://ix.io/4jVW
08:23:36FromDiscord<Phil> (edit) "http://ix.io/4jVW" => "https://paste.rs/HTX"
08:24:07FromDiscord<Phil> (edit) "http://ix.io/4jVX" => "https://paste.rs/UVu"
08:25:33FromDiscord<Phil> (edit) "http://ix.io/4jVZ" => "http://ix.io/4jVY"
08:31:41FromDiscord<voidwalker> well, BitVector seems like the better (faster) choice. I can probably swap between them seamlessly
08:31:49FromDiscord<voidwalker> (edit) "well, BitVector seems like the better (faster) choice. I can probably swap between them seamlessly ... " added "later if needed"
08:34:26FromDiscord<_ πŸŽ„> In reply to @Isofruit "constant as in immutable?": > constant as in immutable?↡this one
08:34:46FromDiscord<_ πŸŽ„> whats const vs let tho?
08:35:36FromDiscord<luteva> In reply to @leorize "https://github.com/disruptek/balls \<- this project": Hi! This seems to be pretty cool! I just can't find it in nimble packages. Is there a reason to not publish it as a nimble package? Or maybe, my nimble config is broken...???
08:50:44FromDiscord<planetis> Computed at compile time for example https://hookrace.net/blog/what-is-special-about-nim/#run-regular-code-at-compile-time
08:58:49FromDiscord<voidwalker> well, it's from one of nimskull's - the nim fork, main devs, maybe that's why. There's a few good libs not in nimble, not sure exactly what reason people have not to publish it there
09:24:35FromDiscord<Phil> In reply to @_ πŸŽ„ "whats const vs let": I assume you came over from python?
09:27:51FromDiscord<Phil> sent a long message, see http://ix.io/4jW8
09:28:22FromDiscord<Phil> If you need a set from g to a user defined letter, that must happen at runtime because you can't know what letter the user will give you
09:28:32FromDiscord<voidwalker> hey Phil, don't mislanguage them by mistake : P
09:33:09FromDiscord<_ πŸŽ„> In reply to @Isofruit "I assume you came": no, from other languages but I'm not aware of the difference
09:37:23*wallabra quit (Ping timeout: 264 seconds)
09:37:42FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=
09:41:04FromDiscord<luteva> or in other words: the value of a const is set at compile time. so you cannot use it, if the value can only be calculated/set at runtime.
09:42:24FromDiscord<luteva> if you want an immutable value to be calculated/set the first time the program is running the code section, you have to use let.
09:43:23*PMunch joined #nim
09:55:46FromDiscord<voidwalker> https://github.com/MarcAzar/BitVector/blob/master/src/bitvector.nim#L44 - do you think it's possible to initialize this bit vector doing memcopy from a string ?
09:56:53FromDiscord<voidwalker> I tried ` copyMem(aPeer.bitField.addr, bitField[0].unsafeAddr, bitField.len)` but this fails, I get a negative value for the length
09:57:01FromDiscord<luteva> is there a container/isolation tool writen in nim? something like podman, docker (or jib, for the java world) or something like this?
10:03:50FromDiscord<voidwalker> Is there any benefit to passing a string to a proc as "var string" for the purpose of being able to use .addr instead of .unsafeaddr ?
10:04:35FromDiscord<voidwalker> without needing for the string to be mutable in that proc
10:06:16FromDiscord<voidwalker> Welp, beef-less hours : D
10:17:15FromDiscord<luteva> In reply to @voidwalker "Is there any benefit": good question! I am also unsure what .unsafeaddr is used for. As I understand .unsafeaddr is a hint, that you are doing something "unsafe". So you could change an immutable (let). But if this is correct, making an immutable mutable just to use a "safe" method is absolutely stupid.
10:18:46FromDiscord<enthus1ast> i think there was a discussion lately that combines addr and unsafeaddr
10:19:07FromDiscord<planetis> UnsafeAddr is deprecated in v2
10:19:41FromDiscord<enthus1ast> ^ this, but addr will be upgraded accordingly
10:20:12FromDiscord<amadan> In reply to @luteva "is there a container/isolation": https://github.com/fox0430/nicoru not too sure if its still being worked on though
10:21:49FromDiscord<planetis> In reply to @_ πŸŽ„ "whats const vs let": There is a const example at the Nim website as well
10:25:12FromDiscord<voidwalker> Are there any data structures in a lib somewhere, optimized to hold filesystem dir/file structure ?
10:26:04FromDiscord<voidwalker> I can't decide if a tree or a flat sequence would be better (assume they are already sorted by path)
10:26:56PMunchDepends on what you want to do and whether logic or speed is more important to you
10:30:26FromDiscord<luteva> In reply to @voidwalker "Are there any data": maybe brianshannan/nim-trees
10:31:25FromDiscord<voidwalker> well, I am supposed to parse a .torrent file, which has them as a seq of @["path","to","file"] format. Torrent v2 specs though have them stored as a tree structure. Of course, I'd like to use only 1 implementation for both source. Then, I'd need fastest possible lookup. From a range of bytes, I need to determine the files/paths they belong to, very frequently.
10:31:39FromDiscord<voidwalker> (edit) "source." => "versions."
10:31:50FromDiscord<voidwalker> (edit) "1" => "one data structure"
10:32:01FromDiscord<voidwalker> (edit) "From" => "For"
10:32:28FromDiscord<luteva> i would try using a tree.
10:33:02FromDiscord<voidwalker> That is a distinct problem. Given len1,len2, ... lenN of distinct files, return the files of a given range
10:33:48FromDiscord<luteva> it should be easier to flatten a tree than to build the tree from a flat structre. imho
10:34:11FromDiscord<voidwalker> building time is not that important.. it's only done once. While retrieving data from it is done millions of times
10:35:11FromDiscord<luteva> that's why i would try using the tree. πŸ™‚β†΅build it once, then flatten to compare. not the otehr way around.
10:36:57FromDiscord<voidwalker> It also needs to be memory space efficient. File paths are very repetitive. Trees solve that problem by having the file stucture embedded in its own structure
10:37:18FromDiscord<voidwalker> For flat sequence, I need to use a dictionary to deduplicate values
10:40:02PMunch@voidwalker, I'd use essentially a finger table
10:40:03FromDiscord<luteva> .... and this can even lead to name clashes (unless you effectively implement a tree). so one more reason to use a tree πŸ™‚
10:40:46PMunchSo you get paths and the length of each file as I understand it. When you get a packet of data you need to know which file it belongs to based on the lengths of the various files, correct?
10:41:11FromDiscord<voidwalker> yes. it is all counted as one continous byte range, made up of individual files
10:41:54FromDiscord<voidwalker> unfortunately, a byte range can span multiple files.. which adds some complexity. shitty protoco : ) well ,was good enough 20 years ago
10:42:08PMunchSo what you do is store a sequence of tuples with the range of bytes it accepts and the path. Then you use a binary lookup on this sequence to determine which file a chunk goes into
10:43:01FromDiscord<voidwalker> Do I really need tuples though ?
10:43:09PMunchPretty much
10:43:18PMunchBut why wouldn't you use tuples?
10:43:23PMunchI mean they could be objects
10:43:33FromDiscord<voidwalker> Since file[n].end + 1 == file[n+1].start
10:43:44PMunchYes, but you still need the path
10:44:28FromDiscord<voidwalker> binary lookup as in binary search ?
10:44:40PMunchYou wouldn't have to store the start and the end, but it makes the searching algorithm slightly easier (although potentially slower because of caching..)
10:44:43PMunchYes
10:44:57FromDiscord<voidwalker> blah I just realised this will not be O(1) time
10:45:27FromDiscord<voidwalker> but no other way around it unless I make a big array where a[n] = index_of_the_file
10:45:28FromDiscord<voidwalker> no ?
10:45:43FromDiscord<voidwalker> (edit) "but no other way around it unless I make a big array ... where" added "the size of the byte range,"
10:45:52PMunchWell..
10:46:15PMunchThere's probably some fuckery you can do to get O(1)
10:46:26FromDiscord<luteva> if you want 0(1) you will probably need to index/key-value
10:47:10FromDiscord<voidwalker> let's see. 4GB torrent, 4.3 billion bytes
10:47:39PMunchBut how many files do you expect in a torrent?
10:47:40FromDiscord<voidwalker> nope, that won't fly : )
10:47:53FromDiscord<voidwalker> can be 1 to tens of thousands or even millions
10:48:09PMunchBinary search is pretty good though
10:48:18PMunchI mean you could make a tree structure as well
10:48:32PMunchIf you want even faster lookups
10:48:49FromDiscord<voidwalker> I guess I should look at the established torrent libs and see what they did. This is basic enough that they probably got it right
10:49:19FromDiscord<voidwalker> bot not basic enough to be obvious for me : )
10:50:57PMunchSay you have a split factor of 32, the first node splits your 4GB range into 32 125Mb chunks. These are equally split so you just need to divide your index by 32 to figure out which branch to take
10:51:32FromDiscord<luteva> maybe a Btree (or a B+ tree)?
10:51:34PMunchOf course you need to add files which end up on a boundry to more than one leaf node
10:51:45PMunchSo it's a bit more complex
10:52:02PMunchHow big are your chunks by the way?
10:52:08FromDiscord<voidwalker> Yeah I am probably going to write it as one big binary chunk, and split at the end
10:52:40PMunchThat's not great if you download something big and don't have a lot of room left on your device though
10:52:54FromDiscord<voidwalker> https://media.discordapp.net/attachments/371759389889003532/1058336875963756584/slide_13.png
10:53:26FromDiscord<voidwalker> there's also this complication called blocks.. you cannot request a whole piece, but subblocks of it. Blocks are <=16kB in size
10:53:40FromDiscord<voidwalker> pieces can be 128kB to 64MB or more
10:53:41PMunchWait, what's the difference between pieces and blocks?
10:54:33FromDiscord<voidwalker> well blocks are the thing you can actually ask for a client to give you, not pieces. You ask for piece index, offset, and length. you get that, and have to assemble those into a whole piece, which you can hash check for integrity
10:54:41PMunchRight, but you know the indices will be incrementing by 16kB. So already there you have saved yourself quite a bit of possibilities
10:55:10FromDiscord<voidwalker> well, the last bit won't end up in a whole 16kB, so you have to cut it : )
10:55:32FromDiscord<voidwalker> it's also possible the torrent was not created in a sane way and pieces are not divisible by 16kB. But that's very unlikely
10:55:44*deadmarshal quit (Remote host closed the connection)
10:55:51PMunchSure, but you went get an index of 10*16kB+1
10:56:19PMunchIt will always be some multiple of 16k
10:57:48FromDiscord<voidwalker> yo could technically expand this into just block logic, so you only keep track of blocks have/needed/active.. and handle hashing at the end
10:57:53FromDiscord<voidwalker> (edit) "yo" => "you"
11:00:43FromDiscord<voidwalker> https://github.com/arvidn/libtorrent/blob/RC_2_0/src/torrent.cpp - how on earth can they maintain this, this single file is 12k lines
11:01:09*pro quit (Quit: pro)
11:17:06FromDiscord<haxscramper> and disruptek does not see any reason to add packages to nimble list anyway
11:17:07FromDiscord<haxscramper> since you can use git URLs
11:17:07FromDiscord<haxscramper> because there is no real reason to do this TBH
11:17:10FromDiscord<haxscramper> it was written before nimskull↡(@luteva)
11:17:47*deadmarshal_ joined #nim
11:28:43FromDiscord<luteva> ok i see. well it is nice to get/search a list of nim packages, search for tags etc. ... but if you always already know in advance, what you would like to install, then ok, you can use the url.
11:29:01FromDiscord<luteva> thx
11:31:24FromDiscord<haxscramper> you can search on github
11:31:25FromDiscord<haxscramper> https://github.com/search?q=language%3Anim+parser
11:31:42FromDiscord<haxscramper> nimph package manager just searches on github as well, there is an API to do this
11:32:44NimEventerNew Nimble package! bossy - Makes supporting command line arguments easier, see https://github.com/guzba/bossy
11:32:44NimEventerNew Nimble package! engineio - An Engine.IO client library for Nim, see https://github.com/samc0de/engineio
11:33:04FromDiscord<luteva> In reply to @haxscramper "https://github.com/search?q=language%3Anim+parser": oh yes of course...
11:50:10NimEventerNew thread by yister: Can I create a unique hash of a proc and all its dependencies?, see https://forum.nim-lang.org/t/9781
12:00:37FromDiscord<luteva> sent a code paste, see https://paste.rs/JsK
12:02:59PMunch@luteva, because you're not casting a person, but a pointer to a person
12:03:05PMunchAnd vice-versa when converting back
12:03:18PMunchYour repr(byte) is actually not correct.
12:04:08PMunchIf you remove the two `unsafeAddr` everything works fine
12:04:36PMunch(And you can see the 15 from the age in the byte representation of the object)
12:05:10FromDiscord<luteva> oh yes. i see! πŸ™‚
12:05:16FromDiscord<luteva> thx!
12:05:26PMunchThe first eight bytes is a pointer to the string object, and the next 8 bytes is the integer
12:08:53FromDiscord<luteva> ok so, if Person is a 'ref object' the person.unsafeAddr would be correct?
12:09:33FromDiscord<luteva> oh, no...
12:11:26PMunchWell then you'd need to cast to a `ptr array` and not just an array
12:11:29PMunchBut yes
12:11:43PMunchYou could of course also then dereference that array by `[]`
12:13:28*pro joined #nim
12:21:01FromDiscord<cow> can't you directly cast a ref object to a ptr, without .unsafeAddr
12:23:30FromDiscord<cow> also, if you do sizeof(Person) when Person is a ref object, it will return the size of the pointer
12:24:01FromDiscord<enthus1ast> we should add a "readPasswordFromStdin" like proc to eg terminal that just prompts without hiding, for yes no question etc
12:25:12FromDiscord<cow> works https://media.discordapp.net/attachments/371759389889003532/1058360100391235664/image.png
12:25:23FromDiscord<cow> https://play.nim-lang.org/#ix=4jWP
12:26:39FromDiscord<cow> (repr also printed some pointers which I cut off from the comments)
12:27:38FromDiscord<cow> @luteva
12:29:15FromDiscord<cow> you can technically also cast back to `Person` but someone more experienced will have to tell us if it's okay to cast pointers to `ref` types (does it work with the GC?)
12:29:49FromDiscord<luteva> ahhhh thx a lot @cow
12:30:03FromDiscord<cow> np πŸ™‚
12:30:51*deadmarshal_ quit (Quit: IRCNow and Forever!)
12:32:39FromDiscord<cow> uh oh this threw a C compilation error https://play.nim-lang.org/#ix=4jWR
12:32:53FromDiscord<cow> i tried to show an example with unsafeAddr
12:35:51FromDiscord<cow> In reply to @cow "uh oh this threw": https://media.discordapp.net/attachments/371759389889003532/1058362780752814080/image.png
12:35:55FromDiscord<cow> um help?
12:38:22FromDiscord<enthus1ast> @luteva\: @cow this will not contain the content of the string
12:38:23FromDiscord<enthus1ast> why not just use json/msgpack/stream ?
12:38:24FromDiscord<enthus1ast> or any other serializer libs
12:38:24FromDiscord<enthus1ast> flatty
12:38:25FromDiscord<enthus1ast> why not just use json/msgpack/streams ?
12:39:00FromDiscord<cow> I thought this was an educational example
12:39:09FromDiscord<cow> but you are right, it just contains the pointer to the string
12:39:09FromDiscord<luteva> yes. for learning!
12:39:14FromDiscord<enthus1ast> when you plan to receive such stuff from a untrusted source, i would never cast, but parse
12:39:55FromDiscord<cow> in fact, the string would probably be GC'd if person escapes the scope
12:42:14FromDiscord<cow> i think nim playground is currently not doing well btw
12:43:02FromDiscord<cow> if you do this, the string gets lost https://media.discordapp.net/attachments/371759389889003532/1058364592130097213/image.png
12:44:27FromDiscord<cow> it somehow still works? https://media.discordapp.net/attachments/371759389889003532/1058364945726713916/image.png
12:46:15FromDiscord<enthus1ast> if name would be an array, it would work i guess. But the whole concept of this is flawed and i would not do it like this (for most usecases i could thing of at least) but just use a serializer
12:54:00FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4jWY
14:17:07FromDiscord<luteva> sent a code paste, see https://paste.rs/fIQ
14:17:55FromDiscord<ambient> afaik all Nim types are compile time
14:18:17FromDiscord<luteva> so a const string should work?
14:21:20FromDiscord<luteva> .... ok no... but, this would be possible using a macro, right?
14:25:21FromDiscord<luteva> so i would have to search for the type given as a string by the caller. is that possible?
14:25:36FromDiscord<luteva> (edit) "so i would have to search for the type given as a string by the caller. is that possible? ... " added "Using a macro?"
14:25:50FromDiscord<luteva> (edit) "possible? Using a macro?" => "possible, with macros?"
14:28:10FromDiscord<cow> `proc` is a runtime procedure
14:38:15FromDiscord<jtv> @luteva https://play.nim-lang.org/#ix=4jXl
14:42:11FromDiscord<luteva> In reply to @jtv "<@954521401073754212> https://play.nim-lang.org/#ix": thx, but i need the other way around: I have the type given as a string. and i want to get the type.
14:45:18FromDiscord<jtv> At compile time? Type isn't available at runtime
14:46:27FromDiscord<luteva> In reply to @jtv "At compile time? ": yes at compiletime. that was my wish πŸ˜„
14:47:19FromDiscord<jtv> You can do it from a macro, just by creating a Ident node w/ that string
14:47:26FromDiscord<jtv> There's probably a better way
14:47:34*rockcavera joined #nim
14:49:08NimEventerNew post on r/nim by llhd: Windows defender recognizes nim 1.6.10 x64 as a Virus, see https://reddit.com/r/nim/comments/zz2aic/windows_defender_recognizes_nim_1610_x64_as_a/
14:52:37FromDiscord<jtv> @luteva https://play.nim-lang.org/#ix=4jXs
14:54:15FromDiscord<jtv> Probably better to type those: https://play.nim-lang.org/#ix=4jXt
14:55:09NimEventerNew post on r/nim by lf_araujo: Did someone recreate Nim with Zig? /s, see https://reddit.com/r/nim/comments/zz2eiq/did_someone_recreate_nim_with_zig_s/
14:57:07FromDiscord<jtv> If you might want to have more general type declarations, you have to create the tree of nodes, which is also easy: https://play.nim-lang.org/#ix=4jXv
15:02:56*arkurious joined #nim
15:03:12FromDiscord<jtv> LMK if that meets your needs, @luteva. That last one should do it under any circumstance I'd think, but if not, I'm happy to help.
15:14:49*azimut joined #nim
15:15:47*azimut_ quit (Ping timeout: 255 seconds)
15:24:22FromDiscord<cow> In reply to @NimEventer "New post on r/nim": except what the poster of this reddit post is missing that cyber is an interpreted language
15:24:30FromDiscord<cow> and apparently it beats JITs in performance?
15:25:56FromDiscord<jtv> @luteva Occurs to me that you might have your type sitting in some compile-time variable, so one last go at it for you: https://play.nim-lang.org/#ix=4jXG
15:30:51NimEventerNew thread by lf_araujo: Did someone recreated Nim with Zig? \s, see https://forum.nim-lang.org/t/9782
15:37:21NimEventerNew post on r/nim by Familiar_Ad_8919: how would you convert a seq[string] to a cstringarray?, see https://reddit.com/r/nim/comments/zz3ddv/how_would_you_convert_a_seqstring_to_a/
15:38:38*arkurious quit (Ping timeout: 255 seconds)
15:39:08*xet7 quit (Ping timeout: 260 seconds)
15:39:15FromDiscord<cow> In reply to @NimEventer "New thread by lf_araujo:": it smells like advertising now lmao
15:40:05FromDiscord<cow> although the reddit user has a non suspicious history so i take it back
15:47:15FromDiscord<Smarc> coulf anyone give me some buzzwords for day5 part1? (AoC)
15:51:18*xet7 joined #nim
15:52:09*arkurious joined #nim
16:08:17*derpydoo joined #nim
16:10:00PMunchBuzzwords?
16:10:17FromDiscord<cow> what library is `pixels` in the new nim book? (https://nim-lang.org/assets/img/nim_book_excerpt.pdf)
16:11:05FromDiscord<catnowblue> sent a code paste, see https://paste.rs/Isz
16:13:03PMunch@cow, I think it's just an imaginary library
16:13:23FromDiscord<cow> oh okay, thanks
16:13:37PMunch@catnowblue, not really
16:14:44FromDiscord<cow> it wouldn't be that hard to define it yourself
16:15:53PMunchWould look a bit like this: https://play.nim-lang.org/#ix=4jXX
16:16:27FromDiscord<cow> you beat me to it 😦
16:17:33PMunchFastest keyboard in the west
16:18:10PMunchYou can get some bonus points if you explain why my solution properly handles the scenario of 0 and 1 element sequences as well :)
16:19:04FromDiscord<cow> nim auto initializes result to the default value right
16:20:47FromDiscord<cow> it doesn't have the right behavior imo
16:20:51PMunchCorrect :)
16:20:54FromDiscord<cow> it returns the same for @[] and @[""]
16:21:06PMunchWell, that's how Nim strings behave
16:21:13PMunchAn empty string is the same as no string
16:21:29PMunchThe string type will always hold something you can pass to string functions
16:21:32FromDiscord<cow> still, I would throw an exception if the sequence is empty for correctness
16:22:01om3gawhy some dylibs os cannot find for ompiled binary, and some not?
16:22:07PMunchEh, depends on whether you consider that to be exceptional or not
16:22:21om3gas*some can
16:23:21FromDiscord<cow> sent a code paste, see https://play.nim-lang.org/#ix=4jXZ
16:23:47om3gais there any chance to tell the os to find the lib from the location relative from binary?
16:24:49om3gaI will get angry and compile that stuff statically
16:24:54om3ga:)
16:25:24FromDiscord<cow> i am happy that stuff just works on linux
16:25:36FromDiscord<cow> on windows i was suffering from having to manage my DLLs
16:25:44FromDiscord<hotdog> In reply to @cow "what library is `pixels`": It’s this one https://nimble.directory/pkg/pixels
16:25:49*derpydoo quit (Ping timeout: 252 seconds)
16:25:50FromDiscord<cow> thanks!
16:25:53om3gaI need to cross compile to windows and mac
16:25:54FromDiscord<hotdog> No prob
16:26:03FromDiscord<hotdog> You need sdl I think for it to work
16:28:02om3gaI can compile without no prob
16:28:28om3gabut dylib for each os, is too painfull
16:30:07om3gain mac I also created app bundle, using manual, that was so unpleasant
16:36:03FromDiscord<hotdog> om3ga have you tried something like https://github.com/chrisheller/docker-nim-cross
16:36:58Amun-Ra/usr/lib/nim/system/sets.nim:21:25: runtime error: load of misaligned address 0x7ffc146a11e2 for type 'NU64', which requires 8 byte alignment
16:37:08Amun-Rahas anyone else tested nim with asan and ubsan?
16:37:38om3gahotdog, no. I cross compiled for windows from linux. Works fine
16:37:58om3gaon mac I compiled natively
16:38:36om3gaAmun-ra, I use all the time that tools
16:38:55om3gawhat you mean test the nim
16:39:28PMunchHmm, asynctools seems to be broken on Windows devel: https://github.com/PMunch/nimlsp/actions/runs/3807847256/jobs/6477921305#step:7:438
16:39:30Amun-Rahmm, that error is pretty hard to debug as it's the only line *san prints
16:41:12om3gawhat it says
16:41:20Amun-Rajust that line
16:41:44om3gaaah, I see
16:43:00Amun-Rahmm, it's somewhere in function I use getopt in
16:43:25om3ga-fsanitize=alignment
16:44:02Amun-Rafound the culprit
16:44:28Amun-Ra"prog -v -v arg" works fine, "prog -vv arg" triggers asan
16:44:29om3gaAmun-Ra: compile with -O0 -fsanitize=alignment -g3 and --lineDir:on --debuginfo
16:44:57om3gait should result with more info
16:46:02Amun-Rano, just the line
16:46:33Amun-Rait's something inside getops, I'll make a shorter example and file bug report eventually
16:46:40om3gayeah, not for this case, but for other stuff that options will add more text
16:46:41Amun-Ragetopt*
16:47:04om3galooks like there is misallinged pointer somewhere
16:47:18Amun-Ramhm
16:47:41PMunchFinally have a debug/testing utility for NimLSP https://github.com/PMunch/nimlsp/issues/31
16:49:04*PMunch quit (Quit: leaving)
16:53:19*derpydoo joined #nim
16:59:45Amun-Raom3ga: submitted: https://github.com/nim-lang/Nim/issues/21206
17:31:16om3gaAmun-Ra: it not does the same here
17:31:45Amun-Raom3ga: I edited the post, I had local config.nims when I tested that
17:33:02om3gayes. with UBSAN it catched
17:33:12Amun-Ramac?
17:35:38om3gaAmun-Ra: yeah
17:35:51om3gasparseopt.nim.c:541:23:
17:36:07Amun-Rathanks
17:36:12om3ganp
17:38:24om3gaAmun-Ra: If cmdline == "", the real command line as provided by the os module is retrieved instead if it is available. If the command line is not available, a ValueError will be raised.
17:38:35om3gamaybe this is the case?
17:39:09om3gathere is no err, but should it not have input parameters?
17:42:33om3gaseems the bug is somewhere there, where it tries to parse argv[]
17:56:28Amun-Rahmm
17:57:04Amun-Ratbh I plan to write my own getopt for nim one doesn't support ususal -o value format
18:17:40FromDiscord<Piqueiras> so I started a couple days ago with nim, does anyone know maybe some way in which this could be rewritten better? https://media.discordapp.net/attachments/371759389889003532/1058448799137284226/image.png
18:18:38FromDiscord<Piqueiras> i havent looked at barely any example code
18:22:52FromDiscord<Elegantbeef> Could remove `return` inside `collatz`
18:24:54FromDiscord<Piqueiras> cool
18:25:22FromDiscord<Piqueiras> are the loop and seq of seqs alright?
18:25:28FromDiscord<Piqueiras> its what looked a bit weird to me
18:25:58FromDiscord<Elegantbeef> Seems fine
18:26:02FromDiscord<Elegantbeef> Conventionally there are some issues, but that's up to you
18:26:37FromDiscord<Piqueiras> yea thats what i kinda meant, how would it be usually done
18:26:41FromDiscord<Elegantbeef> like it's conventionally `n != 0` and `res =` and `var n: int`
18:27:11FromDiscord<Elegantbeef> also `register[^1]`.add res\`
18:27:28FromDiscord<Elegantbeef> Whoops
18:27:35FromDiscord<Elegantbeef> `register[^1].add res`
18:28:14FromDiscord<Elegantbeef> actually is `i -1` == `^1`
18:28:15FromDiscord<Elegantbeef> Hmmm
18:28:28FromDiscord<Piqueiras> but in the beginning isnt register just @[] so register[^1] does not exist?
18:28:39FromDiscord<Elegantbeef> You add the element
18:28:50FromDiscord<Elegantbeef> You add before you index
18:29:24FromDiscord<Piqueiras> register is a seq which can hold seqs but its empty at the moment, so I shold add a new seq to it, right?
18:29:38FromDiscord<Elegantbeef> Which you do before you index, yes
18:30:10FromDiscord<Elegantbeef> When you add a new element you do `i - 1` which is the same as the last value which `^1` gives you
18:30:37FromDiscord<Piqueiras> yeah guess thats true
18:30:39FromDiscord<Piqueiras> nice one
18:31:29FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jYt
18:32:43FromDiscord<Piqueiras> yeah i had my mind on another fortran code I was doing before for sth else lmao
18:35:40FromDiscord<Piqueiras> also I should kinda work on my prints, which was a cool way lol https://media.discordapp.net/attachments/371759389889003532/1058453329941901433/image.png
18:35:45FromDiscord<Piqueiras> cuz it looks kinda ugly
18:40:59Amun-RaPiqueiras: if register is a list or single values you do: for i, num in pairs register: …
18:41:45FromDiscord<Piqueiras> Do I have to specify pairs?
18:42:02Amun-Rano, pairs is an iterator
18:42:25Amun-Rait returns tuple of (index, iterable[index])
18:42:49*pro left #nim (#nim)
18:42:53Amun-Raand mitems if you need to modify such item
18:43:17FromDiscord<Piqueiras> Hmm
18:43:28FromDiscord<Piqueiras> In reply to @Piqueiras "also I should kinda": But this does work tho?
18:43:42FromDiscord<Piqueiras> I meant, how to make a "prettier" echo
18:43:52Amun-Ra#define prettier
18:44:05Amun-Raa, I think I know
18:44:12Amun-Racheck std/stformat
18:44:28FromDiscord<Piqueiras> sent a code paste, see https://play.nim-lang.org/#ix=4jYw
18:44:32Amun-Rait allows you to write echo fmt"{i+1} {num.len}"
18:44:38Amun-Raor &"…"
18:44:54FromDiscord<Piqueiras> Yea I need to get into that
18:45:16FromDiscord<Piqueiras> Just asking if echo had some weird sugar for those cases lol
18:46:54Amun-RaPiqueiras: https://play.nim-lang.org/#ix=4jYy
18:46:57Amun-Rasth like that?
18:47:29FromDiscord<Piqueiras> Seems cool enough, ty
18:47:35Amun-Rano worries
18:48:04Amun-Rafmt and & differs as seen in example
18:48:54*azimut quit (Remote host closed the connection)
18:49:33*azimut joined #nim
18:51:00FromDiscord<scruz> still don't understand why nim didn't go with `f" "` instead
18:51:17FromDiscord<scruz> like `&` is so random for strformat
18:51:35FromDiscord<Elegantbeef> Nim uses `&` for collection concatenation
18:51:39*Amun-Ra remembers \c and \L instead of \r and \n
18:51:48FromDiscord<scruz> hmn
18:51:53FromDiscord<scruz> (edit) "hmn" => "hmm"
18:52:14FromDiscord<Elegantbeef> It uses `fmt`, but due to how Nim works you need something that doesnt escape characters
18:52:35FromDiscord<Elegantbeef> cause `fmt"\t\t\t"` will print `\t\t\t`
18:53:09Amun-RaElegantbeef: I was wondering what was the rationale for fmt and & to exist
19:01:37FromDiscord<Solitude> In reply to @scruz "still don't understand why": why `f`? if anything it should be `i`.
19:02:10FromDiscord<scruz> python
19:02:21FromDiscord<Solitude> who?
19:02:54FromDiscord<scruz> https://media.discordapp.net/attachments/371759389889003532/1058460184638402580/unknown.jpeg
19:02:55FromDiscord<Elegantbeef> And not the actual unescaped characters
19:02:56FromDiscord<Elegantbeef> `fmt "\t\t\t"` prints the tabulator character of course
19:02:56FromDiscord<Elegantbeef> but that's why `&` mostly exists
19:02:57FromDiscord<Elegantbeef> Whether `&` should be `fmt` is a discussion
19:02:58FromDiscord<Elegantbeef> But luckily it's all in userspace so any variation can exist
19:03:24FromDiscord<scruz> In reply to @scruz "": https://media.discordapp.net/attachments/371759389889003532/1058460313760043079/unknown.jpeg
19:03:39FromDiscord<Solitude> crazy stuff, man, keep me updated
19:04:01FromDiscord<scruz> I don't know if you're exaggerating or not
19:05:02FromDiscord<Solitude> sorry, if i stop pretending i will get banned
19:07:55FromDiscord<Elegantbeef> Lol
19:22:37*jmdaemon joined #nim
19:41:26*wallabra joined #nim
20:08:08*neceve joined #nim
20:21:49*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
20:23:30*jmdaemon joined #nim
20:24:08*derpydoo quit (Quit: derpydoo)
20:40:14FromDiscord<_ πŸŽ„> sent a code paste, see https://play.nim-lang.org/#ix=4jYY
20:41:01FromDiscord<yar> how to put arbitrary data on the stack then retrieval at the later date using a pair key value of a string type?
20:42:14FromDiscord<_ πŸŽ„> sent a code paste, see https://play.nim-lang.org/#ix=4jZ0
20:42:55FromDiscord<_ πŸŽ„> oh u mean variables
20:42:57FromDiscord<yar> sent a code paste, see https://play.nim-lang.org/#ix=4jZ1
20:43:07FromDiscord<yar> no arbitrary data on the stack then retrieval at the later date using a pair key value
20:43:21FromDiscord<huantian> what in the world are you talking about lmao
20:43:37FromDiscord<_ πŸŽ„> sent a code paste, see https://play.nim-lang.org/#ix=4jZ2
20:43:42FromDiscord<yar> sent a code paste, see https://play.nim-lang.org/#ix=4jZ3
20:48:44FromDiscord<yar> sent a code paste, see https://play.nim-lang.org/#ix=4jZ6
20:50:59FromDiscord<huantian> how do you store data that only has its size known at runtime?
20:51:05FromDiscord<huantian> (edit) "runtime?" => "runtime on the stack?"
20:51:19FromDiscord<_ πŸŽ„> @huantian sorry to @ you, but could i get help w/ my visitor thing?
20:51:24FromDiscord<_ πŸŽ„> In reply to @_ πŸŽ„ "how do i implement": ^^
20:52:29FromDiscord<huantian> sorry I have no idea what a vistor pattern is lol
20:52:52FromDiscord<yar> In reply to @huantian "how do you store": good point
20:52:55FromDiscord<yar> i'll use the heap
20:53:03FromDiscord<yar> (edit) removed "the"
20:53:03FromDiscord<_ πŸŽ„> https://refactoring.guru/design-patterns/visitor
21:00:03*neceve quit (Quit: ZNC - https://znc.in)
21:02:41*neceve joined #nim
21:03:02*neceve quit (Remote host closed the connection)
21:04:39*deadmarshal_ joined #nim
21:04:51FromDiscord<huantian> https://play.nim-lang.org/#ix=4jZd
21:04:54FromDiscord<huantian> here's a generic example
21:04:58FromDiscord<huantian> so much dynamic dispatch lmao
21:05:44*neceve joined #nim
21:06:02*neceve quit (Remote host closed the connection)
21:06:33*deadmarshal_ quit (Remote host closed the connection)
21:06:34FromDiscord<Boston> If I have a for loop iterating over a seq of strings can get the current index I'm at, the "ordinal" of the current string?
21:06:39FromDiscord<huantian> Do note Nim isn’t really built focusing on this kinda stuff, you might find more success using other patterns
21:06:56FromDiscord<huantian> In reply to @Boston "If I have a": Use std/enumerate
21:07:41FromDiscord<huantian> Or the pairs iterator with `for str, i in someSeq:`
21:09:01FromDiscord<huantian> Or is it `i, str` I can’t remember the rider
21:09:06FromDiscord<huantian> (edit) "rider" => "order"
21:10:44*wallabra quit (Ping timeout: 255 seconds)
21:13:58FromDiscord<Boston> Thanks
21:17:53*wallabra joined #nim
21:25:07FromDiscord<_ πŸŽ„> alright, thank you @huantian
21:32:39*neceve joined #nim
21:33:02*neceve quit (Remote host closed the connection)
21:39:38*neceve joined #nim
21:40:01*neceve quit (Remote host closed the connection)
21:42:34*deadmarshal_ joined #nim
21:44:43*wallabra_ joined #nim
21:45:39*neceve joined #nim
21:45:55*wallabra quit (Ping timeout: 260 seconds)
21:45:56*wallabra_ is now known as wallabra
21:46:01*neceve quit (Remote host closed the connection)
21:58:33FromDiscord<alex.boisvert> I'm using VSCode to build a simple HTML + javascript page using Karax .... problem I'm having is that the Nim extension (nimsaem) doesn't lint the code properly. It seems to assume the standard C backend insteand of the js backend, so I'm getting tons of error, e.g. when importing the std/dom package, it reports "This module only works on the JavaScript platform". Is there a trick to tell the extension that I want to use the js b
21:59:30FromDiscord<alex.boisvert> I do have `"nim.buildCommand": "js"` in my `settings.json` but that's only used for actually building files (versus linting that happens on-the-fly)
22:00:34FromDiscord<alex.boisvert> I've tried forcing `-define:js` in nim.cfg but that doesn't work either (for obvious reasons but I figured it might get me farther)
22:01:39*neceve joined #nim
22:05:10FromDiscord<Solitude> i think `--backend:js` should do it
22:06:20FromDiscord<Smarc> how do i read a file starting from a specific line?
22:07:47FromDiscord<jtv> The easiest way is to read the whole thing and find the nth line. Otherwise, you have to scan it for newlines and stop after you've found n - 1 newlines
22:08:43FromDiscord<alex.boisvert> @Solitude Unfortunately, that doesn't seem to work. πŸ˜• (Unless I'm doing it wrong)
22:10:50FromDiscord<alex.boisvert> I put ``-backend:js` in my nim.cfg and also tried in $file.nim.cfg
22:10:56FromDiscord<alex.boisvert> (edit) "``-backend:js`" => "`-backend:js`"
22:11:04FromDiscord<alex.boisvert> (edit) "`-backend:js`" => "`--backend:js`"
22:12:01FromDiscord<jtv> I think the place that kind of stuff actually works is in config.nims
22:12:21FromDiscord<Solitude> it doesnt matter
22:14:03FromDiscord<alex.boisvert> Oh, actually, it does work!
22:14:13FromDiscord<Solitude> In reply to @alex.boisvert "Oh, actually, it does": you had to restart nimsuggest?
22:14:45FromDiscord<alex.boisvert> In reply to @Solitude "you had to restart": Yes, I guess. I restarted VSCode and it started working.
22:15:02FromDiscord<alex.boisvert> Thanks much!
22:18:56FromDiscord<Piqueiras> which would be a neat way to remove all these quotes from a csv? https://media.discordapp.net/attachments/371759389889003532/1058509522429280406/image.png
22:19:17FromDiscord<cow> removing all quotes?
22:20:21FromDiscord<cow> https://nim-lang.org/docs/strutils.html#replace%2Cstring%2Cstring%2Cstring
22:22:22*Jjp137 quit (Quit: Leaving)
22:22:49FromDiscord<cow> if the csv isn't too long, something like ↡`"/path/to/file.csv".readFile().replace("`
22:23:09FromDiscord<cow> (edit) "↡`"/path/to/file.csv".readFile().replace("`" => "↡`"/path/to/file.csv".readFile().replace("\"", "").writeFile("/path/to/newFile.csv")`"
22:23:15FromDiscord<Piqueiras> oh yeah idk why I tried sth weird and didnt work
22:23:22FromDiscord<Piqueiras> it was replace yea
22:23:32FromDiscord<cow> (edit) "↡`"/path/to/file.csv".readFile().replace("\"", "").writeFile("/path/to/newFile.csv")`" => "↡`writeFile("/path/to/newFile.csv", "/path/to/file.csv".readFile().replace("\"", ""))`"
22:23:43FromDiscord<cow> how did you try it
22:23:47FromDiscord<cow> can you send the snippet
22:23:55FromDiscord<cow> did you import strutils
22:24:14FromDiscord<Piqueiras> maybe cause I was trying some weird thing with map()
22:24:17FromDiscord<Piqueiras> but now it works
22:25:51FromDiscord<Piqueiras> sent a code paste, see https://paste.rs/ahh
22:26:23FromDiscord<Solitude> whats the point of splitting lines there?
22:26:32FromDiscord<cow> you can replace before splitting lines
22:26:49FromDiscord<cow> and no, I don't think that will work with map like that
22:27:03FromDiscord<cow> I would use `mapIt` for this
22:27:11FromDiscord<cow> (edit) "this" => "this, if you couldn't replace before splitting"
22:27:32FromDiscord<Piqueiras> hm, mapIt? ill look onto that
22:27:36FromDiscord<cow> `.mapIt(replace(it, "\"", ""))`
22:27:45FromDiscord<cow> map needs a function as an argument
22:27:56FromDiscord<cow> mapIt is a macro
22:28:03FromDiscord<cow> (edit) "mapIt is a macro ... " added "that lets you easily construct this function"
22:30:55FromDiscord<jos> are there any interfaces in nim that are dynamically dispatched
22:31:06FromDiscord<jos> i see concepts but that looks like static dispatch to me
22:31:25FromDiscord<jtv> Yes
22:31:45FromDiscord<jtv> You can declare a method instead of a proc
22:32:18FromDiscord<jtv> And set an inheritance hierarchy by declaring the type: type subtype = ref object of basetype
22:32:30FromDiscord<cow> that's not an interface
22:32:34FromDiscord<jtv> There's also RootObj and RootRef
22:32:52FromDiscord<jtv> Oh, I see what you're asking
22:34:41FromDiscord<jtv> Concepts are just statically checking that the objects will have the proper interface. They don't have to be part of an inheritance hierarchy. I haven't tried it, but I am pretty sure if the procs you require in a concept are actually methods, it should all just work and dynamically dispatch
22:35:04FromDiscord<jtv> But I don't think you can require a method; I haven't seen the syntax for it if so
22:35:17FromDiscord<jos> mm lemee try
22:35:30FromDiscord<cow> I thought concepts worked more like generics
22:35:54FromDiscord<jos> i mostly interested in holding references of a concept that point to different implementations
22:36:06FromDiscord<jtv> Well, concepts don't exist at runtime
22:36:31FromDiscord<jtv> Like cow said, they are used to typecheck and then create instances of code specific to types that match
22:37:40FromDiscord<jtv> But since you can or types together, you can still do what you want to do
22:38:00*Jjp137 joined #nim
22:38:36FromDiscord<jos> https://media.discordapp.net/attachments/371759389889003532/1058514467119448144/image.png
22:38:39FromDiscord<jtv> Esp if you just cast up from a rootref
22:38:50FromDiscord<jos> the last line is invalid
22:39:10FromDiscord<jos> i think that's the part that i can't really do
22:39:15FromDiscord<jos> like it won't create a vtable for my concept
22:39:25FromDiscord<Elegantbeef> Jtv you're correct there is no method of using concepts at runtime with Nim you need to use something like iface
22:39:35FromDiscord<Elegantbeef> Of course it's invalid they both derive from `RootObj` and dont share parent
22:39:50FromDiscord<Elegantbeef> You need to use macros for runtime dispatch of concepts
22:39:56FromDiscord<Elegantbeef> https://github.com/beef331/traitor exists for instance, no clue if it is
22:40:00FromDiscord<Elegantbeef> usable
22:40:25FromDiscord<jos> interesting
22:40:40FromDiscord<cow> you could also dispatch yourself 🀑
22:40:53FromDiscord<cow> a type enum and a case statement at every proc
22:41:51FromDiscord<cow> and casts
22:41:56FromDiscord<jtv> Beef, that's a really cool idea
22:42:29FromDiscord<cow> (edit) "and casts ... " added "(depending on the details)"
22:42:59FromDiscord<cow> there's the nim equivalent tagged enums, which helps a lot when making seqs of different types
22:43:13FromDiscord<cow> (edit) "enums," => "unions,"
22:44:35FromDiscord<cow> sent a code paste, see https://play.nim-lang.org/#ix=4jZQ
22:44:52FromDiscord<jos> i really do need the dynamic dispatch
22:45:04FromDiscord<jos> because i want users to be able to extend it without having source access
22:45:10FromDiscord<Elegantbeef> Look at iface
22:46:00FromDiscord<jos> i mean its cool but having 2 year old libraries as a foundation of your project is always a weird feeling
22:46:27FromDiscord<jos> it is kind of small tohugh
22:46:28FromDiscord<jos> (edit) "tohugh" => "though"
22:46:35FromDiscord<jos> only 250 lines, i could fix that
22:46:39FromDiscord<jos> if anything did go wrong
22:46:56FromDiscord<Elegantbeef> Otherwise use oop
22:46:59FromDiscord<cow> In reply to @jos "because i want users": also, are you gonna statically compile their extensions into the binary?
22:47:57FromDiscord<cow> i would be also interested in learning how to load extensions from a folder
22:48:21FromDiscord<cow> (edit) "i would be also interested in learning how to load extensions from a folder ... " added "while your main program has been compiled without knowing what extensions there are"
22:51:40FromDiscord<jos> i planned on loading them during runtime but haven't crossed that bridge yet
22:54:19FromDiscord<Schelz> Hi! Is there any way to list all the displays connected to the computer ?
22:56:37FromDiscord<sOkam!> What's the best way to learn good practices for using the different builtin error types for exceptions?
22:56:44FromDiscord<cow> In reply to @Schelz "Hi! Is there any": that sounds something very platform specific
22:56:55FromDiscord<Elegantbeef> Never use builtin error types for exceptions
22:56:59FromDiscord<Elegantbeef> That's the good practice
22:57:11FromDiscord<sOkam!> not even inheriting from them?
22:57:20FromDiscord<Schelz> In reply to @cow "that sounds something very": On windows mostly
22:57:34FromDiscord<Elegantbeef> You can inherit from them i guess but i dont see much benefit myself
22:58:29FromDiscord<sOkam!> I've never used them, so I thought it would be good to start from the base errors↡But if not, what's a better approach?
23:00:01FromDiscord<cow> In reply to @Schelz "On windows mostly": If there's no nim library to do it, you can look into how to do it through C
23:00:07FromDiscord<jtv> @jos That library is pretty widely used, and doesn't need to do much, so I wouldn't stress about that anyway
23:00:29FromDiscord<cow> on linux I think you could use `xrandr` commands to do it
23:05:18FromDiscord<cow> maybe there's a command line program to do it on windows, which you could easily wrap
23:05:19FromDiscord<jtv> Generally people will downplay exceptions, especially since you can return Option types which are easy to use to indicate error (or, I guess, tuples if you don't want to force checking)
23:05:48FromDiscord<cow> i just do both 😭
23:06:08FromDiscord<cow> my functions throw exceptions AND have a tuple indicating if there was an error
23:06:15FromDiscord<cow> half the errors will do one, other half the other half
23:06:16FromDiscord<jtv> But generally you can just inherit from ValueError, OSError or IOError, as appropriate
23:06:21FromDiscord<cow> (edit) removed "half"
23:07:10FromDiscord<cow> i can never decide if crashing the program if something bad happened, or chaining together a bunch of checks if something bad happened is better
23:07:31FromDiscord<jtv> I generally save throwing my own exceptions for when I really do need a longjmp()... for instance, bailing from some deeply nested parsing or compilation.
23:07:56FromDiscord<cow> I usually tend to use exceptions if I don't intend for them to be handled
23:08:09FromDiscord<cow> as in, it's so bad I want the program to end
23:08:50FromDiscord<jtv> Yeah, though that gives me nightmares of Java programs
23:08:59FromDiscord<huantian> there's probablysomething in https://github.com/khchen/winim for the display thing
23:09:42FromDiscord<jtv> Esp in a multi-threaded program you're going to end up having people write a while true: loop and never deal w/ issues πŸ™‚
23:10:44FromDiscord<cow> but if something goes wrong internally, there is a bug, and the best way to get a bug fixed is to crash the program if it ever happens
23:11:01FromDiscord<cow> no, i never got anything into production
23:11:06FromDiscord<jtv> Sure yes.
23:11:31FromDiscord<jtv> Depends on the environment, but generally expect when you have threads, only the current thread will exit
23:11:42FromDiscord<cow> good to know
23:12:00FromDiscord<! Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4jZY
23:12:26FromDiscord<jtv> IDK, I'd assume x1,y1, x2,y2 for opposite corners of the rectangle??
23:12:36FromDiscord<Schelz> In reply to @cow "If there's no nim": I got the audio tho working so I can change it through C++, but for video thats a bit tricky so thats way I asked if in nim could be done. 😁
23:12:55FromDiscord<! Nilts> In reply to @jtv "IDK, I'd assume x1,y1,": oh, i thought it was shape not location based
23:13:22FromDiscord<cow> In reply to @Schelz "I got the audio": maybe winim can help?, but you can pretty easily call C(++) functions from nim
23:13:22FromDiscord<! Nilts> guess i was wrong
23:13:46FromDiscord<jtv> Well, I assume it's specifying a rectangle, and that's usually done by giving the two opposite corners
23:14:05FromDiscord<cow> or x, y, width, height
23:14:16FromDiscord<jtv> Yeah, could be.
23:15:23FromDiscord<! Nilts> In reply to @cow "or x, y, width,": but which is it, i can't even find the file that defines newRect
23:16:37FromDiscord<cow> type Rect = tuple[origin: Point, size: Size]
23:16:47FromDiscord<cow> proc newRect(x, y, w, h: Coord): Rect =
23:16:50FromDiscord<cow> https://github.com/yglukhov/nimx/blob/master/nimx/types.nim
23:17:04FromDiscord<cow> it's x, y and width, height
23:18:03FromDiscord<! Nilts> thanks!
23:26:29FromDiscord<! Nilts> Arrgh, nimx does not even work on the latest version of nim. I can't even run the tests
23:28:24FromDiscord<cow> the readme says they use the latest devel
23:28:43FromDiscord<cow> (edit) "the readme says they use the latest devel ... " added "version, not latest stable"
23:29:04FromDiscord<! Nilts> In reply to @cow "the readme says they": which is?
23:29:47FromDiscord<! Nilts> sent a code paste, see https://paste.rs/BFZ
23:29:54FromDiscord<cow> yeah that's the latest stable release
23:30:25FromDiscord<cow> I'm not a nimx user (i don't do GUI stuff) but I think they mean unreleased new
23:30:44FromDiscord<! Nilts> I don't have enough storage on my machine for another release.
23:31:23FromDiscord<! Nilts> or the time to compile it
23:31:48FromDiscord<! Nilts> why does nim take up so much space? Anyone know which files i can delete?
23:31:54FromDiscord<cow> you can `choosenim devel`
23:32:12FromDiscord<cow> how much space does it take up for you?
23:32:21FromDiscord<cow> (edit) "devel`" => "devel`, I don't think you need to compile it"
23:32:27FromDiscord<! Nilts> In reply to @cow "you can `choosenim devel`,": choosnim does not work on my machine (linux arm)
23:34:46FromDiscord<! Nilts> In reply to @cow "how much space does": 47M
23:34:47FromDiscord<cow> a nim install seems to be around 70 MB on my PC
23:34:55FromDiscord<! Nilts> (edit) "47M" => "47MB"
23:40:15FromDiscord<! Nilts> can i delete `nim/compiler`?
23:42:39FromDiscord<cow> i just did, and nim seems to work
23:42:56FromDiscord<cow> my intuition says that everything besides `bin/` is just source code not needed after you have compiled nim
23:57:08FromDiscord<Elegantbeef> You also need the `lib` folder
23:57:12FromDiscord<Elegantbeef> Cause nim ships the stdlib as source