<< 08-03-2021 >>

00:00:15*joast quit (Quit: Leaving.)
00:20:56*joast joined #nim
00:41:08*arielp joined #nim
01:11:15*grobe0ba quit (Quit: ZNC 1.7.5 - https://znc.in)
01:11:27*grobe0ba joined #nim
01:21:30*AMG18 joined #nim
01:21:49*AMG18 quit (Client Quit)
01:36:59*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
01:37:21*njoseph joined #nim
01:39:34FromDiscord<Gary M> Is there a reason why mingw gcc on windows is stuck on version 6?
01:40:01leorize[m]Araq never updated it, that's all
01:40:24FromDiscord<flywind> use `mingw-w64`
01:40:48FromDiscord<Gary M> I know it only affects a very small % of the userbase, but you can't flag it for c++17 because it's just too old
01:41:15FromDiscord<Gary M> right now I'm actually using WSL2 to compile for windows, which is weird I guess but it works better than default.
01:41:19leorize[m]you can just point nim to a newer gcc of your choice
01:41:24FromDiscord<Gary M> default windows behaviour
01:41:50FromDiscord<Gary M> it's also much easier to install mingw on linux than windows
01:41:55FromDiscord<Gary M> no dealing with msys stuff
01:42:54leorize[m]i think araq policy for mingw on windows is to use the oldest supported version
01:43:15FromDiscord<Gary M> on another note: I encountered some weird behavior with loading shared libs
01:43:19leorize[m]msys is pretty straightforward tbh
01:43:32FromDiscord<Gary M> WSL2 is more straightforward, I think
01:43:54FromDiscord<Gary M> I use VScode which is integrated with WSL2 so I never leave the windows environment
01:44:15FromDiscord<Gary M> so basically I have "libbgfx-shared-lib(Debug|Release).dll" on windows right
01:44:21leorize[m]ah true, microsoft is good at building lock-ins
01:44:36FromDiscord<Gary M> it looks for it right next to the executable just fine
01:44:41FromDiscord<Gary M> however
01:44:49FromDiscord<Gary M> "libbgfx-shared-lib(Debug|Release).so" on linux does not
01:45:02FromDiscord<Gary M> it searches the system directory
01:45:11leorize[m]that's due to how linux works
01:45:17FromDiscord<Gary M> it looks like just using "./libbgfx-shared-lib(Debug|Release).so" fixes the "issue"
01:45:35leorize[m]please don't
01:45:41FromDiscord<Gary M> don't what?
01:45:54leorize[m]`./` means "current directory"
01:46:28leorize[m]it means whatever directory that you happen to be in
01:46:34FromDiscord<Gary M> well yes
01:46:39leorize[m]not the executable location
01:46:45FromDiscord<Gary M> are all linux shared libraries supposed to be in the same location?
01:46:57leorize[m]by default, yes
01:47:09leorize[m]there's a way around using rpath
01:47:21FromDiscord<Gary M> so how would I distribute the shared library?
01:47:30FromDiscord<Gary M> and better yet link it from the wrapper
01:48:00leorize[m]hmm, what are you trying to do?
01:48:18leorize[m]you're trying to ship your software, right?
01:48:29FromDiscord<Gary M> it's a simple app that opens a window with SDL2 then links bgfx to the window
01:48:41FromDiscord<Gary M> sdl2 ships in most package managers just fine
01:48:44FromDiscord<Gary M> but bgfx does not
01:49:08leorize[m]so your two choices are to either statically link or to use rpath
01:49:24leorize[m]using rpath is simpler so I'll show you how
01:49:35FromDiscord<Gary M> okay
01:50:23leorize[m]pass `--passL:'-Wl,-rpath,$ORIGIN'` to the compiler, which will instruct the dynamic linker to look for libraries in the same directory as the executable
01:51:24FromDiscord<Gary M> ah I see, cool.
01:51:35leorize[m]you might notice the use of single quotes, and that's intentional since `$ORIGIN` is a special specifier and not an environment variable, thus has to be passed verbatim to the linker.
01:53:35leorize[m]you should inspect the generated binary with `readelf -d` to verify that the rpath is set
01:56:56FromDiscord<Gary M> so I don't know how to `readelf -d` because I'm dumb
01:57:02FromDiscord<Gary M> but it appears the rpath is not working
01:57:33leorize[m]can you post the output of `readelf -d <exe>`?
01:58:21FromDiscord<Gary M> sent a code paste, see https://play.nim-lang.org/#ix=2S6n
01:58:25FromDiscord<Gary M> now I know how to use readelf -d lol
01:58:38leorize[m]:P
01:58:49FromDiscord<Gary M> anyways, nothing there.
01:59:07leorize[m]looks like the `$ORIGIN` was eaten by your shell or smt :/
01:59:35leorize[m]can you compile with `--listCmd:on` and post the output?
02:00:55*abm quit (Read error: Connection reset by peer)
02:04:33FromDiscord<Gary M> sent a code paste, see https://play.nim-lang.org/#ix=
02:06:10leorize[m]Yardanico: ^ broken paste
02:06:57FromDiscord<Yardanico> Huh
02:06:57FromDiscord<Yardanico> sent a long message, see http://ix.io/2S6v
02:06:59FromDiscord<Gary M> -lm -Wl,-rpath,$ORIGIN -ldl -flto
02:07:53leorize[m]@Gary try `$$ORIGIN`
02:08:04leorize[m]hopefully that'd work
02:08:20FromDiscord<Gary M> It doesn't.
02:08:22FromDiscord<Gary M> I did try that
02:08:24FromDiscord<Gary M> 0x000000000000001d (RUNPATH) Library runpath: [28620ORIGIN]
02:12:16FromDiscord<Gary M> GOT IT.
02:12:29FromDiscord<Gary M> `\\$ORIGIN/` did the trick
02:12:46FromDiscord<Gary M> for note, it's inside a string in a nimble task
02:13:00FromDiscord<Gary M> but it did need the \
02:16:22leorize[m]what a pain :p
02:17:00FromDiscord<Gary M> Oh don't I know it
02:17:12FromDiscord<Gary M> my friend thought bgfx + nim just wasn't working on nim
02:17:19FromDiscord<Gary M> on linux
02:17:59FromDiscord<Gary M> also there are some outdated x11 and windows things in Vladar's sdl2 bindings
02:18:10leorize[m]rpath origin has always been a trouble due to how troublesome passing the flag is
02:18:24FromDiscord<Gary M> nim's winlean didn't really seem to have all the types, if it did they aren't 1:1 named anymore
02:18:33FromDiscord<Gary M> so I used winim/lean, but idk
02:18:35*lritter quit (Ping timeout: 265 seconds)
02:18:58*lritter joined #nim
02:19:25leorize[m]yea, use winim, bindings in nim stdlib are terrible
02:53:43*wasted_youth2 joined #nim
02:54:10*krux02 quit (Remote host closed the connection)
02:56:34FromDiscord<Gary M> do we know if vladar is on the irc or somewhere else?
02:56:54FromDiscord<Gary M> nvm, answered my own question, looks like he's on the IRC
02:57:05FromDiscord<Gary M> saying his name mentions him yes?
03:16:30*NimBot joined #nim
03:20:32*muffindrake quit (Ping timeout: 260 seconds)
03:22:08*muffindrake joined #nim
04:02:39*gpanders quit (Remote host closed the connection)
04:03:34*gpanders joined #nim
04:20:11*spiderstew joined #nim
04:21:45*spiderstew_ quit (Ping timeout: 272 seconds)
04:40:45*a_chou joined #nim
04:41:42*a_chou quit (Remote host closed the connection)
04:42:15*a_chou joined #nim
04:50:05saemPMunch: I'm certain I'm correct as that's how backwards compatibility is maintained for the LSP spec and implementations. Also that's how extension of the protocol are possible for other use cases. It's why the spec uses TypeScript interfaces (structural types) for specification.
04:51:31FromDiscord<mattrb> sent a code paste, see https://play.nim-lang.org/#ix=2S6T
05:04:22FromDiscord<Yardanico> You can't store an openarray like that, it's not a "concrete" type
05:04:34FromDiscord<Yardanico> You can do it with https://nim-lang.org/docs/manual_experimental.html#view-types but I'd recommend just using a seq
05:05:54FromDiscord<mattrb> Gotcha, makes sense. I can totally just use a seq here. Thanks
05:09:13FromDiscord<flywind> sent a code paste, see https://play.nim-lang.org/#ix=2S6X
05:09:15FromDiscord<flywind> compiles with `-d:ssl`
05:09:26FromDiscord<flywind> use valgrind
05:09:45FromDiscord<flywind> It says `==1717935== in use at exit: 3,645 bytes in 8 blocks↵==1717935== total heap usage: 33 allocs, 25 frees, 26,741 bytes allocated`
05:09:49FromDiscord<flywind> does it mean it have some leaks?
05:10:01FromDiscord<flywind> (edit) "have" => "has"
05:12:52*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
05:13:00*njoseph joined #nim
05:13:52FromDiscord<Rika> That’s not the full output
05:14:09FromDiscord<Rika> What’s the output of the lines with unreachable in them
05:14:46FromDiscord<Rika> Those are possible leaks, but people say it doesn’t matter if you’re leaking memory if running in a full fledged OS like Linux or so
05:14:55FromDiscord<Rika> The OS will take care of it anyway
05:15:21FromDiscord<flywind> sent a code paste, see https://play.nim-lang.org/#ix=2S6Y
05:15:26FromDiscord<Rika> Lost being 0 means no leak
05:15:48FromDiscord<Rika> I don’t remember what reachable means but I remember lost means a leak
05:15:59FromDiscord<flywind> I see, thanks.
05:16:13FromDiscord<Rika> It’s on the valgrind quick start guide
05:16:51FromDiscord<flywind> I found it, thanks
05:35:13*narimiran joined #nim
05:54:28*blitzworks joined #nim
06:05:32*a_chou quit (Quit: a_chou)
06:10:26ForumUpdaterBotNew Nimble package! bio_seq - A Nim library for biological sequence data., see https://github.com/kerrycobb/nim-dna-seq
06:25:26FromDiscord<Yardanico> In reply to @flywind "I found it, thanks": You're not testing the right way
06:25:52FromDiscord<Yardanico> You have to use -d:useMalloc as well because Nim uses its own allocator by default
06:26:38FromDiscord<Yardanico> Also global memory is never freed of course
06:26:58PrestigeIs there a langage syntax spec for Nim?
06:27:29FromDiscord<flywind> In reply to @Yardanico "Also global memory is": I see
06:27:41FromDiscord<ElegantBeef> > This document is a draft! Several of Nim's features may need more precise wording. This manual is constantly evolving into a proper specification.
06:27:44FromDiscord<ElegantBeef> From the manual 😄
06:28:04FromDiscord<Yardanico> In reply to @Prestige "Is there a langage": Manual is the closest we have
06:28:10FromDiscord<Yardanico> Or you mean the grammar?
06:28:15PrestigeGrammar, yeah
06:28:23FromDiscord<Yardanico> manual contains grammar as well
06:28:27PrestigeCool, ty
06:28:44FromDiscord<Yardanico> In the very start
06:29:20FromDiscord<Yardanico> (there's also some intro about used symbols and stuff)↵https://nim-lang.org/docs/manual.html#syntax-grammar
06:30:46PrestigeI'm looking into writing a tree-sitter grammar, this is really helpful
06:30:58saem@Yardanico do you stream regularly?
06:31:05FromDiscord<Yardanico> Not really
06:31:18FromDiscord<Yardanico> @Prestige isn't there treesitter for Nim already?
06:31:35PrestigeNot that I've found, would be great if there was
06:32:08saemI tried it today... it takes a lot of getting used to having the monologue running continuously. 😅
06:32:50FromDiscord<Yardanico> you don't have to speak that much :)
06:32:59Prestigea google search shows someone actually asked about a treesitter grammar for nim today, lol https://old.reddit.com/r/neovim/comments/lznywy/question_about_treesitter_support/
06:34:02saemFeels like I do when it's working on the compiler, at least for me, it's mostly staring at the code, wondering why something works that way and bouncing around files reading, picking a small change to make, and then repeat.
06:48:39*vicfred quit (Quit: Leaving)
06:52:14*narimiran quit (Ping timeout: 264 seconds)
06:53:01*letto quit (Quit: Konversation terminated!)
07:01:20*lritter quit (Ping timeout: 265 seconds)
07:10:30FromDiscord<Yardanico> Yeah that's fine
07:10:36*waleee-cl quit (Quit: Connection closed for inactivity)
07:10:44FromDiscord<Yardanico> People don't talk that much on most programming streams
07:14:44*PMunch joined #nim
07:18:17*letto joined #nim
07:45:45*narimiran joined #nim
07:54:11FromDiscord<haxscramper> Prestige: I have https://github.com/haxscramper/tree-sitter-nim/blob/master/grammar.js that I didn't finish yet, so if you want to give it a try you can start from here
07:54:45FromDiscord<haxscramper> Though I don't have that much experience writing tree-sitter grammars so the thing kind of halted midway
07:56:14FromDiscord<haxscramper> Also generated parser is very large (larger than c++) and I'm not sure I'd that is because I did something wrong, or it is due to nim grammar
07:58:20FromDiscord<haxscramper> And also I need to learn how to make indentation-sensetive lexer
08:07:42saemPrestige: LMK if you get interested in property based testing, I'd be interested in working with someone to get something basic together to see if it can generate random programs and do some narrowing.
08:18:37*tane joined #nim
08:22:37ForumUpdaterBotNew Nimble package! nimib - nimib 🐳 - nim 👑 driven ⛵ publishing ✍, see https://github.com/pietroppeter/nimib
08:30:57idfis the bot showing new nimble packages too now
08:31:10PMunchYup
08:31:38idfnice, i i thought its people making new forum threads for their packages and i was a bit confused
08:35:04PMunchI've read half the README for that package and I still have no idea what it does..
08:35:35*JustASlacker joined #nim
08:38:25FromDiscord<ElegantBeef> That's exactly what it does, it makes people confused 😛
08:39:28FromDiscord<ElegantBeef> Seems like it's a DSL to make web pages
08:39:46FromDiscord<ElegantBeef> https://pietroppeter.github.io/nimib/hello.html from https://github.com/pietroppeter/nimib/blob/main/docs/hello.nim
08:40:38ForumUpdaterBotNew Nimble package! meta - View and set the metadata for audio files, see https://github.com/RainbowAsteroids/meta
08:55:32FromDiscord<hugogranstrom> Nimib feels like it would be a nice option to write tutorials in as the code is the same as the page. No more copying of code into a code block in markdown and hoping everything runs 🙃
08:56:28FromDiscord<Yardanico> In reply to @idf "is the bot showing": also with that it's easier for people to discover new packages
08:56:33FromDiscord<Yardanico> and I bet new packages will get more starts too XD
08:56:40FromDiscord<Yardanico> (edit) "starts" => "stars"
09:01:24*haxscramper joined #nim
09:37:42*pbb quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
09:37:48ForumUpdaterBotNew thread by Drkameleon: Sorting array by object key, see https://forum.nim-lang.org/t/7589
09:38:55*pbb joined #nim
09:51:49ForumUpdaterBotNew thread by Vitreo12: Add "buildLib" option to "envcc", see https://forum.nim-lang.org/t/7590
09:54:13*Vladar joined #nim
10:05:46*krux02 joined #nim
10:12:15FromDiscord<zetashift> From https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib `Each test should be in a separate block: statement, such that each has its own scope. ` why doesn't the stdlib use testament too?
10:13:43FromDiscord<Yardanico> because for examples it's better to use runnableExamples and because a lot of tests in the stdlib are quite old
10:13:49FromDiscord<Yardanico> quite a few tests were migrated to use testament instead
10:14:02FromDiscord<Yardanico> have you seen https://github.com/nim-lang/Nim/tree/devel/tests/stdlib ?
10:14:48FromDiscord<zetashift> I didn't yet, I was reading the contributing page and just wondered why, I guess sometimes with Nim it's better to just dive in 😛
10:14:54FromDiscord<Yardanico> wdym wondered why?
10:15:04FromDiscord<Yardanico> this line implies testament https://media.discordapp.net/attachments/371759389889003532/818426584120688720/unknown.png
10:15:06FromDiscord<zetashift> I wondered why stdlib was tested using `block` statements
10:15:32FromDiscord<Yardanico> https://github.com/nim-lang/Nim/blob/devel/tests/stdlib/thttpcore.nim an example of a stdlib module being tested
10:15:43FromDiscord<Yardanico> `block` are used to avoid identifier duplication
10:15:47FromDiscord<zetashift> ooohh
10:15:48FromDiscord<Yardanico> so you don't need to care to rename your test variables
10:16:56FromDiscord<zetashift> thanks :D, I overthinked a bit seeing those block statements
10:18:56*tane quit (Quit: Leaving)
10:50:26*aeverr joined #nim
10:51:09FromDiscord<dom96> In reply to @Yardanico "and I bet new": awesome idea 🙂
10:55:50Oddmongeri was expecting a custom «repr» with this one : https://play.nim-lang.org/#ix=2S7X
10:56:34FromDiscord<Yardanico> you should know that more specific procs have higher priority over generic ones :)
10:57:09Oddmongerso this proc has higher priority ?
10:57:36Oddmongeri had forgotten the :string return ^^'
10:57:40FromDiscord<Yardanico> yep
10:57:50FromDiscord<Yardanico> but yeah, maybe it's just because it's in the same file, I'm not sure :D
10:58:14FromDiscord<Yardanico> if you do `echo 5` it works even with your code, so nim doesn't call your proc for it
10:58:15Oddmongeri should rename it `my$` maybe
10:58:22FromDiscord<Yardanico> (and echo calls $ for each argument implicitly)
10:59:31*aeverr left #nim ("Konversation terminated!")
11:04:33Oddmongerthank you, bon appétit :)’
11:22:07PMunchBlock statements are great .)
11:25:44idfyeah they are really nice
11:26:03PMunchEspecially since they can also return stuff
11:26:20PMunchAnd be broken out of
11:26:25PMunchJust great stuff all around
11:26:36idfyeah very useful to break out of a lot of loops
11:27:18idfkinda easy to overthink with them if you're not careful sometimes
11:27:22FromDiscord<Yardanico> disruptek intensifies
11:27:44idfi miss him bros
11:27:52FromDiscord<Yardanico> @pietroppeter btw I hacked around this with nim's highlite and nim's nimdoc css https://media.discordapp.net/attachments/371759389889003532/818444902160793610/unknown.png
11:28:15FromDiscord<pietroppeter> In reply to @PMunch "I've read half the": Yeah, I definitely can (and will) improve the README, but I hoped hello example would give it away. Anyway @ElegantBeef's explanation of a "DSL to make web pages" is a good explanation. I plan to clean it up, tag the 0.1 and make a forum announcement later this week. There has been some discussion about it in #science channel
11:28:28FromDiscord<Yardanico> it's a bit lacking in "color" but we can improve highlite a bit since it's really customizable
11:28:33FromDiscord<Yardanico> just take identifiers from https://github.com/highlightjs/highlight.js/blob/master/src/languages/nim.js
11:28:39FromDiscord<Yardanico> like builtin
11:28:44FromDiscord<Yardanico> and literals too
11:29:02FromDiscord<pietroppeter> ah, a nimdoc skin 🙂
11:29:52FromDiscord<Yardanico> also it's funny how a lot of nim extensions highlight openarray and not openArray (even in your hello world example)
11:29:56FromDiscord<Yardanico> although openArray is the "canonical" spelling :P
11:30:04FromDiscord<Yardanico> I mean nim syntax highlighting extensions
11:30:12FromDiscord<Yardanico> even highlight.js has openarray and not openArray
11:30:30FromDiscord<Yardanico> (and its case sensitive while it should be only case sensitive for the first letter and also ignore underscores) :P
11:30:37FromDiscord<Yardanico> but it's so much you can ask from those more generic solutions
11:30:41FromDiscord<Yardanico> (edit) "but it's ... so" added "only"
11:31:04FromDiscord<Yardanico> I will try to make highlite make output closer to highlight.js (add the builtin and literal stuff)
11:31:05FromDiscord<pietroppeter> yep, the idea as I mentioned is just to use those identifiers. I was thinking of having as output the same classes the highlight.js uses so that you can reuse all CSS by highlightjs: https://github.com/pietroppeter/nimib/blob/main/assets/atom-one-light.css
11:31:19FromDiscord<Yardanico> oh yeah I can definitely use those
11:31:57FromDiscord<Yardanico> also seems like highlight.js nim grammar is outdated :D
11:32:03FromDiscord<Yardanico> no `concept` for example
11:32:04FromDiscord<pietroppeter> very possibly
11:32:26FromDiscord<Yardanico> also `generic` is not a keyword (was it ever one?)
11:32:48FromDiscord<Yardanico> ah it was in older nim versions
11:32:55FromDiscord<Yardanico> from 0.12.0 https://media.discordapp.net/attachments/371759389889003532/818446174368694303/unknown.png
11:32:59FromDiscord<zetashift> Could use https://shiki.matsu.io/ for highlighting maybe
11:34:08FromDiscord<Yardanico> i don't see if it works for languages not supported by vscode out-of-the-box?
11:34:24FromDiscord<Yardanico> yeah need to do https://github.com/shikijs/shiki/blob/master/docs/languages.md#add for nim as well
11:34:37FromDiscord<zetashift> It uses textmate grammar right? Could re-use: https://github.com/Varriount/NimLime/tree/master/Syntaxes
11:34:38FromDiscord<Yardanico> I'll play around with highlite a bit more
11:35:07FromDiscord<Yardanico> @zetashift yeah, github uses this grammar too
11:35:13FromDiscord<Yardanico> for nim
11:36:02*tane joined #nim
11:36:26FromDiscord<zetashift> https://github.com/shikijs/shiki/blob/master/scripts/pullGrammarsFromGitHub.js think you could modify this repo to point to the Nim grammars
11:36:43FromDiscord<Yardanico> i guess so, you might want to mention it in https://github.com/pietroppeter/nimib/issues/11
11:36:58FromDiscord<Yardanico> although I don't see how is it that different from highlight.js (except being able to use vscode themes of course)
11:37:43FromDiscord<zetashift> Yeah I think that's the main difference
11:38:40FromDiscord<zetashift> actually Nim is in this PR: https://github.com/shikijs/shiki/pull/102/commits it's a 1 line change ahah
11:39:05FromDiscord<zetashift> But I see pietroppeter wants to go a non JS way?
11:39:20FromDiscord<zetashift> In that case shiki isn't gonna cut it
11:39:48FromDiscord<Yardanico> yeah for that I want one of the options to be nim's own highlighting :)
11:42:39FromDiscord<zetashift> Yeah that would be better
11:49:11FromDiscord<Yardanico> yep wasn't that hard to add builtins to nim's highlite https://media.discordapp.net/attachments/371759389889003532/818450270501339147/unknown.png
11:49:33FromDiscord<Yardanico> now lets try to inline styles from https://github.com/pietroppeter/nimib/blob/main/assets/atom-one-light.css for a test
11:58:38FromDiscord<Yardanico> @pietroppeter I guess I kind of did it
11:58:44FromDiscord<Yardanico> default https://media.discordapp.net/attachments/371759389889003532/818452669952819221/unknown.png
11:58:52FromDiscord<Yardanico> him highlite with my custom code https://media.discordapp.net/attachments/371759389889003532/818452703722078229/unknown.png
11:59:36PMunchWhy is TOP SECRET coloured?
11:59:43FromDiscord<Yardanico> because it's a link :P
12:00:55PMunchAah
12:01:11FromDiscord<Yardanico> for this simple example the actual html is really close between highlight.js and nim's highlite
12:01:36FromDiscord<Yardanico> relevant part of code - https://gist.github.com/Yardanico/144caea455c43917a409a22b56f34c03
12:01:38FromDiscord<Unaimend> In reply to @Yardanico "for this simple example": What are you working on?
12:01:51FromDiscord<Yardanico> some experiments for static syntax highlighting for https://github.com/pietroppeter/nimib
12:02:36FromDiscord<Unaimend> is that a static site generator?
12:02:56FromDiscord<Yardanico> no, it's more of nim-centric article writing DSL :P
12:03:35FromDiscord<Unaimend> hmm, still interesting. I plan on writing a few blog posts regarding nim.
12:03:50FromDiscord<Yardanico> yeah I like nimib a lot too
12:03:52FromDiscord<Unaimend> Stuff for newcomers, which I am still basically am
12:08:15*JustASlacker quit (Quit: Leaving)
12:08:35*JustASlacker joined #nim
12:12:07ForumUpdaterBotNew thread by Marcomq: Nimview - a lightweight UI helper, see https://forum.nim-lang.org/t/7591
12:20:18*aeverr joined #nim
12:20:59PMunchYardanico, how do you like Hugo so far?
12:21:18FromDiscord<Yardanico> well, provided I only have 1 hello world blog post on the blog I can't say I have much experience :P
12:21:26FromDiscord<Yardanico> but it wasn't hard to tinker with the theme to adapt it to my needs
12:21:28PMunchHaha, fair point :P
12:21:30FromDiscord<Yardanico> and hugo seems to be very fast
12:21:46FromDiscord<Yardanico> it can act as an interactive server (rebuilding content on changes) and that is really fast
12:21:50FromDiscord<Yardanico> under 10-20ms usually
12:21:57FromDiscord<Yardanico> closer to 1-5
12:22:37PMunchOh cool
12:23:06FromDiscord<Yardanico> so yeah, this is my small attempt at using highlight js themes for nim highlite module (ignore the last func and missing imports) - https://gist.github.com/Yardanico/144caea455c43917a409a22b56f34c03
12:23:36FromDiscord<Yardanico> in the end you get static annotated code that when combined with a highlight jss css theme (there's a lot of them) will result in syntax highlighting :P
12:24:01*arielp quit (Quit: WeeChat 3.0.1)
12:25:19FromDiscord<Yardanico> so the highlighting is all colourful even if it's using nim's own highlighting https://media.discordapp.net/attachments/371759389889003532/818459357875929099/unknown.png
12:25:34FromDiscord<Yardanico> I think we might want to improve rstgen to highlight some of this stuff too - for example builtin types
12:25:44FromDiscord<Yardanico> the current highlighting is fine but it's a bit too "bland" :P
12:25:50FromDiscord<Yardanico> only keywords are highlighted
12:25:56FromDiscord<Yardanico> well, also literals and stuff
12:29:14*SebastianM joined #nim
12:35:11FromDiscord<Yardanico> i forgot - is there anything in the stdlib to escape stuff to be HTML-friendly ?
12:36:58FromDiscord<Yardanico> ah right https://nim-lang.org/docs/cgi.html#xmlEncode%2Cstring can work
12:37:11FromDiscord<Unaimend> So Is it correct that the `==` operator cannot compare sequence of two different types?
12:37:27FromDiscord<Unaimend> (edit) "So Is it correct that the `==` ... operatorof" added "" | "operator ... cannot" added "of `seq`"
12:37:33FromDiscord<Yardanico> of course, how would it do that?
12:37:49FromDiscord<Unaimend> i.e. seq[StringView] und seq[string]
12:38:04FromDiscord<Unaimend> in my exampleI do not see a problem
12:38:22FromDiscord<haxscramper> You can just implement ``func `==`(a: Type1, b:DifferentType): bool``
12:39:27FromDiscord<Unaimend> In reply to @haxscramper "You can just implement": yea did that
12:41:19FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2S8w
12:41:33FromDiscord<Unaimend> (edit) "https://play.nim-lang.org/#ix=2S8w" => "https://play.nim-lang.org/#ix=2S8x"
12:41:45FromDiscord<Unaimend> (edit) "https://play.nim-lang.org/#ix=2S8x" => "https://play.nim-lang.org/#ix=2S8y"
12:42:05FromDiscord<Unaimend> (edit) "https://play.nim-lang.org/#ix=2S8y" => "https://play.nim-lang.org/#ix=2S8z"
12:42:30FromDiscord<Yardanico> no
12:42:46FromDiscord<Yardanico> wait actually
12:42:49FromDiscord<Yardanico> yeah it won't work
12:42:54FromDiscord<Yardanico> you have to define a custom `==` for seqs of different types
12:43:05FromDiscord<Unaimend> kk
12:43:19FromDiscord<Yardanico> Nim's own == expect both sides to be the same type
12:43:52FromDiscord<Unaimend> Do we have a nice way to write commutattive operators↵beause now you have to define
12:43:55FromDiscord<haxscramper> yeah, you need to implement ``func `==`[T0, T1](a: seq[T0], b: seq[T1]): bool = ``
12:44:21FromDiscord<Unaimend> ==(a: T, a:B) and ==(a;B, a:T)
12:44:49FromDiscord<Unaimend> sry my explanation is lacking
12:44:58FromDiscord<Unaimend> ofc a macro should be easy
12:44:59FromDiscord<Yardanico> no, actually you won't have to make two of them
12:45:15FromDiscord<Unaimend> is this not solvable by templates?
12:45:25FromDiscord<Yardanico> ???
12:45:47FromDiscord<Unaimend> sth like defineEquals(type1, typr2)
12:46:03FromDiscord<Yardanico> as I said, you don't have to define it twice
12:46:10FromDiscord<Unaimend> sry
12:46:10FromDiscord<Yardanico> since both arguments are generic
12:46:19FromDiscord<Unaimend> yeah ok in this case
12:46:37FromDiscord<Unaimend> but when you normally define `==` you have to do it twice
12:47:00FromDiscord<Rika> even in this case its not needed, only a `==` for a: strview, b: string (and backwards too probably?) is needed
12:47:11FromDiscord<Yardanico> no he's right
12:47:22FromDiscord<Yardanico> in nim order of arguments matters in this case
12:47:32FromDiscord<Yardanico> for == for string and StringView
12:47:39FromDiscord<Unaimend> and its the same for `+` etc
12:47:42FromDiscord<Yardanico> yes
12:47:47FromDiscord<Rika> i just said what you just said
12:47:57FromDiscord<Unaimend> Should this be in the nim core lib?
12:48:06FromDiscord<Yardanico> well, I think it's not used that often
12:48:12FromDiscord<Unaimend> hmm kk
12:48:39FromDiscord<Unaimend> Then ofc it should not be in the core lib
12:49:05FromDiscord<Yardanico> so yeah, something like this
12:49:11FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2S8C
12:49:15FromDiscord<Yardanico> == definition copied from the same one for openArray
12:49:16FromDiscord<haxscramper> https://nim-lang.org/docs/manual.html#distinct-type-modeling-currencies
12:49:29FromDiscord<haxscramper> Distinct example just uses template
12:49:44FromDiscord<Yardanico> it borrows though
12:49:49FromDiscord<haxscramper> To define everything twice, but you can also implement `{.commutativeOp.}` macro pragma
12:50:02FromDiscord<Unaimend> In reply to @haxscramper "To define everything twice,": ahhh this I what I was looking fore
12:50:10FromDiscord<Yardanico> you'll have to make it yourself ;)
12:50:16FromDiscord<Yardanico> but it shouldn't be so hard
12:50:32FromDiscord<haxscramper> In reply to @haxscramper "To define everything twice,": sent a code paste, see https://play.nim-lang.org/#ix=2S8E
12:50:36FromDiscord<Unaimend> In reply to @haxscramper "I'm talking about this": yeah
12:51:05FromDiscord<haxscramper> I bet arraymancer has this implemented as macro
12:51:14FromDiscord<haxscramper> I'm 99.9% sure
12:51:16FromDiscord<Yardanico> XDDD
12:51:23FromDiscord<Rika> does using two generics guarantee that T0 and T1 are unique?
12:51:28FromDiscord<haxscramper> no
12:51:41FromDiscord<Rika> how do i guarantee uniqueness then?
12:51:55FromDiscord<haxscramper> But it is less generic than one with only single parameter, so it would use `seq[T]` for single sequences
12:52:17FromDiscord<haxscramper> In reply to @Rika "how do i guarantee": Not sure, maybe `T0, T1: not T0`
12:52:21FromDiscord<Rika> what if i want to emit an error if theres nothing more specific?
12:52:28FromDiscord<Rika> does that work...
12:52:31FromDiscord<Rika> lets see
12:52:45FromDiscord<haxscramper> It would be awesome if it did
12:52:56FromDiscord<Rika> !eval proc a[T0; T1: not T0](a: T0, b: T1) = discard
12:52:57NimBot<no output>
12:53:05FromDiscord<Rika> oooooooooo
12:54:02FromDiscord<Rika> !eval proc a[T0; T1: not T0](a: T0, b: T1); a(0, 0); proc a[T0; T1: not T0](a: T0, b: T1) = discard
12:54:03NimBotCompile failed: /usercode/in.nim(1, 40) Error: type mismatch: got <int literal(0), int literal(0)>
12:54:08FromDiscord<Rika> should error
12:54:16FromDiscord<Rika> OML
12:54:26FromDiscord<Rika> @haxscramper it actually works
12:54:31*SebastianM quit (Quit: -a- Bye Bye)
12:54:51FromDiscord<Rika> !eval proc a[T0; T1: not T0](a: T0, b: T1); a(0.int, 0.0); proc a[T0; T1: not T0](a: T0, b: T1) = discard
12:54:53FromDiscord<Rika> should work...
12:54:53NimBot<no output>
12:55:01FromDiscord<Rika> and it does 😮
12:55:15FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2S8K
12:55:27FromDiscord<haxscramper> Because it is really aambiguous
12:55:33FromDiscord<haxscramper> (edit) "aambiguous" => "ambiguous"
12:55:54FromDiscord<Rika> why would it not?
12:55:58FromDiscord<Rika> i dont see the issue...
12:56:13FromDiscord<Unaimend> depens how nim implements ths stuff I think
12:57:18FromDiscord<Unaimend> but I think it would be cool if this would work, but then I dont know a scenario we it would be usefull.↵But at least those template magicians in c++ found a use case for everything
12:57:28FromDiscord<haxscramper> In reply to @Rika "why would it not?": Generic parameter overlaps. You have one unconstrained that catches absolutely everything, and one more specialized, but it seems like overload resolution does not have such fine-grained selection to prefer first one over second
12:57:31FromDiscord<Rika> generics are really strong
12:57:38FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2S8P
12:57:50FromDiscord<haxscramper> This works, but because it explicitly uses single type for generic parameter
12:57:58FromDiscord<Rika> In reply to @haxscramper "Generic parameter overlaps. You": okay
12:58:00FromDiscord<Rika> understood
12:59:08FromDiscord<Unaimend> In reply to @haxscramper "Generic parameter overlaps. You": But I we what it it should be possible to implement
12:59:33FromDiscord<Unaimend> But we should make overload resolution to complicated
12:59:38FromDiscord<Rika> yes but i feel it would be difficult to implement
13:00:10FromDiscord<Unaimend> If I rember the overload res. stuff between templates and auto and normal funcs in c++ that was weird stuff
13:00:26FromDiscord<haxscramper> I think [T0; T1: not T0]` is different from `[T0, T1]` iff `T0 is T1`
13:00:30FromDiscord<haxscramper> (edit) "[T0;" => "`[T0;"
13:00:51FromDiscord<haxscramper> And `[T0 is T1]` is basically `[T]`
13:01:32FromDiscord<haxscramper> And C++ has SFINAE so it can just try to match every possible implementation
13:02:49FromDiscord<haxscramper> I.e. it does not try to solve any constraints to choose best-matching implementation, it just tries all of them in order and if there is some horrific `std::enable_if` that does not match it just goes over the next one. Well, at least that's what it looks like at first glance
13:03:43FromDiscord<Rika> is that one reason compilation explodes?
13:03:47FromGitter<ynfle> You could also put `not T0` in the type of the param
13:03:48*Tanger joined #nim
13:04:44FromDiscord<haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/semcall.nim#L102
13:04:45FromDiscord<haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/sigmatch.nim#L302
13:05:50FromDiscord<haxscramper> I think main parts of our sigmatch logic is somewhere around here. From what I can tell nim just selects best-fitting candidate over all possible ones by comparing them
13:06:40FromDiscord<haxscramper> In reply to @Rika "is that one reason": Part of the reason. This, multiplied by repeated reparsing and reinstantiation of templates (because header files)
13:07:28FromDiscord<Rika> 😄
13:07:42FromDiscord<Rika> In reply to @ynfle "You could also put": yeah, implicit generic
13:08:16FromGitter<ynfle> There is still an issue of it not being discarded which I'm not sure about
13:09:48FromDiscord<Rika> because the string is not used (not returned or consumed by other function)
13:09:49FromDiscord<Rika> ?
13:20:03m4r35n357Hi all, thought I understood the basics after porting a working program from c to nim, but clearly not! I am now porting a program that fails in c owning to "library rot", and am getting an "undeclared identifier" compiler error. Really basic huh? The error occurs at line 14 of https://pastebin.com/i5WTGjze (obviously plot & generate are stubbed out)
13:20:28FromDiscord<Unaimend> So can you use the IntelliJ profiler for nim programs? I head that there is an semi-official plugin for IntelliJ
13:22:34FromDiscord<Rika> m4r35n357: you didnt put the variable declaration keywords (`var` or `let`) before such
13:22:52FromDiscord<Rika> so it has to be `let c: ...` and `let d: ...`
13:22:59FromDiscord<Rika> or you can do a block let
13:23:18FromDiscord<Rika> `let(newline)(indent)c: ...(newline)(indent)d: ...`
13:23:37m4r35n357Rika how embarrassing! thx
13:23:40FromDiscord<Rika> have to do that for every variable you declare
13:23:49FromDiscord<Rika> so others below too
13:27:56FromGitter<ynfle> @Rika, not in my version
13:28:31FromDiscord<Rika> well i dont know what you're running so i cant determiune the issue
13:32:33*Tanger quit (Quit: Leaving)
13:33:00FromGitter<ynfle> The playground link I posted
13:33:05FromGitter<ynfle> Oh sory
13:33:09FromGitter<ynfle> Forgot to post it
13:34:09FromGitter<ynfle> https://play.nim-lang.org/#ix=2S8U
13:34:57FromDiscord<Rika> not returning string
13:35:07FromDiscord<Rika> (no return type)
13:36:21FromGitter<ynfle> Oh haha
13:42:34m4r35n357at the risk of further humiliation, I am now getting an unused variable error for a used variable (making the last line in the function an explicit return didn't make any difference) https://pastebin.com/6NXJSbz7
13:42:58FromDiscord<Rika> dude dont worry
13:43:04FromDiscord<Rika> no humiliation here
13:43:20FromDiscord<Rika> what line?
13:43:24m4r35n357line 339
13:43:30m4r35n357line 39
13:43:31FromDiscord<Rika> i mean in the paste 😛
13:43:33FromDiscord<Rika> oh ok
13:43:53FromDiscord<Unaimend> @Yardanico we need another nim stream, I need distraction from my exam preparation
13:43:57FromDiscord<Rika> unindent the P P line
13:44:02FromDiscord<Rika> you accidentally indented it
13:44:14FromDiscord<hamidb80> how can i print a address of a variable?
13:44:38FromDiscord<Rika> `echo aVar.addr.int`? not sure if that works...
13:44:49FromDiscord<Rika> maybe cast
13:45:02FromDiscord<Rika> `echo cast[uint](aVar.addr)`
13:45:14FromDiscord<Yardanico> only if it's a `var` of course
13:45:23FromDiscord<hamidb80> In reply to @Rika "`echo cast[uint](aVar.addr)`": what does `cast` do?
13:45:28JustASlackeryay for further humiliation
13:45:31FromDiscord<Yardanico> interpret one type as another type
13:45:35FromDiscord<Yardanico> bitwise
13:45:43FromDiscord<hamidb80> i could find docs about it
13:45:48FromDiscord<hamidb80> (edit) "could" => "couldn't"
13:45:54FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#statements-and-expressions-type-casts
13:46:22m4r35n357JustASlacker, glad to oblige; rika the indentation was not acccidental, and removing it makes no difference
13:46:52FromDiscord<Rika> lets see if i misread something
13:46:54FromDiscord<Rika> one moment
13:46:55m4r35n357I tried unindenting, and adding an explicit return
13:47:01m4r35n357neither works
13:47:23PMunchm4r35n357, you have an unmatched ) on line 39
13:47:36FromDiscord<hamidb80> hey
13:47:37FromDiscord<Rika> i told to dedent `P P - delta (p.mu2 r2 + K)` because in the code it's matched with the `let` and not the `proc`
13:47:40FromDiscord<hamidb80> you cant do that
13:48:07FromDiscord<Yardanico> ?
13:48:08PMunchAnd you're not returning anything..
13:48:30PMunchOh wait, yeah as Rika says line 41 should be unindented
13:48:34FromDiscord<Yardanico> and why do you need an address btw?
13:48:34m4r35n357Rika what about automatic return, does that not work within a "let"
13:48:40m4r35n357PMunch, that is it!
13:48:49PMunchm4r35n357, no it doesn't work within a let
13:49:03PMunchThe let block itself doesn't return anything
13:49:09JustASlackerIm just glad somebody else is also a noob
13:49:12FromDiscord<Rika> no, it doesnt make sense, `let` only does variable declaration
13:49:30m4r35n357PMunch, OK, I was actually testing that, but the ')' asked the result!
13:49:37m4r35n357masked
13:49:39PMunchBy the way, you don't need to declare your variable types
13:50:18m4r35n357OK I'll use inference, I was trying to find the bug
13:50:43PMunchI mean you can if you want to, or if you think it makes it more clear/easier to read. I was just saying that you don't have to
13:50:50PMunchIn case you weren't aware :)
13:51:50m4r35n357PMunch, I'm still learning where, I just took out the "let"s and started getting undeclared identifiers again . . .
13:52:11FromDiscord<Rika> thats not what he means
13:52:14FromDiscord<Rika> i think
13:52:22m4r35n357OK I get it
13:52:24FromDiscord<Rika> he means you dont need the : float parts and stuff
13:52:30m4r35n357sorry,my mistake
13:52:44m4r35n357it is very hot & sweaty here ;)
13:53:28PMunchOh right, yes you need the let/var/const part, but not the type (float/int/Dual) part
13:54:15PMunchBit weird that you got an unused variable error by the way
13:54:20FromDiscord<hamidb80> !eval var a = 1; echo repr(addr a)
13:54:22NimBotptr 0x55df97d70060 --> 1↵
13:54:51FromDiscord<hamidb80> In reply to @NimBot "ptr 0x55df97d70060 --> 1↵": i need something like that but without `ptr` and `-->`
13:55:03m4r35n357PMunch, AFAICT that was triggered by the unmatched bracket
13:55:21FromDiscord<dk> !eval var a = 1; echo repr(cast[int](addr a))
13:55:23NimBot94700569542752
13:55:31FromDiscord<Rika> !eval var a = 1; echo cast[uint](addr a)
13:55:33NimBot94549207056480
13:55:34FromDiscord<Rika> ?
13:55:43FromDiscord<Rika> no need to repr an int...
13:56:15m4r35n357PMunch, confirmed, just had the same thing further down ;)
13:58:01m4r35n357Great, all fixed, now I can start on the fun part ;)
13:59:48PMunchimport strutils; var x = 1; echo toHex(cast[uint](x.addr))
14:00:07PMunch!eval import strutils; var x = 1; echo toHex(cast[uint](x.addr))
14:00:11NimBot000055794BBF9060
14:00:33PMunchIf you want it as hex @hamidb80
14:01:20FromDiscord<Yardanico> @hamidb80 just saying - people from IRC won't see discord reactions :)
14:01:34PMunchm4r35n357, happy to be of help :)
14:01:37FromDiscord<hamidb80> In reply to @Yardanico "<@!745944009918251010> just saying -": yeah i know
14:02:16PMunchMakes it kinda hard for me to see that you liked my message though..
14:02:17FromDiscord<hamidb80> In reply to @PMunch "m4r35n357, happy to be": i saw some of your videos, you use `npeg` a lot 😅
14:02:37PMunchHaha, I used npeg a lot during AoC because it was an apt tool for the job :)
14:02:44PMunchBut yes, I have used it quite a bit
14:02:55PMunchReally nice tool
14:06:48FromDiscord<ITR> Does anything like this exist for Nim? https://youtu.be/8QiPFmIMxFc
14:07:08FromDiscord<Yardanico> what exactly?
14:07:33FromDiscord<Yardanico> ah, no, I don't think there's an editor that allows for this interactive-like thing
14:07:47FromDiscord<ITR> that's a shame
14:08:02FromDiscord<Yardanico> well, you can kinda do it with hot code reloading but it's not the same
14:08:15FromDiscord<ajusa> What's the best way to send a seq of bytes in Nim? The send function in net takes a string, so I assume I want to convert a seq of bytes to a string then. Is cast a good option here?
14:09:03FromDiscord<Yardanico> internally seq[char] is the same as string (except the null terminator), so yeah, you can usually just cast
14:09:08FromDiscord<Rika> it works kinda i guess but its not really a good idea
14:09:17FromDiscord<Yardanico> but it's an internal implementation detail, so it's up to you if you want to rely on it or not
14:09:43FromDiscord<ajusa> I guess my other option is a map to char and reduce to string maybe?
14:09:53FromDiscord<hamidb80> In reply to @ITR "Does anything like this": wow
14:10:05FromDiscord<Yardanico> @ajusa your other option is just a for loop, yes
14:10:28FromDiscord<ITR> In reply to @Yardanico "internally seq[char] is the": if it's a byte sequence then a null-terminated string would be horrible
14:10:28PMunch@ITR, seems like you have found yourself a project :)
14:10:38FromDiscord<ajusa> https://github.com/nim-lang/Nim/issues/14810 seems like it would help me
14:10:39PMunchThere's nothing inherently stopping Nim from being used like that
14:10:52PMunchEither through hot code reloading, or with NimScript
14:11:35FromDiscord<hamidb80> In reply to @PMunch "There's nothing inherently stopping": right
14:12:35FromDiscord<ITR> hmm, so one feature he shows off is hovering a line of code to show its effect, so that would have to be some sort of custom editor, right?
14:12:49FromDiscord<Rika> In reply to @Yardanico "internally seq[char] is the": strings in nim dont have null terminators though do they?
14:13:02PMunchAh, yes that would need to be a custom thing
14:13:35FromDiscord<Yardanico> In reply to @Rika "strings in nim dont": they always do, for C compat, so that a conversion from a string to a cstring is kind of zero-cost
14:13:38FromDiscord<ITR> tho maybe an alternative with a macro could work
14:13:39PMunchI mean you could render the image with and without that line and then somehow show the difference
14:13:46FromDiscord<Yardanico> but null terminator isn't usually used for any string operations
14:13:48FromDiscord<Yardanico> nim strings have a length field
14:13:52FromDiscord<Yardanico> it's purely for C compat
14:15:43FromDiscord<ITR> maybe I'll try and do a project with hot-reloading or nimscript for music instead of graphics
14:15:46FromDiscord<Yardanico> so that cstring(nimstring) is zero-cost
14:16:35FromDiscord<Yardanico> and of course null terminator can be useful in hand-written lexers/parsers sometimes
14:16:48FromDiscord<Yardanico> You can't access a null-terminator of a nim string, but you can if you do cstring(string)
14:17:03FromDiscord<Yardanico> (in the past null terminator for nim strings was accessible as well)
14:19:02*abm joined #nim
14:20:04PMunchThis is what a string looks like in Nim: https://play.nim-lang.org/#ix=2S9n
14:20:06PMunchPretty much
14:20:25FromDiscord<Yardanico> in old runtime, yes
14:21:01PMunchIn old runtime?
14:21:06FromDiscord<Yardanico> with refc/etc
14:21:15PMunchIs that not what they look like now?
14:21:16FromDiscord<Yardanico> arc/orc is "new runtime"
14:21:22FromDiscord<Yardanico> in new runtime there's NimStringV2 = obj with len and p fields, and p is a pointer to NimStrPayload which has cap: int and uncheckedarray data
14:21:24FromDiscord<Yardanico> https://github.com/nim-lang/Nim/blob/devel/lib/system/strs_v2.nim
14:21:37PMunchOooh
14:21:43PMunchDidn't know that, thanks
14:23:40*JustASlacker quit (Ping timeout: 276 seconds)
14:23:41FromDiscord<Yardanico> Also if someone's curious - I mostly finished my nim highlighting "module" based on highlite - https://github.com/pietroppeter/nimib/blob/8dc6bad0ad4572715ea0767ba0a407bc175a4c57/src/nimib/highlight.nim
14:23:56FromDiscord<Yardanico> it uses highlight.js theme classes but that can be easily changed, and it highlights much more stuff than nim's highlite
14:24:01FromGitter<redblack3_gitlab> Is there a specific reason why the `len` field of strings is the first field? Why isn't the `ptr` the first field?
14:24:43FromDiscord<Yardanico> Honestly I don't know an answer for that, you'd have to ask someone like Araq or clyybber
14:24:44PMunchCache optimisation perhaps
14:24:56PMunchYou probably read length before starting to read data
14:24:58FromGitter<redblack3_gitlab> if it was the first field, just doing something like `addr nimstring` would give the null terminated string straight away without having to offset by `sizeof int`
14:25:02PMunchOr it's just random
14:25:08FromGitter<redblack3_gitlab> ah alright
14:25:14FromDiscord<Yardanico> @redblack it still won't because in NimStrPayload cap is the first field :P
14:25:20FromDiscord<Yardanico> then you'd have to rearrange that too
14:25:21PMunchI mean the way you do it is mystring[0].addr
14:25:26FromDiscord<Yardanico> yeah
14:25:38PMunchTo get the pointer to the first character in the string, which is the pointer to the whole string
14:26:34FromGitter<redblack3_gitlab> ah, didn't realize the `ptr` wasn't the string itself either
14:28:37PMunchIt is with the default GC, but not with the new runtime
14:30:40FromDiscord<fwsgonzo> Hey all, I have a problem with a multi-project build system. I have made a build script that runs nim on a source file, and then compiles it using CMake
14:31:01FromDiscord<fwsgonzo> this is for the most part fine, as it doesn't cause much rebuilding - at least I don't think so
14:31:22FromDiscord<fwsgonzo> so what happens when you add hundreds of projects into the mix? I think it all breaks down
14:31:56*a_b_m joined #nim
14:32:04*a_b_m quit (Client Quit)
14:32:16leorize[m]are you building C from Nim then integrate it with CMake?
14:32:17FromDiscord<fwsgonzo> with C/C++ hundreds of projects is no big deal, they all run through ninja and it sees only one of the projects changed, and then relinks that
14:32:22FromDiscord<fwsgonzo> yea
14:32:33leorize[m]I'd advise against that...
14:32:59FromDiscord<fwsgonzo> I need to have total control over the build as this is for a custom 64-bit RISC-V toolchain
14:33:02PMunchHmm, is there any way to generate JS code like this from Nim? https://developers.home-assistant.io/docs/frontend/custom-ui/lovelace-custom-card#defining-your-card
14:33:33FromDiscord<fwsgonzo> (edit) "I need to have total control over the build as this is for a custom 64-bit RISC-V toolchain ... " added "- but I'm open to ideas"
14:34:00leorize[m]you should build nim with the nim compiler :P
14:34:22leorize[m]the compiler should be able to cross compile
14:35:48FromDiscord<fwsgonzo> and what happens then, it doesn't rebuild all the projects that haven't changed at the ~speed of ninja?
14:36:05*abm quit (Ping timeout: 256 seconds)
14:36:19FromDiscord<haxscramper> In reply to @ITR "Does anything like this": if you want you can write macro that rewrites your code from something like `interactiveConst(10, "Control name")`, which generates list of constants that could be configured at runtime, and it would be only a matter of implementing editor that can edit things interactively. https://play.nim-lang.org/#ix=2S9v < this could be used as a starting point
14:37:05FromDiscord<haxscramper> So you have all constants, only need to call `setIC` with appropriate IDs somehow
14:37:20FromDiscord<haxscramper> All locations in original source code are stored in `icMap`
14:38:42leorize[m]@fwsgonzo ninja does nothing special aside from a better build format than make imo
14:38:51FromDiscord<ITR> In reply to @haxscramper "*if* you want you": sent a long message, see http://ix.io/2S9x
14:39:04leorize[m]also your way will just slow you down when IC stabilize in Nim
14:39:54leorize[m]@fwsgonzo you can just rebuild the nim always :P the compiler knows what it's doing
14:40:00leorize[m]anyhow, what's your issue right now?
14:41:05FromDiscord<fwsgonzo> let
14:41:20FromDiscord<haxscramper> In reply to @ITR "My current idea is": You can in theory use hot code reloading, but it would be much slower compared to set/get for value in sequence at runtime. Even with tcc I doubt you would be able to get decent feedback speeds
14:42:01FromGitter<redblack3_gitlab> Hey guys, is there an idiomatic way to get a random element out of a `PackedSet`? Or some sort of `pop` function that removes and returns the "last"/random element? I know sets by definition have no order, but I don't care which element I get. Right now I just do ⏎ ⏎ ```for first in self.recycler: ⏎ self.recycler.excl(first) ⏎ return first``` ⏎ ⏎ but my eyes...I could use a `seq` but I
14:42:01FromGitter... need `O(1)` performance for search [https://gitter.im/nim-lang/Nim?at=604637b844f5a454a4618a54]
14:42:19FromDiscord<ITR> hmm
14:42:19FromDiscord<haxscramper> If you want to change logic at runtime, then yes, HCR is an only option, but for only changing values it is overkill
14:42:37FromDiscord<fwsgonzo> let's say you have a game, and you are using sandboxed Nim as the game script - and there are hundreds of maps each with its own binary that is the maps logic - to quickly iterate on that you need to be able to have one build command for everything, so that when you edit files from multiple maps it just instantly builds. I'm sadly not convinced that Nim is the way to go. I'm currently using C++ as the script, which is not very user-frien
14:43:15PMunch@ITR, did you look at NimScript?
14:43:19FromDiscord<haxscramper> tcc can get you around 200ms for "hello world", but anything complex would take more time to recompile, and IIRC even with IC you recompile on module level
14:43:27FromDiscord<ITR> was gonna check out nimscript now
14:43:39FromDiscord<haxscramper> And yes ^ NimScript is also an option, should look into that
14:43:44PMunchhttps://github.com/beef331/nimscripter <- ElegantBeef has done some great work on making it usable
14:44:23FromDiscord<haxscramper> And also there is a series of articles https://peterme.net/how-to-embed-nimscript-into-a-nim-program-embedding-nimscript-pt-2.html
14:44:48leorize[m]@fwsgonzo I would say calling nim to build the nim part from cmake is wiser than generating the c sources
14:45:48PMunch@haxscramper, as the author of that series I would go the NimScripter route myself
14:46:02Clonkk[m]<FromDiscord "<fwsgonzo> let's say you have a "> As @PMunch said, Nim-scripter from elegant beef is quite useful. Otherwise as non-nim solution, Lua is probably what you want
14:46:18PMunchNimScripter was made right after that series, to make it nice and useable
14:50:35FromDiscord<ITR> can attest that lua is often used for stuff like that
15:00:14FromDiscord<Araq> you can also embed Python, it's more heavy weight but works much better than Lua IMHO.
15:01:18PrestigeLua syntax just doesn't feel right to me
15:01:30FromDiscord<Araq> in Lua the `nil` state is simply too pervasive, it's far worse than in other languages, Python included
15:02:22PMunchUse NimScript, popularize it :)
15:02:48FromDiscord<Araq> I'm sad nobody optimizes our VM, it's X times slower than freaking Python and I dunno why 😛
15:03:16PMunchOh, I thought it was about Python speed
15:03:26PrestigeIt got slower
15:03:44FromDiscord<Araq> in theory we have the much better design, register based VM, fast dispatching, no GC activity for integers
15:04:50PMunchAh, well that's not great
15:04:55PMunchThe fact it got slower I mean
15:05:00FromDiscord<Clyybber> but PNode for objects ;)
15:05:20FromDiscord<Araq> @Clyybber we lose in the `fib` benchmark
15:05:28FromDiscord<Araq> same for `fac`
15:05:50FromDiscord<Araq> there is something very weird going on 🙂
15:05:57FromDiscord<Clyybber> hmm
15:06:26FromDiscord<Araq> the PNodes for objects don't enter the picture and even these are faster than Python's dict based objects
15:06:30FromDiscord<mratsim> does it use computed gotos? Otherwise to go further some assembly is needed.
15:06:51FromDiscord<Araq> I never enabled .computedGoto, feared the codegen bugs
15:07:09FromDiscord<mratsim> but even then I don't think the dispatch is the bottleneck, would need a profile.
15:07:28FromDiscord<Araq> we dispatch not nearly as often as we generate few instructions
15:07:31FromDiscord<Clyybber> there are some low hanging fruits like https://github.com/nim-lang/Nim/issues/16790 but that doesnt explain fib either
15:07:59FromDiscord<Araq> thanks to the register based VM, we don't produce many instructions to begin with
15:08:28FromDiscord<Araq> we need to look at it via a profiler
15:08:37PMunchSo no-one knows if it is possible to output JS code in a specific way?
15:09:22*abm joined #nim
15:10:04FromDiscord<mratsim> if you turn your screen you can output it sideway
15:10:20PMunch-_-
15:10:35PMunchI meant more output something that would be compatible with this https://developers.home-assistant.io/docs/frontend/custom-ui/lovelace-custom-card#defining-your-card
15:10:42FromDiscord<Yardanico> @PMunch I mean you can probably emit the whole JS class if you want
15:11:45FromDiscord<Yardanico> IIRC classes in JS are just sugar
15:11:45FromDiscord<Araq> @PMunch we need `class` support for the FFI, somehow
15:11:59FromDiscord<Araq> this also comes up again and again for C++ interop
15:12:03FromDiscord<Araq> RFCs are welcome
15:12:41FromDiscord<Yardanico> found http://xahlee.info/js/js_without_class_keyword.html, might be relevant
15:12:49FromDiscord<Yardanico> not sure how to do "extends" though
15:13:23FromDiscord<mratsim> Class for C++ do work
15:13:39FromDiscord<mratsim> it's "only" the constructor and deleted destructors that are annoying
15:13:43FromDiscord<Yardanico> about JS - there are packers/etc that polyfill classes to older browsers, etc, so it should definitely be possible
15:13:55FromDiscord<Araq> @mratsim you cannot inherit and override a method
15:14:08FromDiscord<Araq> that frequently comes up for UIs
15:14:12FromDiscord<mratsim> well if you use methods 🤷
15:14:27FromDiscord<Araq> I don't, the C++ frameworks do
15:15:10PMunch@Yardanico, ooh that is interesting
15:15:37PMunchExtends probably just adds all the prototypes to the new object
15:15:52PMunchAt least that's how we used to do inheritance back in olden days in JS
15:16:02PMunchBefore it got class support
15:17:26FromDiscord<Yardanico> yeah, also found https://stackoverflow.com/questions/15192722/javascript-extending-class
15:18:41PMunchNow the problem is, how can I wrap everything Nim outputs in a class.. I can make a class, but a lot of functions and such are still outside of it..
15:19:26FromDiscord<Yardanico> I mean you can "emulate" it with older syntax with functions and prototypes and stuff
15:19:50FromDiscord<haxscramper> We'd have to hack into nim dispatching mechanism, or introduce second notion of 'method' to make it work
15:20:08PMunchI guess it might work with variables outside a class
15:20:13federico3https://arstechnica.com/gadgets/2021/03/more-top-tier-companies-targeted-by-new-type-of-potentially-serious-attack/
15:20:13PMunchMaybe..
15:20:13FromDiscord<haxscramper> Otherwise the best option is just generate c++ class and make it call him procedures internally
15:20:20leorize[m]we already have `exportcpp`
15:20:28leorize[m]shouldn't be hard to make it build classes
15:21:07FromDiscord<dom96> You could even make a `jsclass` macro 🙂
15:21:17FromDiscord<dom96> Instead of fighting the compiler in this case
15:21:21PMunchThat's exactly what I've done @dom96
15:21:40PMunchIn the dumbest way possible though: http://ix.io/2S9V
15:21:41FromDiscord<dom96> nice
15:21:51PMunchJust to have a look at the JS output
15:22:21FromDiscord<dom96> ahh, well whatever works, but I guess you'll need to make it possible to specify methods
15:22:25FromDiscord<dom96> and generate them appropriately
15:22:32PMunchYeah, that might be tricky
15:22:48PMunchBecause the Nim code still needs to know about the procedures
15:22:54FromDiscord<haxscramper> exportcpp is not documented in manual. How is it different from exportc and where I can find docs for it?
15:22:56FromDiscord<dom96> might not be worth the effort tbh
15:23:19PMunchOh, probably not. I'm just doing this to see if it is at all possible
15:23:32FromDiscord<Yardanico> @haxscramper from 1.0 changelog:"exportc now uses C instead of C++ mangling with nim cpp, matching behavior of importc, see #10578. Use the new exportcpp to mangle as C++ when using nim cpp."
15:23:32FromDiscord<haxscramper> or it just generates unmangled names or something (i.e. difference is not as big as `importc/importcpp`)
15:23:35PMunchI've already written add-ons for HA in Nim that works great
15:23:49PMunchWell, apart from some weird async bug that I can't figure out
15:24:14FromDiscord<Yardanico> https://github.com/nim-lang/Nim/blob/devel/compiler/pragmas.nim#L823 @haxscramper
15:24:16FromDiscord<haxscramper> @Yardanico Ah, ok, so basically no functional difference to speak of
15:24:22FromDiscord<haxscramper> Only mangling
15:41:43FromDiscord<ITR> hmm, getting an issue with nimscripter, it's complaining about not being able to open file "strutils" on line 16 in nimscript.nim
15:42:02FromDiscord<ITR> which seems to be the buildOS constant
15:42:59FromDiscord<ITR> this happens runtime when doing loadScript, even with the loaded script being empty
16:15:19FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#ix=2Saf
16:17:07FromDiscord<mratsim> so back to @Yardanico and @queersorceress , is `Thread[ref obj]` even supposed to work? maybe cc @Araq https://github.com/jackhftang/threadproxy.nim/blob/master/src/threadproxy.nim#L78-L96
16:17:28FromDiscord<Yardanico> yeah not sure about that, but it crashes while trying to deepCopy ThreadToken
16:17:51FromDiscord<Yardanico> and fails on the string somehow
16:19:37FromDiscord<Yardanico> but yeah threadproxy looks kind of shady
16:19:44FromDiscord<Yardanico> with the stuff it does to "avoid GC", etc
16:19:53FromDiscord<queersorceress> oh nooo
16:21:45FromDiscord<queersorceress> i was prepared for that anwser, but i really don't want to write the channel code myself. i'll use anything if it means not doing that from scratch.
16:22:14FromDiscord<Yardanico> honestly I can't help much because I don't know threads/deepcopy/etc in depth
16:26:23FromDiscord<queersorceress> i'm just trying to make a basic high level api for pushing work to a queue backed by a thread, and then communicating back the results of that work. the hard bit here is that nim's channel and threading apis are fairly bare bones so this is a lot of work to do correctly from scratch. using threadproxy took away most of work of making the low level apis into higher level ones. i'm fine with replacing that with anything, i just don't
16:28:10FromDiscord<queersorceress> but since the basic apis are built to not intentionally do both, this is Hard problem.
16:29:01FromDiscord<queersorceress> unfortunately it's this or doing something horrible and confusing with locks and this seems far more elegant.
16:29:38FromDiscord<mratsim> I managed to get Weave first comment on a the 4 HN entry 🙂 https://news.ycombinator.com/item?id=26385075
16:29:44FromDiscord<mratsim> (edit) "4" => "4th"
16:32:07FromDiscord<queersorceress> and since the base application i'm working with is jester, so this code is going to be running from async already, i don't think i can feasibly do it with locks without causing massive hangups.
16:33:34FromDiscord<Yardanico> @queersorceress well, I think it's mostly a lib issue because I managed recreate the same minified version of the bug from the "Manually Create Thread" example
16:33:45FromDiscord<Yardanico> and the breaking point was adding the Queue object
16:33:55FromDiscord<Yardanico> as a return type to createQueue
16:33:58FromDiscord<Yardanico> that breaks it
16:34:16FromDiscord<Yardanico> actuall;y sorry not that
16:34:23FromDiscord<Yardanico> removing this breaks it
16:34:29FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2San
16:35:08FromDiscord<queersorceress> so that originally wasn't there, the queue got stored onto the queuemanager in a table instead of being returned.
16:35:47FromDiscord<queersorceress> if that isn't there then the code does nothing, as no work would get pushed onto the thread.
16:37:21FromDiscord<Yardanico> but this really makes it work :D
16:37:33FromDiscord<Yardanico> https://gist.github.com/Yardanico/d268f4a97f32f406813291628c19d8d8
16:37:39FromDiscord<Yardanico> ` let answer = waitFor proxy.ask("thread_1", "init", newJNull())` and handling that in workerMain
16:37:40FromDiscord<Yardanico> and it works
16:37:44FromDiscord<Yardanico> 🥴
16:37:56FromDiscord<Yardanico> dont ask me why, I don't know
16:38:17FromDiscord<Yardanico> actually you don't even have to handle it in workerMain
16:39:43FromDiscord<queersorceress> wait, what? so pushing block of work onto the thread does something to resolve the deepcopy?
16:39:50FromDiscord<Yardanico> exactly, I don't know
16:40:00FromDiscord<Yardanico> so yeah, if you're fine with that strange workaround and the fact that things might break in some other way later, then you can use it :P
16:41:47FromDiscord<queersorceress> that feels a bit too magic for what i'm trying to do here but i appreciate the work-around. though it makes me worried to make any more progress incase this is totally unsupported behavior.
16:43:26FromDiscord<Yardanico> juggling raw pointers can sometimes be dangerous, but it all depends on the exact case
16:45:24FromDiscord<queersorceress> @Yardanico this is the original code, what you were looking at was a more simplified version https://gist.github.com/samdmarshall/4689f3f08aea17c50616296d057a3a6d
16:46:59FromDiscord<queersorceress> it's what i would like the api to look like, idk if that changes any of the behavior significantly but it's the same deepcopy crash
16:47:58FromDiscord<Yardanico> well it seems to work fine with that workaround
16:48:19FromDiscord<Yardanico> just add ` let answer = waitFor ctx.main.ask(thread_name, "init", newJNull())` after `createThread`
16:48:28FromDiscord<queersorceress> so it's not related to returning the queue?
16:48:34FromDiscord<Yardanico> i have no clue :D
16:48:42FromDiscord<Yardanico> its really really strange
16:49:26FromDiscord<ajusa> In reply to @ajusa "I'm getting a strange": Tries debugging this further, it doesn't seem like I call connect on the same socket twice either. I read through a bit of async/await stuff in Nim but that didn't really help either...
16:49:37FromDiscord<queersorceress> that is, urgh, i don't think that's okay. i wouldn't even call that okay in C.
16:49:50FromDiscord<Yardanico> i don't think that this is okay either
16:49:56FromDiscord<queersorceress> hahaha
16:50:49FromDiscord<Yardanico> In reply to @ajusa "Tries debugging this further,": you can't reconnect the socket
16:51:05FromDiscord<Yardanico> you have to make a new one for each connection
16:52:27FromDiscord<ajusa> hm, I moved the socket creation to be inside of the while loop and now I get a "Bad file descriptor" error. Thanks though, that's one error resolved 😄
16:52:35FromDiscord<Yardanico> this might not be in the asyncdispatch/asyncnet docs, but this is how sockets behave everywhere
16:52:36FromDiscord<Yardanico> e.g. see https://stackoverflow.com/questions/51901478/python2-7-socket-error-37-operation-already-in-progress
16:52:40FromDiscord<Yardanico> same thing but in Python
16:53:45FromDiscord<queersorceress> then i think this will have to wait until someone more knowledgeable can take a look. that is, unless you wanna implement this for me (just kidding). it would help a lot of people though! this is unfortunate that this is my holdup, as working in C i could have solved this and moved on already.
16:55:47FromDiscord<ajusa> In reply to @ajusa "hm, I moved the": fixed this as well, can't close a socket that failed to connect
16:56:43FromDiscord<mratsim> In reply to @queersorceress "then i think this": write the backend in C maybe and wrap it from Nim.
16:57:37FromDiscord<Yardanico> In reply to @ajusa "fixed this as well,": you should also use withTimeout
16:57:40FromDiscord<mratsim> I do plan to write some threadpool code this week or next week.
16:57:50FromDiscord<Yardanico> @ajusa see https://github.com/Yardanico/adbscan/blob/master/src/adbscan.nim#L101
16:59:00FromDiscord<queersorceress> oh, wait a minute. is it possible that because the thread is created manually, it lacks some internal reference inside threadproxy that causes it to get released early when it leaves scope, hence the deepcopy, and by dispatching some work to it, that reference gets held and thus turns out okay?
16:59:22FromDiscord<Yardanico> maybe it's something like that, yeah
16:59:42FromDiscord<Yardanico> maybe you should open an issue?
16:59:54FromDiscord<Yardanico> the person is active on github so they'll probably respond
16:59:57FromDiscord<queersorceress> if that's all then i can totally live with that as behavior.
17:01:01FromDiscord<ajusa> In reply to @Yardanico "<@!102899813149855744> see https://github.com/Yarda": Why is this wrapped in a try block? https://github.com/Yardanico/adbscan/blob/master/src/adbscan.nim#L131
17:01:07FromDiscord<queersorceress> In reply to @mratsim "write the backend in": if i write this in C then i'd be using libdispatch and that would still be a major pain to wrap for use with nim.
17:01:18FromDiscord<Yardanico> @ajusa see the comment
17:01:29FromDiscord<Yardanico> if it's already closed it'll raise an exception
17:01:43FromDiscord<Yardanico> and isClosed didn't work for me that well
17:02:04*vicfred joined #nim
17:02:17FromDiscord<ajusa> In reply to @Yardanico "and isClosed didn't work": gotcha, that's the exact same issue I was running into. It was saying isClosed is false, I would try to close it, and then I would get an exception
17:03:15FromDiscord<queersorceress> i'd honestly rather do all this in nim as my experience writing multithreaded code in nim isn't too high and i'd like to change that. also getting libdispatch to work on any non-macos platform is a pain.
17:08:23FromDiscord<mratsim> ah yes libdispatch uses named threads and channels.
17:09:56FromDiscord<queersorceress> it's my go-to for a nice high level abstraction of concurrency/threading, difference here would be a queue is always backed by a thread, whereas with libdispatch it isn't guaranteed to be.
17:12:17FromDiscord<queersorceress> the names are so you don't need to pass around the objects, and afaict it would fit into nim's concurrency model fairly easily, if implemented properly - but nobody has implemented this yet.
17:13:23FromDiscord<mratsim> There are/were a couple of roadblocks.
17:14:19FromDiscord<mratsim> 1. strings couldn't be sent across threads until arc (or with Boehm GC), which is problematic when you use named threads.↵2. we need a threadsafe table which is also another problem↵3. we need a robust threadpool
17:14:23FromDiscord<dom96> @ajusa btw note that `await` will also `yield`, so doing `yield` is redundant, it may in fact cause problems
17:14:32FromDiscord<dom96> (edit) "@ajusa btw note that `await` will also `yield`, so doing `yield` ... is" added "+ `await`"
17:17:15PMunch@dom96, I'm looking at this async issue I'm having. Is there anything wrong with putting async procedures in a sequence?
17:17:20PMunchThis is my little library: http://ix.io/2SaB
17:18:28PMunchAnd this is how I use it: http://ix.io/2SaC
17:18:49FromDiscord<dom96> what's the issue?
17:18:54FromDiscord<queersorceress> In reply to @mratsim "1. strings couldn't be": in this case, you wouldn't need to send the string across threads, just the same representation, no? the threadsafe access of the table should be handled by a lock, that would be kinda clunky but would "work". and yes, the lack of robust threadpool has been a problem.
17:19:26FromDiscord<mratsim> yes we can send a cstring to make them threadsafe 😄
17:20:08PMunchThat onEvent is triggered just fine multiple times, but for the final time when it turns on all the lights and starts the radio it triggers the actions but is then stuck at high CPU utilisation and won't trigger the next day.
17:20:23FromDiscord<mratsim> The locked version of the table does exist https://nim-lang.org/docs/sharedtables.html but it's a stop gap for me
17:23:44FromDiscord<queersorceress> i mean, as long as you the programmer can construct an identical string, everything else doesn't matter. like, with libdispatch, if you are naming threads it's usually because they have a specific purpose so the name is unlikely to not be hardcoded.
17:25:20FromDiscord<dom96> PMunch: Hard to say, I don't see you doing anything super strange, maybe apart from the `setTimer`
17:25:27FromDiscord<queersorceress> so in my case i'm making this thread to handle all my disk io, so regardless of where i am, i can always use the same string constant as the thread name to give work to the right thread.
17:25:45PMunch@dom96, got a better way of doing that?
17:26:07FromDiscord<dom96> sent a code paste, see https://play.nim-lang.org/#ix=2SaE
17:26:07FromDiscord<dom96> bbl
17:26:33PMunchThat seems like such a hack though..
17:26:48FromDiscord<queersorceress> in a more complex example or use case that might not be true, or for threads created dynamically to do individual tasks, but with libdispatch those usually don't have names.
17:27:54PMunchI guess I already have the `while true`/`sleepAsync` loop though..
17:32:19PMunchSolving this issue means this library would be ready for publishing by the way. And then I can write an article about writing HomeAssistant automations in Nim :)
17:45:34FromDiscord<Goel> Why gintro have a single monolithic page to scroll instead of separate documents or tabs like the other repos of that kind? https://github.com/StefanSalewski/gintro
17:46:19*m4r35n357 quit (Ping timeout: 245 seconds)
17:48:51FromDiscord<queersorceress> author's preference? it might be easier to search a single page than to dig through multiple. i assume people using the api would already be familiar with it's use
17:48:52*m4r35n357 joined #nim
17:51:24PrestigePMunch: do you want assistance with the nimlsp with CoC issue? I could look into it, given details on why allowExtra isn't a proper solution
17:51:39PrestigeBeen "broken" for a few months iirc
17:51:52PMunchRight.. It was that..
17:52:18PMunchIt has sorta been filed away as "someone elses problem" after you created the issue in the CoC client
17:52:35PMunchShould be a very easy fix I think
17:55:25FromDiscord<mratsim> Pretty sure it's because Nim docgen isn't suited for multipage documents
17:55:29FromDiscord<mratsim> @Goel
17:59:35PrestigePMunch: I can't find the conversation about the issue on nimlsp. Do you have it handy or know details on the prob? I could just try recreating it, I suppose..
17:59:51PMunchWhich issue?
18:00:04Prestigehttps://github.com/PMunch/nimlsp/issues/71 ande https://github.com/neoclide/coc.nvim/issues/1766
18:00:43FromDiscord<queersorceress> @mratsim okay thanks to @Yardanico's work-around my code seems to work now, but seems to be performing multiple operations at once on the thread i made. based on the behavior of the async commands i'm giving i thought that this wouldn't be the case; will i have to add my own deque to manage the execution of new work? if so then i'm starting to think that threadproxy is not something i can rely on to do the heavy lifting of channel
18:02:01FromDiscord<mratsim> I didn't use asyncdispatch much so I don't know the execution model behind (dos it try to drain all the ready work at once or one by one)
18:03:20PMunchWell this was your original fix: https://github.com/PMunch/nimlsp/pull/44
18:04:20PMunchHmm, you don't seem to have created an issue for that though..
18:04:24PrestigeYeah, that was the solution but not much detail was provided
18:05:06PMunchWell the problem was that CoC sent extra fields, so the messages with extra fields weren't seen as valid messages (because they aren't)
18:06:11PrestigeWhat was that causing an issue for? I'm not seeing that as forbidden in the jsonrpc spec, at least
18:07:05FromDiscord<queersorceress> or rather, i think my question is, based on this example (https://github.com/jackhftang/threadproxy.nim/blob/master/examples/simple_ask.nim) if you were to "ask" the `worker_0` thread for multiple sums, it should perform them serially, not concurrently. as the `workerMain` function would block until it was done one operation because of the `waitFor proxy.poll()`. but that seems like it was an incorrect assumption.
18:07:38PMunchWhere does it say you can have extra fields?
18:07:53PrestigeIt doesn't, but it also doesn't say it isn't allowed
18:07:57Prestigeas far as I can tell
18:08:05PMunchWell they define a spec, I've stuck with the spec
18:08:29PrestigeDid this break something by having extra fields?
18:08:33PMunchYes
18:08:38PMunchI'm trying to find the issue
18:08:40PrestigeKk
18:10:54*vicfred quit (Ping timeout: 256 seconds)
18:11:59FromDiscord<dom96> In reply to @PMunch "That seems like such": I use this pattern all the time. Don't see what's hacky about it. You could make it better I guess by implementing a setTimer proc ala JS.
18:12:46PMunchWell the hacky part is waiting a minute between checks
18:12:59PMunchFor this case it isn't really an issue, but I just don't like the pattern
18:13:42PMunchHmm, can't seem to find it Prestige
18:13:58FromDiscord<dom96> huh, the idea is you set the timer to whatever you want
18:14:10PrestigeSame D:
18:14:15FromDiscord<dom96> if you want code to run every 60 secs then set it to 60 secs
18:14:22PMunchBut the issue is that notifications and requests are differentiated by if they have an "id" field or not. With allowExtra a notification is seen as a valid request.
18:14:57PrestigeWait, can't you just check if `id` exists or am I misunderstanding?
18:15:08PMunch@dom96, well in my code I set the timer to the next alarm on my phone - 30 minutes. Then in steps from there until the alarm rings.
18:15:16FromDiscord<Daniel> In reply to @Goel "Why gintro have a": Stefan really invested huge work, effort and time into it, but indeed navigation of the website could be more functional.
18:15:17PMunchContinuously checking if the alarm changes
18:15:31PMunchPrestige, yes that is exactly what you can do
18:15:38PMunchAnd what my solution was going to be
18:16:03FromDiscord<mratsim> In reply to @Daniel "Stefan really invested huge": Well, I think Nim docgen isn't up to par.
18:16:07FromDiscord<Daniel> (edit) "In reply to @Goel "Why gintro have a": Stefan really invested huge work, effort and time into it, but indeed navigation of the website could be ... more" added "much"
18:16:20FromDiscord<mratsim> I did the same thing as him for Weave, dump everything in the README
18:17:13PMunchPrestige, or rather I was going to run whenValid without allowExtra on the message vs. notification check. And then with it on the parse specific methods parts
18:18:23PrestigeHm yeah that could work
18:18:39PrestigeEither way I think it would be a good thing to get this working again for us vim users
18:19:02PMunchWell, I'm a vim user and don't really have an issue
18:19:39PMunchBut yeah, I'm fixing it now
18:19:54PrestigeThanks!
18:22:45PMunchFun fact, nimlsp freaks out completely on nimlsp source-code :P
18:23:14PrestigeYeah I saw that haha, think because of the way nimsuggest is imported?
18:25:11PMunchI dunno, it's like it is looking at its own brain and freaking out by what it seems
18:25:24PMunchLike if you opened the skull of a person and found a nest of gnomes pulling levers
18:25:32PMunchThere, this should fix the issue: https://github.com/PMunch/nimlsp/commit/c0e05cdd750bdada305dac7cd639f0755aa3253c
18:29:25Prestigelmao PMunch
18:29:57PrestigeI'll test that out
18:32:31PMunchUgh, I wish there was a pre-built Nim Docker image for HomeAssistant..
18:32:39PMunchIt takes foreeeever to build
18:32:52FromDiscord<Vindaar> I've finally done it. I've reached peak Nim. Compiler uses 10 GB of RAM, but still compiles successfully in 55 s 😎 🤣 ↵(I have no idea what kind of macro or concept madness is happening here) https://media.discordapp.net/attachments/371759389889003532/818551860713095178/unknown.png
18:33:36PMunchDjeez
18:37:14PrestigePMunch: verified I have diagnostics with coc-nvim now, thanks for the fix!
18:37:42PMunchNo problem, now tell CoC to get their shit together and stop breaking the spec! :P
18:38:36PrestigeHaha well if I had specifics on what they were sending I would file an issue
18:39:14PrestigeShould be able to close #71 now
18:40:01PMunchYou should be able to see that from the logs from nimlsp
18:45:02*Gustavo6046 quit (Remote host closed the connection)
18:49:28*Gustavo6046 joined #nim
18:50:27FromDiscord<ajusa> In reply to @dom96 "<@!102899813149855744> btw note that": Yep, thank you very much! I found a github issue from a few years ago where you said the same thing, so I've updated my code accordingly.
19:02:23FromDiscord<dk> sounds like `yield` should be an error in async
19:08:38federico3Araq: want to take a look at the old advisories (not the Nimble ones) before I publish them? https://github.com/nim-lang/security/security
19:15:08FromDiscord<Vindaar> In reply to @Vindaar "I've finally done it.": sent a code paste, see https://play.nim-lang.org/#ix=2Sbf
19:15:38PMunchHmmm. I'm looking at some code for the Teensy and I want to write code like `D6.input(); D6.pullup(); D6.high(); D6.low()` and generate Nim code like `portd or (1 shl 6)`
19:15:51PMunchWhat would be the best way of doing this?
19:17:04PMunchI think I can do `Pin[Port: static[string], Num: static[int]]` and then define the procedures as macros that grabs the port and created the correct identifier.
19:17:13PMunchBut that feels like a bit of a hack..
19:30:21FromDiscord<x19> is it possible to call external masm procs from a nim program?
19:31:29*waleee-cl joined #nim
19:32:39FromDiscord<mratsim> In reply to @x19 "is it possible to": yes
19:33:02FromDiscord<x19> nice
19:33:14FromDiscord<mratsim> This is how I compile ASM code alongside Nim: https://github.com/status-im/nim-blscurve/blob/master/blscurve/blst/blst_lowlevel.nim#L25
19:33:16PMunchWell this is an annoying issue: http://ix.io/2Sbn
19:33:28PMunchNo further message on what's wrong..
19:33:37FromDiscord<mratsim> and otherwise you can just link it if you have an object file
19:34:10FromDiscord<x19> nice so i just use the compile pragma the masm assembly code with --cc:vcc
19:34:56PMunchThis is my code by the way: http://ix.io/2Sbo
19:35:06PMunchWait..
19:35:09PMunchI'm an idiot
19:41:03PMunchJust creating an object out of the pins and making them const works just fine..
19:43:37FromDiscord<Gary M> I know this is weird but is there a way to turn off all error checking for a line?
19:44:18FromDiscord<konsumlamm> comment it out?
19:44:24FromDiscord<Gary M> the thing is that I have some when defined(linux): code that creates types different than when defined(windows):
19:44:36FromDiscord<Gary M> so it thinks it has illformedAST when I'm using windows
19:44:54FromDiscord<Gary M> but everything compiles fine
19:47:26FromDiscord<mratsim> {.push checks:off.} and then {.pop.}
19:48:09FromDiscord<Gary M> I did try that earlier but maybe the issue is that I didn't restart vscode
19:48:10FromDiscord<mratsim> use a template for convenience: https://github.com/status-im/nim-blscurve/blob/master/blscurve/bls_batch_verifier.nim#L170-L180
19:48:12FromDiscord<Gary M> so let me try again
19:48:37FromDiscord<Gary M> nope, it's still showing the erros
19:48:54FromDiscord<Gary M> https://i.imgur.com/xExb3k4.png
19:49:39FromDiscord<haxscramper> That is a hard error, you can't disable it with checks etc. You need to wrap everything in `when`
19:49:59FromDiscord<haxscramper> To conditionally compile for different OS
19:50:15FromDiscord<Gary M> it is wrapped with when defined(linux):
19:50:40FromDiscord<Gary M> it's probably a weird issue to do with using WSL2
19:51:07FromDiscord<haxscramper> Then some other `define` elsewhere might also hide other parts
19:51:16FromDiscord<Gary M> but nimsuggest should be running in WSL2 with the linux installs of nimble pkg's
19:51:29FromDiscord<Gary M> hm, let me see.
19:53:09FromDiscord<Gary M> okay so the types are wrapped with another define so I think I know how to fix this. Thanks
19:53:32*xet7 quit (Remote host closed the connection)
19:54:33*xet7 joined #nim
19:55:11FromDiscord<Gary M> well, I thought I knew how to fix this
19:55:51FromDiscord<Gary M> adding the other define to a cfg file isn't being read by nimsuggest
19:57:05FromDiscord<zidsal> in the `mgetOrPut` runnableExamples it explains that it's easy to accidentally create a copy of the value. Is there anywhere I can read more about when nim copies stuff? Imagine I have a table of `[a, var b]` why does `table.mgetOrPut(a).add` mutable B but `var nowACopy = table.mgetOrPut(a)` make a copy
19:58:22FromDiscord<konsumlamm> what's a table of `[a, var b]` supposed to be?
19:58:49FromDiscord<zidsal> lets go with `[string, var seq[string]`
20:00:15FromDiscord<konsumlamm> the `var` wouldn't be part of the type of the value
20:00:43FromDiscord<konsumlamm> you'd have a `var Table[string, seq[string]]`
20:01:03FromDiscord<konsumlamm> In reply to @zidsal "in the `mgetOrPut` runnableExamples": the last part is correct
20:01:53FromDiscord<konsumlamm> in the first case, you directly pass the `var V` to a new function (`add`)
20:02:06FromDiscord<mratsim> In reply to @zidsal "in the `mgetOrPut` runnableExamples": copies can happens on assignment to temporaries.
20:02:12FromDiscord<mratsim> (edit) "happens" => "happen"
20:02:25FromDiscord<zidsal> and I am presuming add takes a var argument?
20:02:28FromDiscord<konsumlamm> but assigning ir to a new variable creates a copy (since `Table` is a value type)
20:02:38FromDiscord<konsumlamm> In reply to @zidsal "and I am presuming": exactly
20:03:19FromDiscord<zidsal> but why would the table being a value type matter when we're doing a mget surley that's going to return a sequence? I'm prsuming if the seq was a ref type it wouldn't copy?
20:03:39giacoI have to deal with a string protocol. I have to split all incoming packets into tokens of fixed size. What's the nim way to avoid allocating tons of strings and also gain some nim points with elegant solution?
20:06:36FromDiscord<konsumlamm> In reply to @zidsal "but why would the": mm ye, `seq` is a value type as well though
20:06:54FromDiscord<zidsal> ya, I was saying hypothetically if it was a ref type :p
20:07:21FromDiscord<zidsal> (edit) "ya, I was saying hypothetically if it was a ref type :p ... " added "I come from a java background so all of this is newish to me"
20:07:38FromDiscord<mratsim> In reply to @giaco "I have to deal": An elegant string solution only exists in Perl.
20:08:02FromDiscord<konsumlamm> if it was a ref, a `var seq[T]` wouldn't really be useful in the first place, since then you could modify it anyway
20:08:10FromDiscord<mratsim> if you want to avoid alloc, store the string in one buffer and offsets in another.
20:08:23FromDiscord<konsumlamm> though the problem would still persist i think
20:10:26giacomratsim I will never look back to Perl
20:13:47PMunchPrestige, now my editor gives me warnings as I type. Is this something you've done Prestige?
20:14:35PrestigePMunch: that makes sense because I'm checking for diagnostics when a file is modified - we should fix that
20:14:49PMunchI mean I kinda like it, but it probably means that nimsuggest runs pretty much constantly..
20:15:16PrestigeThere are a couple options. The first that comes to my mind is to only perform the checks after a file has not been modified for X amount of time...
20:15:20PrestigeYeah
20:17:38PMunchThat sounds like what many editors do with "wait until the user is done typing"
20:17:44PMunchBut even that might be too heavy for Nim
20:17:51Prestigehmm maybe so
20:17:54PMunchWith lots of macros and such nimsuggest can seriously chug..
20:18:36PMunchI've had Vim hang for a couple seconds every time I save because NimLSP is gathering data
20:18:59FromDiscord<queersorceress> sent a long message, see http://ix.io/2SbG
20:19:03PrestigeHm can we make it tuneable?
20:20:20PrestigePMunch: this block of code is responsible https://github.com/PMunch/nimlsp/blob/master/src/nimlsp.nim#L506 if you wanted to test changes
20:20:31Prestigewe still need to call `mod` above, though
20:21:11FromDiscord<mratsim> In reply to @queersorceress "<@!570268431522201601> if you are": sent a long message, see http://ix.io/2SbH
20:23:26PMunchI mean if you just change that to didSave isn't it going to fix it?
20:23:34PMunchOr move it rather
20:23:56PrestigeEssentially the same code exists for didSave, so you'd just need to remove the block that I linked
20:24:19PMunchOh
20:24:29PMunchWait why did you add that then? Did you intend to add this feature?
20:25:02PrestigeI did, but didn't think about the possible performance issues
20:25:13Prestigeworks on my machine, and all
20:26:26FromDiscord<queersorceress> In reply to @mratsim "It's a bit different": the named thread thing doesn't really matter to me, as long as i can hand work off to a specific/designated worker that behaves a specific way, rather than saying "here is work that needs to be done" and have it be done in a place that i don't control.
20:26:40FromDiscord<VinKer> How to get the 31st bit from this binary digit ? It's 1 in this case. 01000000000111110000000000000001
20:27:36FromDiscord<queersorceress> because then i'm right back to using locks in an environment that isn't conducive for locks, and that isn't going to be nice.
20:27:48FromDiscord<dk> !eval echo "01000000000111110000000000000001"[30]
20:27:50NimBot0
20:27:57PMunch-_-
20:27:57FromDiscord<dk> huh
20:28:30PMunch!eval let num = 0b01000000000111110000000000000001; echo ((num shr 31) and 1)
20:28:32NimBot0
20:29:30FromDiscord<queersorceress> and the channel thing only matter to me that i get a response back, not hung up on how, just so long as when the work is done i know what the end result was. channels just seem to be the intended way to do that.
20:29:42FromDiscord<VinKer> Thanks, let me try
20:30:13PMunchWell, it would be `let num = 0b01000000000111110000000000000001; echo ((num shr (31 - 1)) and 1)` for what you call the 31st bit
20:30:43FromDiscord<VinKer> Yes, shr 30 is right
20:32:33PMunchHere you can see it all working: https://play.nim-lang.org/#ix=2SbJ
20:33:32FromDiscord<VinKer> Just one more question. How do i get 16-23 bits from this binary number ? 01000000000111110000000000000001
20:33:53FromDiscord<mratsim> In reply to @queersorceress "the named thread thing": ah, yeah my threadpool will be hand over type of things
20:34:04FromDiscord<mratsim> Nim's threadpool does have a distinguished thread thing
20:34:18*haxscramper quit (Remote host closed the connection)
20:34:43*haxscramper joined #nim
20:34:50*haxscramper quit (Remote host closed the connection)
20:35:11FromDiscord<mratsim> In reply to @VinKer "Just one more question.": you shift by n and then and by 0b11111111
20:35:42FromDiscord<mratsim> n being 16 or 64-23 or depending if you are counting from the end or from the start
20:35:53FromDiscord<mratsim> (edit) "64-23" => "63-23"
20:36:06FromDiscord<VinKer> @mratsim Thanks, Let me try
20:36:06FromDiscord<mratsim> 63 being 64-1 assuming 64-bit integer
20:36:23FromDiscord<mratsim> and 64-1 is equivalent to mod 64 since 64 is a power of 2
20:36:38FromDiscord<konsumlamm> In reply to @VinKer "Just one more question.": i suggeat looking at the `bitops` module, that has a lot of useful helper fubctions regarding bit manipulation
20:36:41FromDiscord<mratsim> (edit) "and" => "`and`"
20:37:47FromDiscord<Gary M> I can cast an array of uin16's to pointer but I can't cast an array of a nim defined type to pointer, anyone know why?
20:38:12FromDiscord<VinKer> @konsumlamm Oh, that's good. Let me check
20:38:46PMunch@Gary M, because uint16's are numbers, and pointers are numbers
20:38:52PMunchIt is probably not doing what you think it is doing
20:39:02PMunchIf you are actually doing casting and not `.addr`
20:40:59FromDiscord<Gary M> well if I try to addr the 0 index of the unit16 array is says the expression has no address
20:41:48FromDiscord<Gary M> it needs to return a pointer type
20:46:21FromDiscord<Gary M> I guess I'll try unsafeAddr in the mean time.
20:47:03PMunchWhat exactly are you trying to do
20:48:42PMunchIf you need to return a pointer type and Nim says the expression doesn't have an address it probably means it is stored on the stack and that pointer would point to somewhere in a stack frame that you just popped
20:48:54PMunchWhich will lead to all sorts of funny issues
20:50:19FromDiscord<Gary M> I'm passing an array of indices to a C library
20:56:37FromDiscord<William_CTO> sent a code paste, see https://play.nim-lang.org/#ix=2SbR
20:56:51FromDiscord<Gary M> oh hey that looks like mine and @ElegantBeef 's bot
20:58:13FromDiscord<Gary M> sent a code paste, see https://play.nim-lang.org/#ix=2SbS
20:58:53PMunchUhm @William_CTO, what question?
20:59:12PMunch@Gary M, and how are you doing that?
20:59:43FromDiscord<Gary M> the array stuff?
21:00:07FromDiscord<Gary M> `mIbh[4] = bgfx_create_index_buffer(bgfx_make_ref(sCubePoints[0].unsafeAddr, sizeOf(sCubePoints).uint32))`
21:00:38FromDiscord<Gary M> however I've opened another can of worms already in that I'm not sure how I'm supposed to load the shader programs 😄
21:01:07FromDiscord<William_CTO> Yep, ElegantBeef gave me permissions to use his macro for my own code. I plan to release the code back to y'all as well
21:01:10FromDiscord<Solitude> PMunch, bridge lost part of the message
21:01:26PMunch@Gary M, and how is sCubePoints defined?
21:01:44PMunch@Solitude, ah that explains it :P
21:01:56FromDiscord<Gary M> sent a code paste, see https://play.nim-lang.org/#ix=2SbX
21:02:13FromDiscord<William_CTO> Since Beef and Gary may understand better, I am trying to add a way to call a proc before the command is ran to check to see if it can be ran by another user. Am I on the right track or wayy off?
21:02:19FromDiscord<Gary M> @William_CTO no worries. He can probably help you with that stuff. I didn't write the macro part.
21:02:44FromDiscord<Gary M> I'm still very macro-shy haha
21:03:06FromDiscord<Gary M> oh you're trying to filter out commands by role or user id?
21:03:07FromDiscord<William_CTO> 👍
21:03:41FromDiscord<William_CTO> Things like that. Could also be used to implement a different cooldown system, or limit commands to devs only, etc
21:04:27FromDiscord<Gary M> okay so basically the way I would do that is in the nimcordBot.nim main file on the messageCreate event
21:04:44FromDiscord<Gary M> the way I filter it already for m.author.bot
21:04:47FromDiscord<William_CTO> For my bot I need different checks for different users
21:04:51FromDiscord<William_CTO> (edit) "users" => "commands"
21:05:00FromDiscord<William_CTO> (edit) "commands" => "commands."
21:05:11FromDiscord<Gary M> right right
21:05:33FromDiscord<Gary M> probably just needs a simple modification to mark the commands with an enum or something like that
21:05:51FromDiscord<Gary M> then you can implement your custom logic outside of the commands
21:06:49FromDiscord<Gary M> but there's a thousand ways to skin a cat and my way might not be the best 🤷
21:23:39ForumUpdaterBotNew Nimble package! questionable - Elegant optional types, see https://github.com/markspanbroek/questionable
21:26:21PMunchHmm, seems kinda similar to optionsutils
21:27:30*rwiser[m] joined #nim
21:30:06FromDiscord<ElegantBeef> @William_CTO i'd say make a new permissions slot which takes a `set[int]` of `allowed` and has an int of `cooldown`,
21:31:13FromDiscord<ElegantBeef> That way you can just do it on the command and it injects a check if the user is allowed and last time it did it
21:32:08*PMunch quit (Quit: leaving)
21:36:24*narimiran quit (Ping timeout: 246 seconds)
21:38:14*lritter joined #nim
21:56:35*ex_nihilo joined #nim
21:58:39*dddddd quit (Ping timeout: 256 seconds)
22:00:18*dddddd joined #nim
22:09:49FromDiscord<dom96> ahh, optimising binary data structures is fun
22:13:00FromDiscord<Araq> IC works for "hello world"!
22:14:50FromGitter<ynfle> 👏
22:16:39FromDiscord<Clyybber> for the second recompile now too?
22:16:44FromDiscord<Araq> yes
22:16:51FromDiscord<Clyybber> awesome!
22:17:54FromDiscord<Araq> yeah, I'm so excited that I had to join here
22:18:28FromDiscord<Araq> so far no bugfix had to add hacks
22:18:44FromDiscord<Araq> never seen it to work out like this before
22:18:56FromDiscord<Araq> maybe I'm getting better at compiler dev 😛
22:19:04FromDiscord<Clyybber> :D
22:19:38FromDiscord<Clyybber> while you are here; is there a reason we do the .Sup chaining instead of casting?
22:19:48FromDiscord<Clyybber> In ccgexprs.downConv
22:20:15FromDiscord<Araq> Ansi C's aliasing rules suggest .Sup is the best way to do it
22:20:56FromDiscord<Clyybber> I see, thanks!
22:21:06FromDiscord<Clyybber> And good night
22:21:21FromDiscord<Araq> good night
22:25:17FromDiscord<Gary M> does nim have a ternary conditional operator?
22:25:20FromDiscord<Gary M> x ? y : z
22:25:53FromDiscord<ElegantBeef> If expressions
22:26:04FromDiscord<Araq> `(if x: y else: z)`
22:26:13FromDiscord<Gary M> good enough lol
22:26:19FromDiscord<Gary M> hi Araq
22:27:07FromDiscord<ElegantBeef> Though someone did show off using `? :` by using that whole `:` allows you to pass the last arg
22:28:41FromDiscord<ElegantBeef> This abuse of `:` https://play.nim-lang.org/#ix=2Scp
22:30:44FromDiscord<Araq> https://play.nim-lang.org/#ix=2Scq a template reflects its lazy nature better
22:31:26FromDiscord<Gary M> is it something you dislike?
22:33:31FromDiscord<Araq> I would never use it, `if` is available as an expression
22:36:06FromDiscord<dom96> sent a code paste, see https://play.nim-lang.org/#ix=2Sct
22:38:58FromDiscord<j-james> Why does the `split` iterator not return an optional enumerator?
22:39:20FromDiscord<Araq> what is an optional enumerator?
22:40:05FromDiscord<ElegantBeef> The better question would be why does it need to return an optional enumerator 😛
22:40:21FromDiscord<j-james> Like `for thisThing, foo in "string"`
22:41:30FromDiscord<j-james> Because my sole use of `std/enumerate` is with `split` 🤷
22:43:30FromDiscord<Araq> you should probably learn about scanf
22:43:55FromDiscord<Araq> or use a csv parser, 90% of all usages of split are wrong
22:45:56FromDiscord<j-james> Probably should
22:52:26*tane quit (Quit: Leaving)
22:52:46FromDiscord<ElegantBeef> Hey it just so happens 90% of the uses of split are for copying the string into memory a second time for parsing!
22:53:43FromDiscord<Araq> first, let's read the full file into memory, even if it's 20 GB.
22:53:51FromDiscord<Araq> then let us call `lines` on it
22:54:00FromDiscord<Araq> then for every line we split at `;`
22:54:17FromDiscord<Araq> and then we strip the indivual cell
22:54:26FromDiscord<ElegantBeef> advent of code participants are nervously glancing around the room
22:54:55FromDiscord<Araq> and then we hope the file doesn't contain a single `\`
22:55:58FromDiscord<Araq> you should resist the temptation to read about parsing. Or anything. The first stack overflow reply surely is good enough for your use case
22:56:08FromDiscord<Araq> (edit) "you should resist the temptation to read ... about" added "a book"
22:57:05FromDiscord<Araq> in fact, I wonder if our `split` says "use scanf instead"
22:57:48FromDiscord<Araq> yeah, no "see also" entry for that... 😕
22:57:50FromDiscord<ElegantBeef> Well on the plus side borrowed memory stands to be an easy way to remove atleast some of the pitfalls from running split on a large string
22:58:19FromDiscord<Araq> hardly.
23:01:07FromDiscord<Araq> I want COW strings instead, not borrowing
23:01:35FromDiscord<Araq> but for now, good night
23:01:40FromDiscord<ElegantBeef> Buh bye
23:01:49FromDiscord<Araq> "Buh"?
23:01:57FromDiscord<ElegantBeef> That's what it actually is
23:02:19FromDiscord<Araq> COW is buh?
23:02:33FromDiscord<ElegantBeef> No buh bye is saying good bye
23:02:44FromDiscord<Araq> ah til
23:02:55FromDiscord<ElegantBeef> some people write bye bye, but it's buh bye
23:02:56FromDiscord<Recruit_main707> xD
23:03:19FromDiscord<Araq> bye bye bytes
23:25:19giacosuddenly, I'm not sure how should I edit an existing string without reallocation
23:25:50FromGitter<ynfle> Strings are mutable
23:26:51FromDiscord<ElegantBeef> You just edit the string, if it goes over the current string capacity it'll realloc
23:27:17giacosure, but to reuse it from scratch, is it just mystr.setLen(0) mystr.add("foo")?
23:29:11FromDiscord<ElegantBeef> setLen shouldnt change the capcaity so that should be fine
23:30:37*Vladar quit (Quit: Leaving)
23:32:23*NimBot joined #nim
23:46:23FromDiscord<reilly> In reply to @Gary M "good enough lol": If you want something more symbol-y then there's https://github.com/mattaylor/elvis