<< 21-12-2020 >>

00:01:14FromDiscord<KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2IVC
00:02:08FromDiscord<ElegantBeef> ... it's var args that means it can take an openArray or single values with comma seperations, so it's just `writeFile("sample.json", outputJsonData)`
00:02:47FromDiscord<ElegantBeef> giaco cant you just do this? https://play.nim-lang.org/#ix=2IVD
00:02:53FromDiscord<KingDarBoja> ;:/
00:02:53FromDiscord<KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2IVE
00:03:03FromDiscord<ElegantBeef> Look at your error
00:03:13FromDiscord<ElegantBeef> Look at what it expects
00:03:17FromDiscord<ElegantBeef> Look at the mismatch position
00:05:05FromDiscord<ElegantBeef> https://media.discordapp.net/attachments/371759389889003532/790369207736467456/unknown.png
00:05:37FromDiscord<ElegantBeef> Learning to read the error message will make life easier
00:05:48FromDiscord<ElegantBeef> ~~Plus when i get colourized output done it'll be easier~~
00:05:49FromDiscord<KingDarBoja> Agh, I thought I was using `writeFile`
00:06:20FromDiscord<KingDarBoja> (edit) "Agh, I thought I was using `writeFile` ... " added "🤦‍♂️"
00:06:50giacoElegantbeef, yes, I can. Not sure why I went with concat
00:06:57FromDiscord<ElegantBeef> Yea this would probably make it easier and less wall of texty 😛 https://media.discordapp.net/attachments/371759389889003532/790369679704981554/unknown.png
00:07:22FromDiscord<ElegantBeef> Idk using con cat sounds like you dont like cats, so i can see why you'd use it
00:08:04FromDiscord<KingDarBoja> Indeed
00:08:33FromDiscord<KingDarBoja> So the correct way should be creating the file, reading it using `let f = open()` and use that to pass it to write?
00:09:37FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=2IVF
00:10:25FromDiscord<KingDarBoja> Ty
00:10:49FromDiscord<KingDarBoja> Sorry for the noise 😛
00:39:48leorizedisruptek: this is pretty next-level: https://github.com/nim-lang/nimble/blob/3e07ffe71052735b6fc1d9ab06c195ce091ccb80/src/nimblepkg/packageinstaller.nim#L59-L75
00:40:12leorizenimble installs a `.cmd` and one without any extensions for binaries on windows
00:41:16leorizeso, uh, don't execute `.exe` on windows, that won't work
00:45:58*sirn quit (Ping timeout: 258 seconds)
00:46:18*fowl quit (Read error: Connection reset by peer)
00:46:36giacosealmove, your last update works nicely! :D sweet. Thanks
00:47:11*fowl joined #nim
00:47:36FromDiscord<shadow.> aoc day 20
00:47:37FromDiscord<shadow.> my brain is hurting
00:47:56*sirn joined #nim
00:48:17giacoI'm dealing with a piece of code where "foo.foldl(a.int + b.int, 0)" doesn't compile (returns undeclared identifier 'foo'), but "foldl(foo, a.int + b.int, 0)" compiles and runs successfully. What's happening?
00:48:43leorizedepends on what your `foo` is
00:49:46giacofoo is same thing in both cases, that would be seq[uint8] in my case
00:50:50leorizecan you check if it fits the limitations described in:
00:50:52leorize~mcs
00:50:53disbotmcs: 11method call syntax, or UFCS in popular lingo; see https://nim-lang.org/docs/manual.html#procedures-method-call-syntax -- leorize
00:51:11leorizehttps://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax
00:51:15leorize^ would be that one instead
00:51:43leorize~mcs-limits is limitations of Nim's method call syntax: https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax
00:51:44disbotmcs-limits: 11limitations of Nim's method call syntax: https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax
00:52:59giacothanks. Surprisingly, the code that is not compiling now was compiling yesterday. I've just checked out from git working code and returns same error, so it is something external from my code
00:56:30giacoapparently I'm dealing with this, but I don't understand why compiler now need a disambiguation that was not needed some hours ago
00:57:39*oculux quit (*.net *.split)
00:57:39*bozaloshtsh quit (*.net *.split)
00:57:39*nickster quit (*.net *.split)
00:57:39*bacterio quit (*.net *.split)
01:12:44*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
01:14:57*abm quit (Quit: Leaving)
01:17:20*Lord_Nightmare joined #nim
01:17:54*oculux joined #nim
01:17:54*bozaloshtsh joined #nim
01:17:54*nickster joined #nim
01:17:54*bacterio joined #nim
01:23:30*Tanger joined #nim
01:35:43PrestigeAre these limitations something that's planned to be addressed as a special case? Or do we just not care about these cases
01:37:23FromDiscord<ElegantBeef> I imagine since generics have been addressed they'll be addressed if possible 😄
01:38:34*krux02 quit (Remote host closed the connection)
01:38:40PrestigeI really need a good Nim project to create at work for our next hack day...
01:38:57PrestigeWould be nice to start using Nim at work. It's made me dislike Js lol
01:39:24FromDiscord<ElegantBeef> Clearly write nim and output the js and pretend you write code like that 😛
01:40:12PrestigeI'd need to figure out how to interface with our JS framework and all
01:40:41FromDiscord<ElegantBeef> Nah just `importC` the procs you need and `exportC` the procs you write 😛
01:41:01FromDiscord<ElegantBeef> That's atleast how i half assed my interop for the webrtc api
01:41:24PrestigeI'd be interested in seeing that actually
01:41:42FromDiscord<ElegantBeef> https://github.com/beef331/mrapi/blob/master/src/mrapi.nim
01:42:08PrestigeOh, neat
01:42:11FromDiscord<ElegantBeef> It can be done smarter using promises/async but i couldnt get await to work on Nim's side
01:42:28FromDiscord<ElegantBeef> There's also an example
01:42:57FromDiscord<ElegantBeef> If you want to see what the test does it's here https://www.jasonbeetham.com/elementest/
01:44:01FromDiscord<ElegantBeef> Apparently element doesnt like how i have that setup as when embedded it doesnt allow capturing of audio/video, which i think is due to the httpheaders
01:44:18FromDiscord<ElegantBeef> But eh, it "works"
01:46:19FromDiscord<ElegantBeef> I'd remove those callbacks if i could've got await to work, but it just wouldnt
01:49:04leorizedisruptek: just released setup-nim 0.1.1, should fix your issue
02:15:43FromDiscord<Quibono> This is getting monotonous to say, so I apologize, but we still don't have M1 Mac support and I'm tearing my eyes out lol
02:16:48leorizewe don't have CI for Mac M1
02:17:19FromDiscord<Quibono> Are you someone who knows how long that'll take? It's like, got this smoking new car I can't drive anywhere.
02:17:28leorizebecause currently no providers provide M1...
02:17:48leorizeyou should be able to build nim on m1
02:17:58leorizeclone https://github.com/nim-lang/csources_v1
02:18:12FromDiscord<Quibono> I've tried but I'm willing to follow instructions lol.
02:18:14FromDiscord<Rika> more like getting an experimental car that isnt street legal yet 😛
02:18:47FromDiscord<Quibono> Lol my car has a fan, but I haven't heard it once. Tis scary
02:18:57FromDiscord<Quibono> @leorize Okay clone csources_v1
02:19:04leorizeclone nim-lang/Nim too
02:19:45leorizecopy csources_v1 to Nim then `cd Nim/csources_v1`
02:19:49leorizerun `./build.sh`
02:19:53leorize`cd ..`
02:19:56leorize`bin/nim c koch`
02:20:04leorize`./koch boot -d:release`
02:20:17leorizethen add `bin` to PATH
02:20:22leorizeand you got yourself a compiler
02:20:28leorize`./koch tools`
02:20:38leorizeand you got the tooling ready
02:21:55FromDiscord<Quibono> When you say run ./build.sh, am I doing sh build.sh?
02:22:32leorizeyea
02:23:11FromDiscord<Quibono> sent a code paste, see https://play.nim-lang.org/#ix=2IW5
02:23:53leorizetry this ./build.sh --cpu arm64
02:24:19FromDiscord<Quibono> Same.
02:26:09leorizeplease report that as a bug against csources_v1
02:26:40leorizehttps://github.com/nim-lang/csources_v1/blob/2fbbfb191dffdfe0f62460a6aad93f7a1ccd2f5c/build.sh#L6403-L6406
02:26:45leorizelooks like it's still not supported
02:27:03leorizefunny how we generate sources for ia64 and powerpc but not arm
02:29:35FromDiscord<Quibono> https://github.com/nim-lang/csources_v1/issues/1
02:29:36disbotsh build.sh --cpu arm64 results in linker command failure.
02:29:49leorizeQuibono does rosetta work for normal x86_64 Nim?
02:29:59FromDiscord<Quibono> O
02:30:05FromDiscord<Quibono> I'm not sure how to test it
02:30:21FromDiscord<Quibono> If you instruct me on how I'll happily test lol.
02:30:38leorizehttps://github.com/nim-lang/nightlies/releases/download/2020-12-21-devel-051477b314acae9141eb697ff369385643f1bbbf/nim-1.5.1-macosx_x64.tar.xz
02:30:43leorizedownload and extract that
02:30:50leorizetry running bin/nim in there
02:31:04leorizeif it works then we can use it to help you bootstrap arm Nim
02:34:37FromDiscord<Quibono> So run the unix executable in bin?
02:35:11EvolverHow do I get the first part of a path, e.g. `foo/bar/baz`? This should return `foo`.
02:35:56leorize@Quibono yes
02:36:27FromDiscord<Quibono> Okay it ran, how do I confirm it ran properly lol
02:37:02leorizelet's use it to build you an arm64 compiler :P
02:37:13FromDiscord<Quibono> Lol okay.
02:37:27leorize`bin/nim c --cpu:arm64 --out:bin/nim compiler/nim.nim`
02:38:18FromDiscord<Quibono> Sooooo how do I run it with those arguments instead of it autoexecuting?
02:38:31leorizeyou run it in the terminal
02:38:51FromDiscord<Quibono> So cd into it
02:38:54leorizeyep
02:41:03FromDiscord<Quibono> I'm cd'ed into the bin file and when I try to run "nim c --cpu:arm64 --out:bin/nim compiler/nim.nim" it says "command not found: nim"
02:41:28leorize`cd ..`
02:41:37leorizethen run `bin/nim` instead of `nim`
02:42:17FromDiscord<Quibono> Okay that seems to have executed just fine
02:43:48leorizebin/nim --version
02:43:59leorizewhat do you see
02:44:26FromDiscord<Quibono> Nim Compiler Version 1.5.1 [MacOSX: arm64]
02:44:44leorizecongrats, you now have an arm64 compiler :)
02:44:52leorizecopy bin/nim into <Nim source>/bin
02:45:03leorizethen redo the bootstrapping steps
02:45:26leorizeand you got yourself a Nim installation
02:45:37FromDiscord<Quibono> Sooo, clone nim from github, then copy, then redo these steps?
02:46:12leorizexhttps://irclogs.nim-lang.org/21-12-2020.html#02:19:56 <- do from this one
02:46:17FromDiscord<Quibono> I'm not trying to be obtuse I'm just still pretty new at this.
02:46:49leorizethe path to getting an arm64 compiler is a bit convoluted atm :p
02:47:18FromDiscord<Quibono> So out of actual curiosity, if I could do it in 20 minutes, why isn't it supported? lol
02:47:47leorizeM1 is not supported by any CI platform yet, so we can't test it
02:48:21FromDiscord<Quibono> Why not call it an experimental release lol
02:49:03leorizeI can hook nightlies up to make building a compiler for M1 possible, just open an issue in nim-lang/nightlies, and I'll look into it when I have time
02:49:23leorizekoch needs some fixes to be able to cross-compile a compiler
02:51:06FromDiscord<Quibono> Gotcha, I appreciate the help.
02:52:09FromDiscord<Quibono> So I did the step before koch boot -d:release
02:53:14FromDiscord<Quibono> cd'ed into the source directory, when I do the koch release step it says koch not found
02:54:45leorizehave you did `bin/nim c koch`?
02:54:59FromDiscord<Quibono> Yep
02:55:17FromDiscord<Quibono> If I go out a dir and do nim/koch... I get
02:55:27leorizeyou need `./koch` :P
02:55:33*sagax joined #nim
02:55:39leorizeyou can only omit the `./` when the folder is in your PATH
02:56:10FromDiscord<Quibono> lol
02:56:13FromDiscord<Quibono> Thanks
02:56:20FromDiscord<Quibono> Is newb
02:56:49FromDiscord<Quibono> Compiling is still kind of black magic to me.
02:57:23leorizeso bash will look for `<app executable>` in `PATH`
02:57:39leorizeand by default "the current folder" is never in PATH
02:58:03FromDiscord<Quibono> So you're just saying "hey stupid look here"
02:58:09leorizeyep
03:02:25FromDiscord<Quibono> Okay now to figure out how to edit PATH on big sur
03:03:41FromDiscord<Quibono> Doing nano .bash_profile doesn't seem to be updating it, like I can see that .bash_profile has it and I've updated it, but when I go echo $PATH no joy
03:03:53leorizerestart your terminal
03:03:56leorizeshould have it then
03:04:25leorize.bash_profile, .bashrc are only read on bash startup
03:07:08FromDiscord<Rika> big sur uses zsh now i believe
03:07:17FromDiscord<Quibono> Yeah that was the problem
03:09:17FromDiscord<Quibono> And zsh seems even weirder to update fml
03:11:57FromDiscord<Quibono> Okay needed to do nano .zprofile THEN change it
03:12:04FromDiscord<Quibono> Thank you to everyone
03:13:04leorizeyou're welcome :)
03:14:13disruptekleorize: sweet, i'll try it, thanks.
03:18:57disruptekironic... big sir is my stripper name.
03:19:38*klaufir_ quit (Ping timeout: 268 seconds)
03:19:40disruptekso if you have a working arm build, you can provide the gitnim distro for m1.
03:20:23disruptekleorize: 0.1.1 doesn't help me. 😢
03:21:05leorizelogs please?
03:22:37FromDiscord<Quibono> Rut roh guys when I do nim ... in the terminal it says command not found nim
03:22:54disruptekhttps://github.com/nim-lang/nimble/blob/3e07ffe71052735b6fc1d9ab06c195ce091ccb80/sr
03:22:59disruptekoops.
03:23:05disruptekhttps://github.com/disruptek/skiplists/runs/1586727780?check_suite_focus=true
03:23:08disruptekstupid wayland c+p.
03:23:43disruptekquibono: echo $PATH and see what they've done to you.
03:24:19FromDiscord<Quibono> /usr/local/bin /usr/bin /bin /usr/sbin /sbin $/Users/me/nimproj/Nim/bin
03:24:57FromDiscord<Quibono> Did I copy in the wrong stuff?
03:25:00leorizedisruptek: try `testes.cmd`, if that works file a nimble bug
03:25:00disruptekwell, there's your problem, sport.
03:25:07FromDiscord<Rika> what is that $ doing there
03:25:16disrupteksend me your $.
03:25:21disruptekyou don't need it.
03:25:32disruptekleorize: cool.
03:26:09FromDiscord<Quibono> Aaaand nim works, you're officially all awesome.
03:26:20FromDiscord<Quibono> Some guide had the $ there, removing it fixed it
03:26:44leorizehttps://github.com/disruptek/skiplists/runs/1586727780?check_suite_focus=true#step:3:35 <- this path is correct, so I'd just blame nimble at this point :P
03:27:10*iwq quit (Ping timeout: 265 seconds)
03:27:38disruptekhard to believe there could be a bug in nimble that remains after 10 years, but easy to believe i'd be the one to find it.
03:28:06*aenesidemus quit (Quit: Leaving)
03:31:40leorizeand it is a nimble bug
03:31:43leorizehow fun
03:33:13disruptek.cmd works, though.
03:33:25leorizeyep, I saw it
03:33:56disruptekfindExe should find it, right?
03:34:12disrupteki feel like that'd be a kinda reasonable expectation.
03:34:31leorizeofc it can't :)
03:34:54disruptekso why does nimble create .cmd?
03:35:11leorizepoor man's shim
03:35:27disrupteksometimes i wish people would just not even attempt engineering.
03:35:46disrupteklike, if you aren't equipped to solve the problem completely, please just don't even design in any solution at all.
03:35:52leorizehttps://github.com/alaviss/setup-nim/runs/1586282771?check_suite_focus=true#step:9:189 <- a view into what nimble creates
03:35:53disruptekjust design out the mere hint of a solution.
03:36:12leorizea file w/o extension for "git bash", and a `.cmd` for Windows cmd
03:36:21leorizeno .exe because who uses it, right? :)
03:36:36disruptekthat's madness.
03:37:33leorizenimble used to just build all the things and copy them to `.nimble/bin/`
03:37:41leorizesomething changed so nimble now try to "symlink"
03:37:53leorizebut that stuff doesn't work on windows
03:37:56EvolverIs the use of `options` recommended?
03:37:58disruptekhttps://github.com/alaviss/setup-nim/runs/1586282771?check_suite_focus=true#step:9:29
03:38:03disruptek"building loaf.exe"
03:38:47disruptekwish i could see the XSuccess hint here.
03:39:05disruptekEvolver: yes.
03:39:12disruptekresults is really nice, too.
03:39:15disruptek!repo badresults
03:39:16disbothttps://github.com/disruptek/badresults -- 9badresults: 11like results but worse 15 1⭐ 0🍴
03:55:47EvolverIf I get a redefinition error, is there any way for me to allow it anyway?
03:55:54disruptekno.
03:56:09disruptekwhy would you attempt to define the same thing twice?
03:56:35EvolverFirst time it's `Option[string]`. Second time I want it to be `string` because I already quit if it was none.
03:56:50disrupteklet's see the code.
03:57:14FromDiscord<Moral Craft> These bots are cool ngl.
03:58:21Evolverdisruptek: https://paste.ee/p/BMj4Y (The whole repo is not public yet since it's a WIP.)
03:58:23disruptekdom96: btw, did you get back to me about wrapping <> around the urls in disbot output? i can do it now that i can compile nimterop.
03:58:55disruptekuse a block: to create a new scope or use a new variable name.
03:59:06disruptekshadowing with a type change is code smell.
03:59:10disruptek~disrupstyle
03:59:11disbotdisrupstyle: 11tips for writing code that won't provoke 😠 rants 🤬 on irc: https://gist.github.com/disruptek/6d0cd6774d05adaa894db4deb646fc1d -- disruptek
04:00:57*muffindrake quit (Ping timeout: 268 seconds)
04:01:55FromDiscord<ElegantBeef> Disruptek i'm disappointed, i expected it to say "dont write code"
04:03:09*muffindrake joined #nim
04:04:20giacoI'm playing with object variants and I've successfully created one. But I'm failing to read its fields, would you help me echoing any var? This is its repr -> https://termbin.com/t00o
04:04:33FromDiscord<ElegantBeef> Can we see the code?
04:05:30disruptekelegantbeef: write whatever you want, just don't show it to me.
04:05:44FromDiscord<ElegantBeef> lol
04:05:59FromDiscord<ElegantBeef> I mean i agree with everything you said there
04:06:36giacoyes but gnome just failed and copypaste is no more working, let me restart gui
04:10:00giacoElegantBeef, here -> https://termbin.com/fv7qb . The object I'm trying to read is type OpusTy
04:10:30FromDiscord<ElegantBeef> Minimal examples save lives
04:11:31FromDiscord<ElegantBeef> What's the issue anywho
04:12:55giacoall parsers depends on each other. Problem is reading the contents of OpusTy object after it has been created. I do see that all the Fields contains correct values with repr, but I'm trying different myopuspy.<stuff> and I keep getting no cake
04:15:35FromDiscord<ElegantBeef> You just check the kind of the object then you can access any sub field
04:15:57FromDiscord<ElegantBeef> So if it's of type `okHead` you should be able to access the `head` field
04:18:25giacoElegantBeef, but how? obj.kind -> Error: undeclared field: 'kind' for type parsers.OpusTy
04:19:58FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=2IWB
04:20:14FromDiscord<ElegantBeef> Are you calling this from another module?
04:20:21FromDiscord<ElegantBeef> If so add the `` on the fields
04:20:51FromDiscord<ElegantBeef> so it turns into `head: T`
04:23:06Evolverdisruptek: OK. I put it in a `block`: https://paste.ee/p/bhgHv
04:23:38disruptekno, the last let statement and wherever you wish to use such a shadow.
04:24:11disruptekbut sure.
04:24:16disrupteki guess this works.
04:24:17EvolverI don't follow.
04:24:23EvolverIt works but what am I missing
04:25:09disruptekvar repo: Option[string] ... repo = some("string") ... block: let repo = get repo ...
04:25:23giacoElegantBeef, thanks, but I didn't get it. Do you know the docs page that talks about this `` thing?
04:25:28disrupteki /think/ you can get away with that last let statement reusing the symbol, but i'm not 100%.
04:25:45FromDiscord<ElegantBeef> ah sorry
04:25:47disrupteklike i said, it's code smell because the type changed.
04:25:47FromDiscord<ElegantBeef> it's an asterix
04:25:51FromDiscord<ElegantBeef> It's called a export marker
04:25:52Evolverdisruptek: I will refactor it. Thanks.
04:26:02FromDiscord<ElegantBeef> https://nim-lang.org/docs/manual.html#procedures-export-marker
04:26:03disruptekjust a style nit. if it works, it works.
04:30:32*fputs joined #nim
04:31:40giacoElegantBeef, I've added the "*" and now I can do myobj.head/tags/data, thanks! But how can I know the kind of it before accessing data? Object variants have different fields
04:31:54FromDiscord<ElegantBeef> expose the `kind` aswell
04:32:12FromDiscord<ElegantBeef> It can be applied to any field you want exposed
04:32:26giacothanks!
04:33:13giacobtw the phrase that made me ask about the documentation was "If so add the `` on the fields so it turns into `head: T`"
04:35:46FromDiscord<ElegantBeef> Yea i know
04:35:49FromDiscord<ElegantBeef> I checked the logs
04:36:31FromDiscord<ElegantBeef> For some reason inside backticks it gets turned into a >= sign in the irc bridge
04:36:59giacointeresting :D
04:37:19giacoproblem solved anyway. Object variants acquired!
04:52:02*spiderstew joined #nim
04:55:22*spiderstew_ quit (Ping timeout: 260 seconds)
04:55:22giacoin 150 lines of nim I've achieved what I did in 500 lines of golang
04:55:36FromDiscord<Rika> congrats
04:55:58FromDiscord<Rika> oversimplicity results into complexity which is funny
04:55:59giacoI know it is not a measure, but it is really nicer to read and write
04:56:02*narimiran joined #nim
04:56:45FromDiscord<ElegantBeef> That was inferred by you saying golang 😛
04:57:24giacohaha
05:00:40disrupteknicer to read and write /is/ a measure, as is less code.
05:07:53FromDiscord<ElegantBeef> It's now that i want to use my colourful output branch that i realize choosenim is lacking
05:12:33disruptekleorize: here's a weird one: https://github.com/disruptek/jason/runs/1587029260?check_suite_focus=true#step:4:39
05:13:35disruptekthe test failed, the exec should have raised (in nimble's nimscript) on osx but it didn't.
05:14:09disrupteklooks like the hash is back in the compiler's --version, so that's good.
05:16:26*a_chou joined #nim
05:21:22giacois it possible to write a seq[uint8] to a stream without copying it into a fixed size buffer first? if I do writeData(addr(myseq), len(myseq)) I obviously write wrong data
05:21:40disruptektake the addr of the first element.
05:22:00giacoare seq really sequential in memory?
05:22:06FromDiscord<ElegantBeef> Yes
05:22:06disruptekwhat else?
05:22:14giacothanks!
05:25:07*fputs quit (Ping timeout: 260 seconds)
05:33:04FromDiscord<ElegantBeef> We should play tricks on people and have sequences just fuck cache locality
05:33:55disruptekjust scribble all over their memory outside of release mode to make release look more heavily optimized.
05:42:07*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
05:42:14*njoseph joined #nim
05:43:18*a_chou quit (Remote host closed the connection)
05:50:17*waleee-cl quit (Quit: Connection closed for inactivity)
05:52:00FromGitter<gogolxdong> Is there a way to qualify strformat.& when conflicting with `&` symbol from another module?
05:54:34FromDiscord<Rika> exactly how you just wrote it but with backticks around &
05:57:46FromGitter<gogolxdong> ah,ok , thanks!
06:02:02disruptek~&
06:02:02disbot&: 11unreachable
06:04:20*ex_nihilo joined #nim
06:09:47giacohow to listen to udp port? Before diving into async I want to play with an old school simple udp server. I'm creating a socket with newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) and listening with socket.recvFrom(data=data, length=100, address=address, port=port) but address and port are var arguments so I expect them to be the connected client address and port. How can I wait for data on local port
06:09:49giaco5555?
06:10:34FromGitter<jrfondren> https://forum.nim-lang.org/t/7143
06:14:19giacobindAddr was the answer! Thanks
06:18:07*vicfred quit (Quit: Leaving)
06:20:44giacoI need to split incoming udp data using udp packet sizes. Is there a way to handle raw udp sockets or just get data splitted according to udp payload size of each packet?
06:22:00FromGitter<jrfondren> if you can do it in C you can do it in Nim, but I don't know UDP well enough to point you in the right direction.
06:22:26disruptek!repos udp
06:22:27disbothttps://github.com/treeform/netty -- 9netty: 11Netty - reliable UDP connection library for games in Nim. 15 55⭐ 4🍴
06:22:27disbothttps://github.com/fowlmouth/nimrod-enet -- 9nimrod-enet: 11ENet reliable UDP networking library - wrapper for Nimrod 15 12⭐ 2🍴
06:22:27disbothttps://github.com/tulayang/httpkit -- 9httpkit: 11An efficient HTTP tool suite written in pure nim. Help you to write HTTP services or clients via TCP, UDP, or even Unix Domain socket, etc. 15 15⭐ 2🍴 7& 6 more...
06:23:09disruptekyou can get 9 results, total, if you speak to disbot directly.
06:23:24disruptekdisbot: are you in the mood to be helpful?
06:23:25disbotwithout a doubt.
06:23:31disruptekaight, there you go.
06:23:41giaco:D
06:24:05giacodisbot: udp raw socket
06:24:06disbot😕
06:24:33disruptekyou have to /msg it, chucklehead.
06:24:34giacowait, I got it
06:24:50giacohaha /me dumb
06:25:05disruptekat least you're on irc.
06:25:20Zevvlike, if you don't know what a TCP FIN is, keep your hands off the internet
06:25:21disruptekit's impossible for people on discord because yardanico hates them.
06:25:28FromDiscord<Rika> lol
06:25:44Zevvoh that came out wrong
06:25:48FromDiscord<Rika> this time it isnt even because of you disliking discord its just a limitation of the bridge bot haha
06:26:21FromDiscord<Rika> zevv i assume you mean "keep your hands off of manipulating packets"
06:26:21disruptekit's due to a limitation of a human.
06:26:41FromDiscord<Rika> many things can be boiled down to that haha
06:27:12Zevvno, I mean that in the broadest sense possible
06:27:31Zevvthat would make the world a better place, trust me
06:27:47Zevvgo read a book
06:28:20Zevvbut, nooo, lets make our worlds revolve around facebook and twitter
06:29:01FromDiscord<Rika> man if everyone needed to know as specialized of a topic as tcp packet types then no one would have much time for anything else
06:29:15Zevvright, and how is that bad
06:29:22disruptektrue, we did nothing else in those days.
06:29:40disruptekit was only when pornhub came along that i forgot about tcp.
06:29:49Zevvwe just read dickens and got drunk, remember
06:30:15Zevvthe halcyon days
06:30:41disruptekremember ice-cold server rooms?
06:31:00FromDiscord<mratsim> cheap threads are not where it's at, cheap tasks are
06:31:13Zevvdude, I totally forgot of those. and that smell and dry air
06:31:37disruptekremember vt100 terminal cables?
06:32:02Zevvrs-232 consoles is in my daily work
06:32:08disruptekoh, that's right.
06:32:12ZevvI drop my DTR to log out
06:32:22disruptekokay, how about tape backup?
06:32:40ZevvI saved my tapes and 1 DD drive
06:32:54ZevvI recovered a 90's email a few weeks back
06:33:16Zevvit has SCSI with, like, 60 pins on the flatcable
06:33:26disruptekhow about that certain phone that you always kept around because it was perfect for plugging into a modem or whatever ad hoc.
06:33:35*fputs joined #nim
06:33:42disrupteklike, it had a hook button on the handset or whatever.
06:33:56FromDiscord<Rika> zevv if i told you you had to learn everything about being a doctor (and only that) would you think it was smart or practical
06:34:06disrupteki had a 100mb scsi drive that weighed like 15lbs.
06:34:25*fputs quit (Client Quit)
06:34:59disruptekadaptec came out with the UW-SCSI and it was like 68 pins and blew our fucking minds because it was so much smaller (read: sexier).
06:35:20disruptekremember IDE master/slave jumpers?
06:35:29FromDiscord<mratsim> remember Zip drives?
06:35:35disruptekjazz?
06:35:40FromDiscord<mratsim> Jaz
06:35:50disruptekthe iomega boom, that was crazy.
06:35:55disrupteks/boom/bubble/
06:36:31disruptekremember zmodem?
06:36:57disruptekremember pc games that came on 37 floppies?
06:37:17disruptekremember people calling the 3.5" floppy "hard disk" because... it was harder than the 5.25" floppies?
06:37:43miprino. What PC game came on 37 floppies?
06:37:44disruptekremember when you had a floppy with all your games on it?
06:37:47FromDiscord<mratsim> 37 floppies was a recipe for a "CRC32 checksum failed" error
06:38:00disruptekReturn to Zork was a big one.
06:38:00FromDiscord<mratsim> I remember games on 5 CDs though
06:38:20Zevvrika: well, people who dont know about doctoring, typically keep their hands from other people, right?
06:38:27FromDiscord<mratsim> remember Encarta?
06:39:03ZevvNo, i never ran windows
06:39:09FromDiscord<mratsim> @Zevv, if the coronavirus epidemic proved anything, it's that people who have no business with it started to claim being competent
06:39:20*mipri left #nim (#nim)
06:39:25disruptekremember the early dictionaries where you could listen to the pronunciation of words like, `cocksucker` and `motherfucker` for hours on end?
06:39:51FromDiscord<mratsim> I didn't speak or write english at the time
06:40:10disruptekremember the pc speaker music from star control?
06:40:18disruptekthat was a mindfuck at the time.
06:41:44disruptekremember BBSes?
06:41:50disruptekc'mon, man.
06:42:02disruptekremember bbs "doors"?
06:42:55FromDiscord<mratsim> I didn't imagine finding clear information on coroutines and continuations on a Javascript/React blog but apparently JS folks are being forcee-fed continuations https://www.yld.io/blog/continuations-coroutines-fibers-effects/
06:43:32*fanta1 joined #nim
06:43:52giacoI don't understand if net high-level interface is capable or not in preserving udp packet boundaries
06:45:54disruptekremember aperture grill CRTs?
06:46:55disruptekhow about the first time you saw VGA gradients?
06:47:18FromDiscord<mratsim> I have a neural network book from the 80s that mention graphic.h
06:47:50FromDiscord<mratsim> graphics.h
06:48:24disrupteklol
06:49:13disrupteki was thinking today about writing a MUD.
06:50:21*Zevv quit (Quit: Lost terminal)
06:50:43*Zevv joined #nim
06:51:12Zevvits interesting to see how some languages have had coroutines for decades, and no one cared. and now it seems the latest hype, everybody wants to do it
06:51:25Zevvwhy now? what changed, and why not 10 years ago
06:51:40Zevvthis is 70's stuff
06:51:49disruptekeven the cpc paper is 15 years old.
06:51:52Zevvremember continuations?
06:52:02Zevvthat smell?
06:52:13giacobecause lazy is hipster, and hipster is good
06:52:27Zevvdisruptek: ikr
06:56:36disrupteki dunno, i couldn't sleep for two days after araq dropped that paper.
06:57:51FromDiscord<Rika> zevv: they generally keep away from doctoring complicated diseases but no they still talk and touch people
07:01:38Zevvyeah, it's not that bad of course. It's not like people wihout president skills become president or anything.
07:02:11disruptekand presidents without medical skills never dispense medical advice.
07:03:02Zevvanyway, let's don't go there. There's kids around here
07:03:05FromDiscord<Rika> the analogy is incorrect then
07:03:24FromDiscord<Rika> why? well you changed the range
07:04:28Zevvmy excuse is that I just got out of bed
07:08:34FromDiscord<mratsim> @Zevv, neural networks were from the 80s as well
07:08:47Zevvthere you have it. "neural networks"
07:09:15FromDiscord<mratsim> My father gave me 3 books for implementing them from that time.
07:09:20FromDiscord<mratsim> they came with floppy disks
07:09:35FromDiscord<mratsim> and used graphics.h
07:09:40ZevvI did that as well, but I only had one book :(
07:09:44Zevvsee where that brought me.
07:09:51Zevvmy father was cruel
07:10:14FromDiscord<mratsim> well he gave that to me after I did Arraymancer ....
07:10:17FromDiscord<mratsim> so it was too late :p
07:10:23Zevvhehe :)
07:13:04Zevvand look at this stuff https://www.youtube.com/watch?v=-J_xL4IGhJA. 1985. It's all *so* totally relevant. That course was a hell of an eye opener for me, but decades too late
07:13:35FromDiscord<InventorMatt> I think the perceptron was first created in the 50s but gradient descent was the 80s which advanced it significantly
07:14:12disrupteki feel like if he's not able to talk /and/ write on the board, he should write on the board before class.
07:14:25disrupteki'm not fucking paying you to write COMPUTER SCIENCE goddamnit.
07:14:42Zevvoh you payed
07:15:00Zevvdon't start that course, it's like 40 episodes like that
07:15:04disrupteki'm paying by having to look at this balding fuck in those pants.
07:15:04Zevvbut man is it great stuff
07:15:04FromDiscord<mratsim> @InventorMatt People even did a physical perceptron iirc
07:16:00FromDiscord<mratsim> After pushing everyone to use CPS you dare judge a book by its cover?
07:16:02FromDiscord<mratsim> come on
07:16:20Zevvwho is pushing who?
07:16:37Zevv(where's that fingerpointing meme thing)
07:17:17FromDiscord<mratsim> Python mail from 1999 explaining coroutines, continuations and generators https://mail.python.org/pipermail/python-dev/1999-July/000467.html
07:18:06Zevv"I've often suspected theorists were *surprised* (and maybe appalled when the language folks went on to *implement* the continuation idea.
07:18:09ZevvDon't really know, but suppose it doesn't matter anyway. The fact is we're
07:18:12Zevvstuck with them now <wink>."
07:20:35FromDiscord<mratsim> on the "surprises" there is also this paper. http://parametricity.net/dropbox/yield.subc.pdf↵Basically it tells that language dev couldn't care less about continuations, and language theorist about implementation "details". But as it happens "yield" is equivalent to a continuation and so we could reconcile the two.
07:21:34FromDiscord<mratsim> And this revisits how continuations were discovered in 1960 in various settings but no one cared: https://www.cs.tufts.edu/~nr/cs257/archive/john-reynolds/histcont.pdf
07:21:50disruptekhey, my old uni.
07:22:56disrupteki don't know that prof though.
07:23:30ZevvA van Wijngaarden. he dutch
07:24:21disruptekyou guys are making me sleepy.
07:24:49disrupteki think maybe mamy is gonna need another couple weeks to steep.
07:24:54disruptekat this rate, anyway.
07:25:18Zevvsteep? sleep? steepy?
07:25:50disruptekhe needs to let it roll around his head a bit.
07:25:56disrupteksteep like tea.
07:27:17disruptekprobably he will rewrite the whole thing in synthesis.
07:28:20FromDiscord<mratsim> you joke but I was thinking about that yesterday :p
07:28:37disrupteknah, i'm not joking. 😉
07:38:16disrupteki think ray told me that rust uses a state machine design.
07:38:56disruptekbut although it'd be faster and ... tighter, it's not as versatile.
07:39:24disruptekit's the better way to impl the static approach w/o fn, but it gives up too much power.
07:39:52disruptekwhen you are ready to do it in synthesis, look at my chain demo first.
07:40:41disrupteki think it makes a compelling argument. and it gives up less, at moderate cost. we don't lose any static analysis.
07:40:57disruptekhttps://github.com/disruptek/cps/blob/master/experiments/chain.nim
07:41:15FromDiscord<mratsim> Ray?
07:41:28disruptekrayman222O1
07:41:55FromDiscord<mratsim> Rust iterators are compiled to a state machine for sure. For Rust async/await I think the state machine is implicit.
07:42:42disruptekyeah, but it's kinda one-dimensional.
07:43:14disrupteki can be taught, though. maybe you will convince me. 😀
07:43:19FromDiscord<mratsim> if we want the max efficiency, we drop down to ASM and directly save/restore stack from there like here: https://web.archive.org/web/20100106212446/http://homepage.mac.com/sigfpe/Computing/continuations.html
07:43:39disrupteki think it's a waste.
07:45:33FromDiscord<mratsim> it happens to be what the multithreading framework with the lowest overhead I encountered did: https://github.com/chaoran/fibril/blob/master/src/fibrili.c#L18-L27↵↵Resuming is just 2 mov and a goto in assembly.
07:46:15disruptekyeah, iirc zachary carter fucked around with that one, too.
07:46:33disruptekbut "i don't care." 😁
07:46:35FromDiscord<mratsim> I wanted to implement it in Nim but didn't find the time.
07:46:55FromDiscord<mratsim> That was my plan for Weave IO before looking into CPS
07:47:10disruptekmore important to have something that is trivially portable, i think.
07:47:12FromDiscord<mratsim> only thing I'm wary of with it is stuff around floating point registers
07:47:19disrupteki trust the compiler to take care of us.
07:47:28FromDiscord<mratsim> yes, that's why I didn't implement Weave using that
07:47:33disrupteks/compiler/c compiler/ 🤣
07:47:47FromDiscord<mratsim> but stackless Python for example as assembly for all arch
07:48:04disruptektrue, but cps runs on web-browsers right now.
07:49:13disruptekanyway, we can always reimpl a lower level in asm later.
07:49:17FromDiscord<mratsim> well there was 2 reasons why I didn't implement Weave using that:↵1. is I didn't want to have assembly for all platforms, though the ASM is just mov, mov, goto so that's not really difficult.↵2. I wanted to have the same code for local machine and distributed computing. And distributed computing obviously cannot use assembly but has to use message queues/channels
07:49:22disruptekthe important thing is to nail the ergonomics.
07:49:26disruptekthat's what nim's all about.
07:49:40FromDiscord<mratsim> Yes that's what I'm thinking about
07:49:48disruptekright.
07:49:52FromDiscord<mratsim> so in terms of ergonomics
07:50:05FromDiscord<mratsim> we need to specify a threadpool interface for cps link
07:50:14FromDiscord<mratsim> should be easy enough
07:50:28disruptekdispatcher problem, but yes.
07:50:32FromDiscord<mratsim> "level 1" would be the 5 primitives on the paper
07:50:47FromDiscord<mratsim> apparently cpc_spawn can be build on top of those primitives?
07:50:57disrupteki mean, forget the paper.
07:51:09FromDiscord<mratsim> I'd do level 1.5 = cpc_spawn, Lua coroutines, ...
07:51:48FromDiscord<mratsim> level 2 = reimplementing closure iterators, async/await, and D-ranges/C++ ranges
07:51:51FromDiscord<mratsim> and streams
07:52:22FromDiscord<mratsim> and maybe npeg with runtime grammar 😉
07:52:28FromDiscord<mratsim> or a protobuf compiler at runtime
07:52:40disruptekwell, you're welcome to label stuff. but we still need to figure out roughly how we get from A to B to level 17.
07:52:49*Cthalupa quit (Ping timeout: 268 seconds)
07:53:32disruptekone idea i had was to use the effects system to auto-cps-ify i/o by tainting symbols of painted types.
07:54:13disruptekuser pragma expr would let us invoke the same proc in a cps context or outside.
07:54:22FromDiscord<mratsim> I need applications/examples that are motivating, sufficiently hard or a pain point for some of the community (like iterator chaining and D ranges or streams) to showcase that and design a path from there.
07:54:38*Cthalupa joined #nim
07:54:41disrupteki'm in favor of user stories, yes.
07:55:57disruptekyou should be able to come up with some thorny async problems from status.
07:57:33*PMunch joined #nim
07:58:22disruptekfrosty wants to use cps to serialize unbounded memory graphs.
07:58:46disruptekgram wants cps to do queries of the graph via multiple cores.
07:58:59disruptek(hence skiplists)
07:59:35disruptektestes wants to clone testes and do criterion runs with them "in the background."
07:59:35FromDiscord<mratsim> Async problems in Status are: tracking unattended futures, cancellation, thousands to millions of timers, low memory overhead
07:59:56disruptekwhy is millions of timers a problem?
08:00:11FromDiscord<mratsim> Graph queries are CPU bound, use Weave.
08:00:38FromDiscord<mratsim> not sure why but at one point we had a lot and they were leaking.
08:00:41disruptekyes, but i want to wrap them in cps in any event.
08:00:48FromDiscord<mratsim> and it was a pain to track those leaks
08:00:54FromDiscord<mratsim> also debuggability.
08:01:11FromDiscord<mratsim> basically a compelling story is maintenance+debuggability
08:01:22disrupteki cannot fathom why that would be an issue, but maybe someone can write it up for us.
08:01:31FromDiscord<mratsim> that's our main woes with current event loop + closure iterators
08:01:40disruptekshould be a trivial application for millions of continuations -- timers or anything else, honestly.
08:03:31disruptekthe maintenance story means less code, and simpler code.
08:04:14FromDiscord<mratsim> sent a long message, see http://ix.io/2IXm
08:04:21disruptekdebugging is something that zevv hates, but it's a fact that people want tracing and exceptions.
08:05:04FromDiscord<mratsim> Basically, debugging experience makes or break building complex applications
08:05:15disruptekyou can mess with cpsTrace but i dunno the state of cpsExceptions. it doesn't need to be impl outside of the dispatcher, but i think i did experiment with stashing the exception in the env.
08:05:24FromDiscord<mratsim> and P2P applications are a pain to debug given that it's very hard to test and reproduce some bugs.
08:05:44FromDiscord<mratsim> we are using Result instead of Exception as much as possible
08:05:47disruptekwell, play with it. i'm pretty happy with it and it was trivial to impl.
08:06:33disruptekif you're doing timers with ioselectors then you've already lost.
08:06:50FromDiscord<mratsim> anyway, I have some ideas to add threadsafe priorities and timers to an IO scheduler
08:06:50disrupteki would just have a priority queue but what do i know?
08:07:20FromDiscord<mratsim> chronos uses a heap
08:07:40disrupteki will look at these tickets after i take a nap. 🙂
08:08:01disruptekbut, y'know, we're still waiting for clyybber to bring the juice.
08:08:09disruptekneed some of these bugs locked down.
08:11:15FromDiscord<mratsim> synthesis doesn't work in the browser I think, it uses undocumented `var a {.goto.} = Label`
08:11:34FromDiscord<mratsim> though if JS has a goto it should be possible to implement it.
08:13:09disruptekshouldn't be a problem, but i don't think you'll want to go that route in any event.
08:13:32disruptekLabel is a nskLabel in macro-speak, right?
08:26:02*klaufir_ joined #nim
08:32:51FromDiscord<mratsim> it's an enum
08:33:24FromDiscord<mratsim> You define a list of state as an enum and when you assign a new value Nim translate that into a goto
08:44:48FromDiscord<mratsim> As it so happens, here is an article explaining how to copile CPS and Kotlin coroutines to state machines https://labs.pedrofelix.org/guides/kotlin/coroutines/coroutines-and-state-machines
08:46:25FromDiscord<mratsim> and Nim goto pragma example: https://forum.nim-lang.org/t/1320#8332
08:47:52ZevvI hate nothing about that
08:48:04Zevvgood traces are the reason why people don't need debuggers in 99% of the cases
08:56:56*xace quit (Ping timeout: 240 seconds)
08:59:06*lritter joined #nim
08:59:14*Tanger quit (Remote host closed the connection)
09:05:05*xace joined #nim
09:11:31FromDiscord<dom96> @disruptek, @leorize don’t blame Nimble for Windows’ limitations 🙂
09:12:03*hnOsmium0001 quit (Quit: Connection closed for inactivity)
09:13:21FromDiscord<dom96> I don’t even think we can create a shim with an exe extension
09:34:13*habamax joined #nim
09:40:58leorize[m]dom96 you already made some for choosenim
09:41:25FromDiscord<Rika> chocolatey uses exe shims
09:41:41leorize[m]scoop uses exe shims too if that matters
09:42:11FromDiscord<Rika> yeah and they do it better because chocolatey shims dont have the proper icon lmaooooo
09:44:59FromDiscord<dom96> Yeah. And people hate that too
09:45:31leorize[m]well your issue rn is that the software doesn't work as expected
09:49:12FromDiscord<dom96> Yep. It’s definitely a bug.
09:56:26PMunchSorry for being a bit short in my description of the coroutines stuff I have been doing in Nim yesterday. I was busy with AoC :P Why did you guys wonder about that anyways?
09:58:05FromDiscord<mratsim> whether closure iterators, CPS, coroutines/fibers are functionally equivlent and can each be implemented from each other
09:58:15FromDiscord<mratsim> or I assume that's @dom96 inquiry
10:05:02PMunchAah
10:05:19PMunchI mean I was using closure iterators in order to implement my coroutines
10:05:23PMunchWhich worked pretty well
10:06:35Zevvok dom96, it seems Ar4q is clear on this, right?
10:06:48Zevvsee his last comment on the CPS RFC just now
10:13:18*hoijui joined #nim
10:16:21*hoijui quit (Client Quit)
10:18:35*liblq-dev joined #nim
10:20:59*mipri joined #nim
10:27:38*Vladar joined #nim
10:36:28*liblq-dev quit (Quit: WeeChat 3.0)
10:36:44*liblq-dev joined #nim
11:01:15FromDiscord<sealmove> what's the difference between `tuple or object` and `tuple|object`?
11:01:29FromDiscord<mratsim> 4 characters
11:02:48FromDiscord<Rika> nothing in practicality i believe
11:04:29FromDiscord<mratsim> I'm starting to get an inkling of how to unify iterators, closure iterators and allow chaining using coroutines that would compile down to state machines and people can choose to make them stack or heap.↵And they could be used across threads (so I guess that makes them fibers).
11:04:47FromDiscord<mratsim> Now I'm wondering if I could make continuation the basic building block of that
11:10:53PMunchWait, how are you going to unify those?
11:15:41FromDiscord<mratsim> assume a new keyword equivalent to proc/func/template like "coro" or "fiber" or just a user pragma {.coro.} or {.fiber.} for starter.↵↵you have "coro foo(x, y: int): int = while true: yield x + y"
11:16:18FromDiscord<dom96> > ok dom96, it seems Ar4q is clear on this, right?↵yep, I think that clarifies many things.
11:16:30FromDiscord<mratsim> a code transformation transforms that to proc foo(x, y: int, env = TypedEnv()): int
11:16:38FromDiscord<dom96> I think mratsim's question is a good one as well in that RFC
11:17:15FromDiscord<mratsim> the body inside is transformed into a state machine, it loads the env at the start which includes the last state used
11:17:29PMunchSo syntax similar to what I made here: https://github.com/PMunch/fibers/blob/master/example.nim#L5
11:17:52FromDiscord<mratsim> to get inline iterators efficiency: you can auto tag it inline if it never escapes it's scope
11:18:20FromDiscord<mratsim> and the env is carried in a regular object
11:18:27FromDiscord<mratsim> that can only be moved or mutated.
11:18:50FromDiscord<mratsim> and this can be send to a scheduler or across thread
11:18:53PMunchWouldn't that still add a bit of overhead to normal iterators?
11:19:33FromDiscord<mratsim> I think withan inline function call that should be OK but that can be easily measured
11:19:42FromDiscord<mratsim> and you can do composition.
11:20:23FromDiscord<mratsim> lifting the environment canbe done either using the compiler logic or what zevv and disruptek developed in CPS
11:21:32FromDiscord<mratsim> Then I have to check if we can make the state machine just be a continuation and build coroutines on top or if it's too much.
11:21:41FromDiscord<mratsim> see Kotlin coroutines that use CPS transform: https://labs.pedrofelix.org/guides/kotlin/coroutines/coroutines-and-state-machines
11:22:36FromDiscord<mratsim> also CPS is an alternative intermediate representation to SSA in compilers
11:23:07FromDiscord<mratsim> so if somehow Nim ends up having CPS as an IR (instead of some form of SSA) we can as well mutualize the effort.
11:31:34FromDiscord<mratsim> This also gives us lazy evaluation that is dear to haskell
11:31:54FromDiscord<mratsim> and zero cost functional programming without intermediate buffer or allocation
11:51:06FromDiscord<krisppurg> sent a code paste, see https://paste.rs/3bO
11:51:41FromDiscord<Rika> the {} is needed to make it term rewriting
11:51:54FromDiscord<mratsim> the {} will make the compiler automatically look for the expression enclose and replace them with the body of toOption
11:51:58FromDiscord<Rika> and it only works with the function you specify
11:52:14FromDiscord<mratsim> so it avoids having to explicitly do toOption
11:52:15FromDiscord<krisppurg> I have no clue what to specify
11:52:22FromDiscord<mratsim> but it's more granular than converter
11:52:34FromDiscord<mratsim> well why did you want to make a toOption converter?
11:52:41*zahary quit (Quit: Connection closed for inactivity)
11:55:04Zevvmratsim: the promises keep heaping up. zero proper fp and lazyness, yay
11:55:11FromDiscord<krisppurg> @hobbledehoy had made PR with that code, which does its job (you can optionally put `some`), but then I misunderstood what it does and rejected it (mistake), then I decided to bring it back.
11:55:35FromDiscord<krisppurg> (sorry for the ping hooble)
11:55:40FromDiscord<krisppurg> (edit) "hooble)" => "hobble)"
11:55:48FromDiscord<mratsim> @zevv, here are 2 lunchtime articles for you: https://jorgecastillo.dev/digging-into-kotlin-continuations, https://proandroiddev.com/how-do-coroutines-work-under-the-hood-803e6e9da8bb
11:55:52FromDiscord<hobbledehoy> all good
11:56:48Zevvmratsim: i got time to read one, which one do i pick
11:57:07FromDiscord<mratsim> the first
11:59:25Zevvso they save the stack frame on a yield
11:59:27Zevvwith a copy
11:59:57Zevvand do the transformation similar to waht disruptek does
12:02:39PMunchHow do closure iterators in Nim do this right now by the way?
12:03:47FromDiscord<haxscramper> Have you looked at https://github.com/nim-lang/Nim/pull/11992 ? It is not related to async in any way if I understand it correctly, but also should enable lazy evaluation
12:03:49disbotevery symbol becomes 1st class; defines 0-cost lambda and aliases; inline iterators/templates/etc can be passed to any routine ; snippet at 12https://play.nim-lang.org/#ix=250A
12:05:06FromDiscord<mratsim> I yes, forgot about this one
12:07:30FromDiscord<mratsim> it doesn't do lazy evaluation alone but it does give you inline iterator fusion and chaining
12:07:51FromDiscord<mratsim> mmmh actually it does give you alzy evaluation.
12:08:05FromDiscord<mratsim> so I guess it's better for compile-time
12:12:15FromDiscord<mratsim> And you need to reify this for coroutines/fibers.
12:15:32Zevvmratsim: do you have any insights on lifting vs copying the stack frame?
12:15:59Zevvyou pay for the copy, but code accessing stack data will typically run faster then code working with lifted data
12:16:22Zevvso its context switch overhead vs locals access overhead, is that right?
12:16:28FromDiscord<mratsim> In Weave I just copy, but I require the dev to tell me what to copy.
12:16:58Zevvright, I guess lifting is friendlier for the user
12:17:14FromDiscord<mratsim> and I use a hack that {.nimcall, gcsafe.} tagged functions check for invalid capture and missing local variable
12:17:53Zevvyou probably also need some specific platform or os support to manipulate the stack in the first place
12:18:18FromDiscord<mratsim> either you use setjmp longjmp
12:18:31FromDiscord<mratsim> or you need assembly to store the stack pointer and base pointer
12:18:39FromDiscord<mratsim> but that's all
12:18:43Zevvalso with setjmp longjmp you need to bootstrap a new stack
12:19:23FromDiscord<mratsim> see here: https://github.com/chaoran/fibril/blob/master/src/fibrili.c#L22-L24↵↵mov rsp, mov rbp, jmp
12:19:56Zevvright, been there
12:19:59PMunchAah, all this brings back memories from uni where we were implementing a task scheduling OS in C/assembly
12:20:18Zevvgood they still teach that to the kids these days
12:20:27Zevvyou need to go there at least once imho
12:20:46PMunchUnfortunately the class has been phased out in other universities that had it
12:21:02Zevvid love if this would all work with safe nim only, tho
12:21:13Zevvno platform or arch specific code, no need for setjmp
12:21:15PMunchMy university still has it as a requirement, and I think the same course is optional at Princeton
12:23:03FromDiscord<dom96> @mratsim does chronos implement what I added to asyncdispatch: instrumentation for the futures that are alive and pending?
12:23:13FromDiscord<dom96> That really helps with tracking down leaks
12:23:33FromDiscord<dom96> Why is cancellation a problem? Wasn't this solved in Chronos?
12:24:26FromDiscord<mratsim> sent a long message, see https://paste.rs/zpq
12:24:29FromDiscord<dom96> I would think timer limitations would be tied to memory, so I see the last two problems as the same thing. I'm curious what the limits were for Status in terms of memory?
12:24:35PMunchHmm, this is acting up on recent versions of Nim: https://github.com/PMunch/getmac/blob/master/src/getmac.nim#L74
12:24:49FromDiscord<mratsim> with argsTy being a tuple representation of all the parameters
12:24:53PMunchSays that "expression expected, but found 'keyword else'"
12:25:01PMunchDid something change with `when` statements?
12:25:12FromDiscord<mratsim> because tuples can be named, they are really nace for packing unpacking
12:25:37FromDiscord<dom96> PMunch: sounds like a regression, report it
12:26:31FromDiscord<mratsim> @dom96 We have a lot of logging, tracking and metrics in chronos now
12:26:57FromDiscord<mratsim> https://github.com/status-im/nim-chronos/search?q=chronosFutureTracking
12:27:04PMunchI mean the simple case seems to work fine
12:27:04FromDiscord<dom96> So these problems are already resolved?
12:27:37FromDiscord<mratsim> cancellation is a problem because it's manual
12:27:44FromDiscord<mratsim> there is no "async garbage collection"
12:28:03FromDiscord<mratsim> so you need to not forget that a cancellable future needs to be manually garbage collected
12:28:12PMunchHmm, seems like it's using the result as a block that's the issue
12:29:11FromDiscord<dom96> So please be clear about what the problems are right now, presumably finding leaks is no longer a problem at least because the metrics are there
12:29:21PMunchhttps://play.nim-lang.org/#ix=2J01 <- works on 1.2.8, not on 1.4.x
12:29:54FromDiscord<dom96> I'm not sure how you wish futures to be cancelled automatically to be honest
12:30:22PMunchHuh, but this is the other way round: https://play.nim-lang.org/#ix=2J02
12:30:33FromDiscord<mratsim> you have an interface/trait "onCancellation" that will be called.
12:30:43FromDiscord<mratsim> and you put your garbage handling here
12:30:52FromDiscord<mratsim> just like we have `=destroy`
12:31:13FromDiscord<dom96> But that's what should happen when a cancellation occurs
12:31:28FromDiscord<mratsim> I am clear about the problems. Zevv was asking about what caused issues in async.
12:32:03FromDiscord<mratsim> i;e. the most important things for us is debuggability and maintenance
12:32:10*liblq-dev quit (Quit: WeeChat 3.0)
12:32:24FromDiscord<mratsim> and any solutions that would replace that needs to provide this.
12:33:28FromDiscord<dom96> it looks disruptek asked the question: https://irclogs.nim-lang.org/21-12-2020.html#07:55:57
12:33:36*liblq-dev joined #nim
12:34:14FromDiscord<dom96> I think it's important to talk about what the problems are right now, not what you experienced in the past. At least when mentioning issues in the past mentioning that they have been resolved would help a lot
12:35:08FromDiscord<mratsim> this is resolved in chronos, I don't know the state in asyncdispatch
12:35:30FromDiscord<mratsim> also if the futures didn't allocate, we wouldn't have these problems in the first place
12:35:41FromDiscord<dom96> Ahh, that's not clear from what you've said.
12:35:59FromDiscord<dom96> Which problems are still unresolved in chronos?
12:36:08FromDiscord<dom96> (edit) "Which ... problems" added "of those"
12:37:46FromDiscord<mratsim> some of structural issues in chronos are linked to defer and try/finally, code size explosion and those here: https://github.com/status-im/nim-chronos/issues/2
12:37:47disbot[RFC] Async I/O with structural control flow (a.k.a. Enforced Awaits) ; snippet at 12https://play.nim-lang.org/#ix=2j7c
12:38:26FromDiscord<mratsim> https://github.com/status-im/nim-chronos/issues/66#issuecomment-582430083
12:38:28disbotmacro code size explosion ; snippet at 12https://play.nim-lang.org/#ix=2J05
12:38:46FromDiscord<mratsim> but I think this is a scheduler problem
12:38:55FromDiscord<mratsim> not closure iterators/cps/coroutine problem
12:39:16FromGitter<bung87> my framework qps thousands faster than jester with std now
12:42:02FromDiscord<dom96> @mratsim yeah, looking at that code size issue it seems to mostly affect debug builds. I doubt it's a problem with async per-se but rather how macros/generics interact.
12:42:38FromDiscord<flywind> What's difference between using syscall and libc function?
12:43:04FromDiscord<flywind> https://man7.org/linux/man-pages/man2/getrandom.2.html#top_of_page
12:43:27FromDiscord<mratsim> syscall is in the kernel
12:43:47FromDiscord<dom96> @mratsim from my perspective it sounds like the remaining issues are minor enough to not warrant a completely different approach, but rather just a few minor fixes
12:43:57FromDiscord<flywind> I see they use `syscall(random)` instead of `getrandom` as their system random implementation
12:44:17FromDiscord<mratsim> @Clyybber, since CPS is using concept and likely co-recursive one, we might want to fix that: https://github.com/nim-lang/Nim/issues/13982 AFAIk generics have a cache to avoid having duplicate instantiation and concepts likely need one as well.
12:44:18disbotConcepts building on each other: duplicated procs in C codegen ; snippet at 12https://play.nim-lang.org/#ix=2y08
12:45:08FromDiscord<mratsim> My big issue with closure iterators is that I can't work with them easily in a multithreaded scheduler.
12:46:04FromDiscord<mratsim> and you can't build them part by parts to say create a parser or an efficient iterator that would allow lazy evaluation/transformation with map/filter/reduce for example.
12:46:41FromDiscord<mratsim> this is solvable by having proper coroutines/fibers/continuations
12:46:58FromDiscord<dom96> Why can't you work with them easily in a multithreaded scheduler?
12:47:01FromDiscord<mratsim> I have to see the implementation of closure iterators though
12:47:47FromDiscord<mratsim> I need owned nocopy objects
12:47:58FromDiscord<dom96> Regarding building them party-by-part, I will just call that chaining. Is that a limitation of closure iterators (the concept and implementation) or just the syntax in Nim with which they're exposed?
12:48:06FromDiscord<dom96> (edit) "party-by-part," => "part-by-part,"
12:48:22FromDiscord<mratsim> you get one alloc per closure iterator
12:48:34FromDiscord<mratsim> it's an implementation limit.
12:48:55FromDiscord<Clyybber> @mratsim yeah, afaik araq was on that
12:49:04FromDiscord<mratsim> I don't think there is a concept of closure iterator, they are just coroutines that don't know their true power.
12:50:13FromDiscord<dom96> I see. So either we free them or replace them with CPS
12:51:26FromDiscord<dom96> (edit) "I see. So either we free them ... or" added "(from their limitations)"
12:51:42FromDiscord<mratsim> well that's the thing. I'm trying to see if 1. coroutines are enough, and i think so. 2. Do we want to implement them in terms of CPS or can we use Nim inline iterator + environment or a state machine generator.
12:52:14*narimiran quit (Ping timeout: 260 seconds)
12:52:18FromDiscord<mratsim> hence why I'm looking into the new Kotlin coroutines which are even more recent than Rust, implemented on Java byte code which has a lot of limitation (meaning library implementation is possible)
12:52:36FromDiscord<mratsim> and they happen to use continuation inside to handle resume.
12:52:59FromDiscord<dom96> Cool, sounds good
12:53:04FromDiscord<mratsim> and on top of those coroutines, Kotlin create launch/await abstraction
12:53:36FromDiscord<mratsim> so I suggest you read that for the inner: https://jorgecastillo.dev/digging-into-kotlin-continuations
12:54:30*narimiran joined #nim
12:56:24FromDiscord<mratsim> and seems like with their lazy async: https://kotlinlang.org/docs/reference/coroutines/composing-suspending-functions.html#lazily-started-async we can have the option to make them zero cost with epoll like Rust or C++ unified executor proposal
12:56:36FromDiscord<juliuskiesian> i have two arrays a and b, and i want to swap the values at a[i] and b[i], what's the optimal way to do it?
12:56:47FromDiscord<mratsim> swap(a[i], b[i])
12:58:23FromDiscord<juliuskiesian> sent a code paste, see https://play.nim-lang.org/#ix=2J0e
12:58:43FromDiscord<juliuskiesian> if i pass Genomes to crossOver, are these copied?
12:59:31FromDiscord<juliuskiesian> (edit) "https://play.nim-lang.org/#ix=2J0e" => "https://play.nim-lang.org/#ix=2J0f"
13:00:05FromDiscord<dom96> That depends on if they're `ref`s or not
13:00:34FromDiscord<mratsim> actually it depends on the size of Genome
13:01:03FromDiscord<mratsim> if it's ref/seq/string those are internally just pointers, so no copy of data occurs
13:01:30FromDiscord<mratsim> if it's an array, it will be copied if less than 24 bytes (3 pointer size) and pass by reference otherwise
13:01:41FromDiscord<mratsim> same rule if it's a big object.
13:03:13*lritter quit (Ping timeout: 264 seconds)
13:03:24FromDiscord<mratsim> if you're worried about copy, make the procedure use var Genome and swap in-place. Because you copy in babyA = a and babyB = b
13:03:44FromDiscord<mratsim> or do the a and b copy in the for loop because you are doing 2 passes over the data right now.
13:05:30FromDiscord<juliuskiesian> sorry, what do you mean 2 passes?
13:07:50*lritter joined #nim
13:09:04FromDiscord<mratsim> `var babyA = a` is one pass over Genome a
13:09:10FromDiscord<mratsim> then the for loop is another pass
13:12:24FromDiscord<mratsim> sent a code paste, see https://play.nim-lang.org/#ix=2J0l
13:13:21FromDiscord<mratsim> On a recent CPU, the if should have no cost even in a tight loop because they are very predictable.
13:13:38FromDiscord<mratsim> and you do a single pass over the data only
13:14:03FromDiscord<mratsim> the newSeqUnitialized might not work for Genome, not sure what's behind the type.
13:32:41FromDiscord<krisppurg> Any answers?
13:32:58FromDiscord<krisppurg> https://discord.com/channels/371759389889003530/371759389889003532/790547175393722370
13:37:13PMunch@krisp, what was your question?
13:39:18FromDiscord<krisppurg> @mratsim#9204 I've answered your question: https://discord.com/channels/371759389889003530/371759389889003532/790547915193843724↵What am I supposed to specify in {}? I know its supposed to make the compiler look for the expression enclose and replace them with the body of toOption
13:40:07*revere quit (Quit: quit)
13:40:09FromDiscord<mratsim> I don't understand why you need converter from that
13:40:37FromDiscord<mratsim> or doing some(something)
13:40:50*revere joined #nim
13:43:14FromDiscord<krisppurg> sent a code paste, see https://play.nim-lang.org/#ix=2J0x
13:44:26FromDiscord<krisppurg> _ _ ^^^
13:46:10FromGitter<ynfle> Can anyone help me with this `{.borrow.}` https://play.nim-lang.org/#ix=2J0z?
13:46:32FromDiscord<lqdev> sent a code paste, see https://play.nim-lang.org/#ix=2J0A
13:46:42FromDiscord<mratsim> then `template rewriteEmbed{Embed(title: t, url: u, color: c, fields: f)}(t, u, c, f: typed): typed = Embed(title: some t, url: some u, color: some c, fields: some f)`
13:46:56FromDiscord<lqdev> mratsim please no
13:46:59FromDiscord<mratsim> though @lqdev solution is better
13:47:12FromDiscord<lqdev> don't encourage him to use term rewriting templates when there clearly exist much simpler solutions
13:47:13FromDiscord<krisppurg> I mean for example
13:47:35FromDiscord<dom96> That but don't name the constructor `embed`, either `initEmbed` or `newEmbed`
13:47:38FromDiscord<krisppurg> embed is an example of specifying so much `some`s
13:47:47FromDiscord<dom96> (`new` for ref objects)
13:48:06FromDiscord<lqdev> @dom96 why?
13:48:31FromDiscord<lqdev> imo constructors should only be named with the `initT` convention iff they do some extra initialization logic
13:48:43FromDiscord<mratsim> @ynfle report on Github
13:48:55FromDiscord<mratsim> likely that borrow for iterators doesn't work
13:49:07FromDiscord<krisppurg> Another example is https://krisppurg.github.io/dimscord/dimscord/restapi.html#editGuild%2CRestApi%2Cstring%2Cstring
13:49:16FromDiscord<dom96> @lqdev no, the convention is to always name this way
13:49:26*Q-Master quit (Ping timeout: 256 seconds)
13:49:27FromDiscord<lqdev> but i don't like that convention.
13:49:45FromDiscord<dom96> fair enough, but that is the convention 🙂
13:49:59FromDiscord<mratsim> there are at least one, maybe 2 RFC for that
13:50:10FromGitter<ynfle> @mratsim `pairs` works https://play.nim-lang.org/#ix=2J0E
13:50:31FromDiscord<mratsim> at status we use `proc init(T: typedesc, a: int, b:float, c:string): T` convention.
13:50:47FromDiscord<mratsim> so taht you can use Embed.init(a, b, c)
13:51:10FromDiscord<haxscramper> I use `make` too, and `ć͘͡҉̗̝̼o̸̵̴n̷̛̟d̷̶̡é́͜n͍͟͝s̷̺͝e̶̻͝`
13:51:26FromDiscord<mratsim> maybe items doesn't use lent return value then?
13:51:26FromDiscord<haxscramper> `makeRect`
13:51:34FromDiscord<krisppurg> the reason why I'm not using an embed constructor is because:↵(See other objects too that start with "Embed")↵https://krisppurg.github.io/dimscord/dimscord/objects.html#Embed
13:52:40FromDiscord<lqdev> well it does have a lot of fields and thus proc params but compilers are smart enough to inline that anyways
13:53:02FromDiscord<krisppurg> It would be a hassle to write a constructor, so why not a simple solution.
13:53:21FromDiscord<lqdev> well you're saying it's a hassle to write `some` everywhere
13:53:26FromDiscord<lqdev> you can always just macro it
13:53:29FromDiscord<krisppurg> Yes
13:54:19FromDiscord<krisppurg> how could I?
13:55:28FromDiscord<krisppurg> re
13:55:35FromDiscord<krisppurg> (edit) "re" => "re: ^"
13:55:51FromDiscord<mratsim> believe me, it's way more of a hassle to hunt down converter / autocovnersion bugs
13:56:10FromDiscord<mratsim> write a macro that overload with a default parameter
13:57:07FromGitter<ynfle> @mratsim https://nim-lang.org/docs/iterators.html#items.i%2Cseq%5BT%5D
13:57:27FromDiscord<mratsim> here is a simple macro that copies a proc, it's parameter, its body and renames it: https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/linear_algebra/helpers/overload.nim
13:57:49FromGitter<ynfle> Was that for me?
13:57:59FromDiscord<mratsim> you can use that as a base to create a proc or template that put the needed "some"
13:58:18FromGitter<ynfle> I'm guessing not
13:58:45FromDiscord<mratsim> you just need to put newCall(ident"some", _) here: https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/linear_algebra/helpers/overload.nim#L20
13:59:44FromDiscord<mratsim> ynfle: what the hell is lent2 in the stdlib 😮
13:59:48*abm joined #nim
14:00:18*Q-Master joined #nim
14:01:08FromDiscord<krisppurg> instead of body.add use newCall
14:02:24FromDiscord<krisppurg> What does overloaded name supposed to mean?
14:02:30FromDiscord<mratsim> the best way to learn is to use echo "treerepr" to see the before/after
14:02:49FromDiscord<mratsim> echo node.treerepr
14:02:56FromDiscord<shadow.> mratsmim newCall ident is deprecated
14:03:02FromDiscord<shadow.> use newCall(string, untyped)
14:03:37FromGitter<ynfle> @mratsim https://github.com/nim-lang/Nim/blob/version-1-4/lib/system/iterators.nim#L1
14:03:40FromDiscord<mratsim> I use it to create overloads with the same name when the C or Fortran proc has different names: https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/linear_algebra/helpers/auxiliary_lapack.nim#L13-L14
14:03:49FromDiscord<mratsim> @shadow. Ah thanks
14:03:52FromDiscord<shadow.> np
14:04:01FromDiscord<krisppurg> So proc name?
14:04:06FromDiscord<shadow.> yup
14:04:16FromDiscord<shadow.> newCall("echo", newLit("hello, world"))
14:04:26FromDiscord<shadow.> what kind of macro are you making again?
14:04:30FromDiscord<shadow.> im sure i could contribute
14:04:45FromDiscord<mratsim> something to remove noisy "some" in a constructor
14:05:04FromDiscord<mratsim> but not having to define a proc each time we want a "someless" constructor
14:05:07FromDiscord<shadow.> nono i knew that but
14:05:10FromDiscord<shadow.> how would that be accomplished
14:05:25FromDiscord<mratsim> @ynfle, yes but why is it lent2 and not lent
14:05:47FromGitter<ynfle> :shrug:
14:06:00FromGitter<ynfle> I guess that's why it can't borrow
14:06:00FromDiscord<krisppurg> im confused still, do I have to make the constructor?
14:06:02*tane joined #nim
14:06:04FromDiscord<mratsim> you take the base proc or type or expression and you replace arguments by some arg
14:06:15FromDiscord<mratsim> probably not
14:06:33FromDiscord<mratsim> you can do "somify(Embed(foo: a, bar: b, ...))"
14:06:48FromDiscord<mratsim> with somify being a macro that rewrites the expression with some
14:07:38FromDiscord<mratsim> so transforms that to: Embed(foo: some a, bar: some b, ...)
14:07:47FromDiscord<krisppurg> right
14:07:48FromDiscord<mratsim> it can be AoC day 21 😉
14:08:01FromGitter<ynfle> @mratsim, it was actually to fix your issue https://github.com/nim-lang/Nim/issues/14421
14:08:03disbot`items` is 20%~30% slower than iteration via an index ; snippet at 12https://play.nim-lang.org/#ix=2J0N
14:08:45FromGitter<ynfle> https://github.com/nim-lang/Nim/pull/14447
14:08:46disbotfix #14421 items uses lent T ; snippet at 12https://play.nim-lang.org/#ix=2pTy
14:08:53FromDiscord<mratsim> ah i see it's backward compat https://github.com/nim-lang/Nim/pull/14447/files#diff-c22ce16c62c4ea2da575b120827e8f0a21bfb4156d370c9492fa31db56b78d5aR1
14:08:54disbotfix #14421 items uses lent T ; snippet at 12https://play.nim-lang.org/#ix=2pTy
14:09:39*revere quit (Quit: quit)
14:09:49FromDiscord<krisppurg> Right
14:17:45Fish-FaceI started trying to use `nimeval` to do day 19 part 2 but it seems like a terrible idea
14:18:07narimiranFish-Face: what did you use for d19p1?
14:18:24Fish-Facenpeg + render to regex
14:18:58narimiranFish-Face: do you want some hints for pt.2?
14:19:14Fish-FaceOnly nim-related hints I think
14:19:23Fish-Facealthough
14:19:43narimirani think you need to realize what do new rules really do
14:20:03FromDiscord<flywind> Does vmops work in JS backend?
14:20:18FromDiscord<flywind> !eval import math; static: echo arctan2(0.0, -1.0)
14:20:20NimBot<no output>
14:20:56FromDiscord<flywind> For example, this doesn't work with `nim js -r` and gives `Error: cannot 'importc' variable at compile time; arctan2`.
14:21:31Fish-Faceif you can confirm whether the language you're trying to recognise is regular or not that would help. I thought maybe it is because you end up with something like `a^na^mb^m` (where a and b are actually non-terminals) which just works out as `aa+b+`, but if I mangle the rules that way it doesn't work
14:21:45Fish-Facebut maybe I just screwed it up
14:22:30narimiranFish-Face: for pt.2, you need to do it manually first - to realize what's going on there
14:22:48Fish-Facedo what manually? expand the new rules a few times?
14:23:09*revere joined #nim
14:23:12narimirani don't mean to solve it completely, just to realize what the new rules really represent, and where do they occur
14:24:44*abm quit (Ping timeout: 256 seconds)
14:24:44Fish-FaceI mean the first one represents something like "one or more rule 42" and the second represents "one or more rule 42 followed by the same number of rule 31" whichi s what I was getting at with the a^nblabla up there. Is this not what you mean?
14:25:28narimiranok, half-way there ;)
14:25:42narimiran"...and where do they occur"
14:26:15Fish-Faceone after the other, which is the other thing I was saying with the a^n stuff :P
14:26:35ZevvI had an interesting experience with 19
14:26:47Fish-Facehence my question of whether the language is in fact regular, in spite of the "same number of..." appearing :P
14:26:47ZevvI rewrote my input to an nepg grammar in vi
14:26:48Zevvran it
14:26:50Zevvand got the wrong answer
14:27:04Zevvbut I got so nauseous looking at the aaabbabababaabaaabaa that I gave up debugging
14:27:26Fish-FaceZevv: because PEGs are deterministic, basically I think
14:28:00Zevvthat was my idea, but then I propably didn't read the assignment properly
14:28:03Zevvthat's usually my problem
14:28:09ZevvI start coding and read after
14:28:22Fish-FaceI rewrote mine to `pegs` format programmatically and it also failed. I thought i could just switch around the priorities in the choices but it also didn't work
14:29:03Fish-Facethat's why I was trying to rewrite to `nimly` since it's a BNF parser rather than PEG
14:29:18Fish-Facebut I wanted to do it programmatically rather than in vi :P
14:29:46Zevvwell, the thing is: it's not documented, but you can build npeg grammars programmatically
14:29:53Zevvthat's what npeg does when it parses the grammar
14:30:11Fish-Facehmm, but doesn't `npeg` have the same issue that it is deterministic?
14:30:20Zevvso you can do `let a = newPat("a"); let b = newPat("b"); let c = a * a * b * b * b`
14:30:27Zevvthen c is a grammar that matches "aabbb"
14:30:31Zevvyes it does
14:30:38Zevvso that's out. It would have been fun though :)
14:30:42Fish-Faceyeah
14:30:49Fish-Facethat's useful to know though
14:31:02Fish-FaceI used `pegs` because the primary interface is run-time :P
14:31:04Zevvwhen all you have is npeg, everything looks like a grammar
14:31:16Zevvsure pegs is better suited here
14:31:17Fish-Facewee-eell, this *is* a grammar question we're talking about!
14:31:29Zevv:)
14:31:34Fish-Facebut I think narimiran is trying to say that the language might actually be regular
14:31:59ZevvI saw a 12 line python version that made me pretty angry
14:32:07Fish-Faceoh?
14:32:29narimiranZevv: because it could be done in 11 lines?
14:32:34Zevvhaha
14:33:02Zevvanyway, I just often use npeg for parsing the input because I'm at the state where I can type most of these grammars in one go without mistakes
14:33:10Zevvfor me it's less error prone than split() etc
14:33:16Fish-Faceheheh
14:33:29ZevvI just did today in my lunch break
14:33:46Fish-FaceI am 1.5 hours into my lunch break
14:33:50Fish-Faceshould probably go back to work
14:33:56ZevvI skipped a few days tho
14:33:59Fish-Facehave been looking at 19 tho
14:34:00Zevvyesterday looked fun
14:34:03FromDiscord<Quibono> Sooo I've got a json response that is a seq of two different object types, which I'd like to deserialize. How do I structure a nim object that is optionally object A or B?
14:34:16Fish-Face20 part 2 is annoying because it involves rotating stuff
14:34:28FromDiscord<Shucks> Whats the reason of using `when true:` or `when false:` blocks? Saw them on github and stdlib sometimes.
14:34:35Zevvrotating by 90° is trivial
14:34:52ZevvShucks: usually leftovers from debugging
14:34:58Zevvits like #if 1 or #if 0
14:35:14Fish-Faceit's not that it's hard it's just annoying and error-prone
14:35:15narimiranZevv: yesterday looked fun??
14:35:21Zevvno?
14:35:30ZevvI have the solution in my head
14:35:37narimiranZevv: for pt.1 or pt.2?
14:35:42Zevvhaven't seen pt 2
14:35:47narimiranlol
14:35:52Zevvbut for 1 I'd create an int for each possible of the 8 edges of a tile
14:35:52Fish-Facept 1 is fine
14:35:57Zevvand then match up by indexing edges
14:35:58Zevvwhat was 2?
14:36:05Fish-Faceyou have to actually construct the map
14:36:08narimiranpt.1 is veeery easy if you do only what you need to do (and don't what you *think* you need to do)
14:36:09Fish-Facerotate all the tiles correctly
14:36:15Fish-Facenarimiran: yes indeed
14:36:30Fish-Faceanother situation where there is a HUGE shortcut not specified in the text :P
14:36:45Fish-Faceand in fact pt2 also benefits from that
14:37:11narimirani haven't solve pt.2 as it looks like too much work
14:37:17Fish-Facebut I did not finish writing the solver for part 2
14:37:19ZevvFor #1 you would just find the tiles with edges that don't match, right
14:37:29narimiranZevv: almost there
14:37:33Fish-Facemore or less
14:37:53Zevvbut for 2, you pick 1 tile, place it at 0,0 and then find other tiles that fit. Or are there duplicate edges?
14:37:55Fish-Facethe shortcut being there's no guarantee in the text that there are any tiles with non-matching edges
14:38:02Fish-Facethere are no duplicates
14:38:10Zevvthen it's not "hard" as such
14:38:23Fish-Faceyes. just annoying and error-prone :)
14:38:29Zevvpick a tile, place it at 0, 0, and for each of the neighbours find a matching tile in the list you collected
14:38:34Zevvsure, error-prone, I believe that :)
14:38:57Fish-Facein particular you have to track your rotations and flips
14:39:15Zevvno you don't. You can create 8 permutations of each tile and index on each of the "8" edges
14:39:21Zevvand then handle them as individual tiles.
14:39:30Zevvonly thing is: if you use 1 of the 8, you discard the other 7
14:39:39Fish-Facehmph
14:39:46Zevvnot?
14:39:47Fish-FaceI don't like the memory inflation :P
14:39:54Zevvmasochist
14:39:55Fish-Faceyes
14:40:24Fish-Faceit was also masochistic to do AoC in a language I never heard of before December
14:40:29Fish-Face:D
14:40:42Zevvand, how does that work for you
14:41:03ZevvI used nim for half a year before the 2018, but I actually *learned* nim with the AoC I think
14:41:08*liblq-dev quit (Read error: No route to host)
14:41:09Zevvyou just get chased over the stdlib
14:41:32*abm joined #nim
14:42:01Fish-FaceI am collecting a list of irritations as I go
14:42:14Zevvthere's a few
14:42:15narimiranFish-Face: how large is it?
14:42:22Fish-Facenot that large
14:42:33Zevvthe bad thing is that most people seem to just learn to live with those
14:43:12Zevvhttp://zevv.nl/div/grammar.png
14:43:33Fish-FaceI think the biggest thing is the conflation of mutability and reference semantics in function parameters
14:44:01Zevvdoes that actually bite you?
14:44:14narimiranZevv: btw, here's my first ever npeg usage: https://github.com/narimiran/AdventOfCode2020/blob/master/nim/day19.nim
14:44:29Zevvgood boi, you'll get the hang of it
14:44:39Zevvdid it hurt?
14:44:40Fish-Faceit has done. I think you could just deal with it by copying the value within the function but it seems janky
14:45:07narimiranZevv: a bit, but that was me shooting myself
14:45:08FromDiscord<Rika> well i dont understand how mutability and reference semantics are supposed to be separated
14:45:10Fish-Facealso some things go weird if you use reference types. I don't know why you have to define `$` for instance
14:45:15ZevvI wonder; I used to be bothered but I kind of forgot about that
14:45:21narimiranZevv: plan to learn it a bit more and (ab)use it for other AoC tasks
14:45:41Zevvnarimiran: https://github.com/zevv/aoc2020/blob/master/21/main.nim
14:45:50ZevvFish-Face: "go weird"?
14:45:54Fish-Face@Rika: so `x: var int` does not to me mean "x is mutable AND mutating x mutates it in the calling scope"
14:45:56narimiranZevv: yeah, already took a peek at that
14:46:03FromDiscord<Quibono> How do you deserialize a seq that contains both some of ObjectA and ObjectB?
14:46:19ZevvFish-Face: /to me/ is your problem then?
14:46:27FromDiscord<Rika> it does to me, its what is said in the nim docs, its whats intuitive to me with other languages, i dont get it
14:46:34ZevvIt's a C++ &
14:46:36Zevvno more, no less
14:46:43Fish-Facewhich is called a `ref`erence :)
14:46:44Zevvit's *literally* that, if you look at the generated source
14:46:56*JustTakingALook joined #nim
14:47:05Zevvyeah but no one says that we should use the same nomenclature as C++ does
14:47:16Zevvit's the semantics and some words.
14:47:23Zevva "ref" is a "traced pointer" (?) here
14:47:31Zevvhow do you call that in c++?
14:47:33*xet7 quit (Quit: Leaving)
14:47:36Fish-Facehe
14:47:37Fish-Faceh
14:47:41FromDiscord<Rika> smart prolly
14:48:07FromDiscord<Rika> im not sure why it doesnt make sense
14:48:12Zevvso, I don't think this annoyence is one that will stick. It's just something to make your own
14:48:12FromDiscord<Rika> to you i mean
14:48:32ZevvI guess that it's hard to unlearn things
14:48:36Zevvharder then learning, typically
14:48:53Zevvso if it's called a "reference" in your head, yeah, that'll take some more effort
14:48:54FromDiscord<Rika> true
14:49:00FromDiscord<Rika> makes sense
14:49:05Zevvand "var" is maybe a bad choice, I don't know. But for me it's no problem
14:49:36Fish-FaceI understand it but it's not intuitive to me: there are two orthogonal concepts at play, 1. "alters value in parent scope", 2. "mutable within current scope". The appearance of the `var` keyword would most intuitively, IMO, be attached to the second one in parameter lists, just as it is when it's used to declare a variable
14:49:57FromDiscord<Rika> that doesnt make sense to me now
14:50:03Fish-Faceit's not that big a deal though.
14:50:04Zevvright, so the re-use of "var" is the problem here
14:50:10Zevvit's the same word having two distinct meanings
14:50:11Fish-FaceZevv: I think so yes
14:50:19FromDiscord<Rika> thats understandable
14:50:19Zevvwell, luckily we don't have "static" in C
14:50:23Fish-FaceHAH
14:50:25FromDiscord<Rika> lol static
14:50:27Zevvmeaning, like, 5 different things?
14:50:32FromDiscord<Rika> absolute pain to understand
14:50:35Fish-Facethat keyword is an abomination
14:50:57Zevvwell, I guess they did that deliberately to not pollute the keyword name space
14:51:04Fish-FaceI remember at some point finding out about another usage of it. I'd already used C, albeit not much, for some years
14:51:17Fish-Facebut that was a true WTF moment
14:51:41ZevvI had one of those when we had a discussion among collueges on different ways for initialization in C++ we could think of
14:52:29Zevv /why/ so many.
14:53:09Zevvah here it is: https://mikelui.io/2019/01/03/seriously-bonkers.html
14:53:16Fish-FaceI think the most frequent irritation is having to use `foldl` all the time - python spoils you with `sum` and `any` etc. And related to that, I got used to doing a lot of stuff in python with lazy evaluation, but `foldl` and `map[It]` etc need a `toSeq` in there
14:53:27*xet7 joined #nim
14:53:36Zevvyeah, but I only have that 4 weeks a year
14:54:00Zevvtypically from dec 1 to dec 24
14:54:28ZevvNim is not very strong yet on the fp front. Lot of this stuff is not properly optimized and causes copies
14:54:35Zevv~repo zerofunctional
14:54:35disbotno footnotes for `repo`. 🙁
14:54:38Zevv!repo zerofunctional
14:54:39disbotno results 😢
14:54:41Zevvwhat
14:54:52Zevv!repo zero-functional
14:54:53disbothttps://github.com/mikebelanger/nim_functional_benchmarks -- 9nim_functional_benchmarks: 11Comparing performance between nim's functional libraries: sequtils, iterutils and zero_functional 15 0⭐ 0🍴
14:55:00Fish-Facehehe
14:56:37FromDiscord<Rika> !repo zero_functional
14:56:37disbothttps://github.com/mikebelanger/nim_functional_benchmarks -- 9nim_functional_benchmarks: 11Comparing performance between nim's functional libraries: sequtils, iterutils and zero_functional 15 0⭐ 0🍴
14:56:42FromDiscord<Rika> ?????????????????????????????
14:56:53FromDiscord<Rika> also sequtils has an any
14:56:54FromDiscord<Rika> and an all
14:57:02FromDiscord<Rika> not sure if math has a sum though
14:57:14Zevvmath has sum
14:57:30FromDiscord<Rika> prolly does but you need to make sure the seq's inner type can fit the sum
14:57:34Zevvand indeed we have all and any
14:57:47FromDiscord<Rika> but yeah i wish we had better fp
14:57:47ZevvThe toSeq is annoying, it's a limitation of the uniform call thingy
14:58:04FromDiscord<Rika> the ufcs toSeq issue i hear should be fixed soon?
14:58:12FromDiscord<Rika> but i dont know for i am not smart
14:58:44Fish-Faceyeah I figured at least some of those things would be in other bits of the stdlib I hadn't found yet
14:59:30FromDiscord<Rika> i tried reading all of the docs i could find and now i have a big brain xddddd
14:59:37FromDiscord<Rika> (i kid, i am very dumb)
14:59:46narimiranFish-Face: pro tip: go here: https://nim-lang.github.io/Nim/lib.html and just type what you're looking for in the search box on the left
15:00:31Fish-FaceI'm pretty sure I searched somewhere else and found nothing helpful so I just went "screw it" and used foldl... when you have a hammer...
15:00:37Fish-Faceeither that or assumed it was in sequtils
15:00:43Fish-Faceif anywhere
15:01:43*PMunch quit (Quit: leaving)
15:01:50FromDiscord<shadow.> is ufcs limited in pragmas as well?
15:02:05FromDiscord<shadow.> bc i've noticed i can do `{.pragma(a).}` but not `{.a.pragma.}`
15:02:11FromDiscord<Rika> that's just cursed
15:02:15FromDiscord<shadow.> well
15:02:18FromDiscord<Rika> absolutely cursed
15:02:25FromDiscord<shadow.> its for dimscord and i wanted to be able to do `{.discord.event.}`
15:02:28FromDiscord<Rika> i believe so
15:02:33FromDiscord<shadow.> instead of `{.event(discord).}`
15:02:34FromDiscord<Rika> since pragmas are just macros sometimes
15:02:38FromDiscord<shadow.> hmm
15:02:41FromDiscord<shadow.> last time it didn't work
15:02:44FromDiscord<shadow.> i suppose i'll do more testing
15:03:00FromDiscord<Rika> i mean "i believe so" to this
15:03:04FromDiscord<shadow.> ohhh
15:03:34Fish-Faceright
15:03:38Fish-FaceI will stop slacking so much
15:04:09FromDiscord<shadow.> sent a code paste, see https://play.nim-lang.org/#ix=2J1m
15:05:57*Kaivo quit (Quit: WeeChat 2.9)
15:07:13FromDiscord<dom96> I prefer `event(discord)` 🙂
15:07:26FromDiscord<shadow.> rly?
15:07:28FromDiscord<shadow.> fair enough lol
15:13:03*leorize quit (Ping timeout: 240 seconds)
15:13:22EvolverAs I am learning Nim, I am going to start posting generalized questions and their answers on StackOverflow.
15:13:29FromDiscord<shadow.> lol good idea
15:13:34FromDiscord<shadow.> or make a website
15:13:36EvolverDon't downvote me please
15:13:36FromDiscord<shadow.> using jester 😉
15:13:57FromDiscord<shadow.> you could make like a
15:14:01FromDiscord<shadow.> nim tutorial faq
15:14:02FromDiscord<shadow.> or something
15:14:14FromDiscord<Rika> downvoted, duplicate of
15:14:34EvolverIf everyone posts common questions and answers on SO which are googlable, it will make the language so much easier to use for newbies.
15:16:16FromDiscord<Clyybber> yeah I need to finish up my PR
15:16:22FromDiscord<shadow.> Evolver: that's true
15:20:32FromDiscord<krisppurg> what do I put in the second param? (`_`)
15:21:37FromDiscord<mratsim> you replace by the param a, b, c you collected in someify(Embed(fieldA: a, fieldB: b, fieldC: c, ...))
15:22:10FromDiscord<krisppurg> ?
15:22:48FromDiscord<mratsim> Sorry I don't really have the time to help you, but basically look in the AST of "Embed(fieldA: a, fieldB: b, fieldC: c, ...)"
15:23:22FromDiscord<mratsim> you will see that the a b c that you need have some structure
15:23:23FromDiscord<krisppurg> well I mean what do I need to exactly put in newCall
15:23:35FromDiscord<krisppurg> shadow pointed it out what you provided was deprecated
15:23:47FromDiscord<mratsim> you need to get them and put them in that newCall
15:24:03FromDiscord<krisppurg> get the params?
15:24:07FromDiscord<mratsim> yes
15:24:13FromDiscord<krisppurg> from where?
15:24:24FromDiscord<mratsim> from "Embed(fieldA: a, fieldB: b, fieldC: c, ...)"
15:24:48FromDiscord<mratsim> your macro will transform that into "Embed(fieldA: some a, fieldB: some b, fieldC: some c, ...)"
15:25:14FromDiscord<krisppurg> newCall("some", a, b, c)
15:25:22FromDiscord<mratsim> no
15:25:50FromDiscord<mratsim> it needs to be newCall("some", a) then newCall("some", b) then newCall("some", c)
15:26:10FromDiscord<krisppurg> right
15:26:12FromDiscord<mratsim> those a b c are at some index of the ast[i]
15:26:21FromDiscord<mratsim> so you will have a for loop
15:26:52FromDiscord<mratsim> and you need to look at the AST to know if it's ast[i] or ast[0][i] or ast[1][i] or something
15:27:02FromDiscord<mratsim> and you use treeRepr to get a representation of the AST
15:27:14FromDiscord<krisppurg> https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/linear_algebra/helpers/overload.nim#L17
15:27:31FromDiscord<mratsim> this is for a proc
15:27:50FromDiscord<mratsim> but if you don't want a proc and directly transform an constructor call the AST is different
15:28:28FromDiscord<mratsim> you can use "dumpTree: Embed(foo: a, bar: b, baz: c)" to get an idea
15:28:46FromDiscord<mratsim> or within a macro: "echo treeRepr(myAst)"
15:29:11FromDiscord<juliuskiesian> i see.
15:30:18FromDiscord<juliuskiesian> sent a code paste, see https://play.nim-lang.org/#ix=2J1r
15:30:24FromDiscord<juliuskiesian> that's the Genome type.
15:30:45FromDiscord<krisppurg> lemme get this straight, so for constructing an object you would need to `somify(Embed(...))`↵in `somify`, you get the params then you iterate each param and do newCall("some", param), then...?
15:31:38FromDiscord<mratsim> then you reconstruct the Embed call with the "some" instead of plain parameters
15:31:58FromDiscord<mratsim> @juliuskiesian if Direction doesn't involve seq/ref/string you can use https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/private/sequninit.nim#L15-L19
15:32:13FromDiscord<mratsim> if you can wait a hour I'll show you
15:32:20FromDiscord<krisppurg> right
15:32:28FromDiscord<mratsim> ping me if I forget
15:32:30FromDiscord<juliuskiesian> @mratsim Direction is just an enum.
15:32:35FromDiscord<krisppurg> sure.
15:33:41FromDiscord<mratsim> @juliuskiesian then you can use my own newSeqUninit, the one in the stdlib has been restricted to numeric types but you can use it for any types that is trivially destructible
15:34:10*waleee-cl joined #nim
15:34:36FromDiscord<juliuskiesian> hm, sorry for the bad naming, dnaSeq is actually an array.
15:36:45FromDiscord<mratsim> array are fine as well
15:37:18FromDiscord<juliuskiesian> sent a code paste, see https://play.nim-lang.org/#ix=2J1v
15:37:19FromDiscord<mratsim> but as I said, if you want to optimize this, pass mutable buffers to the proc and do the swaps in place
15:38:00FromDiscord<mratsim> before optimizing though, you should ensure that your code is correct and have a test suite
15:38:14FromDiscord<mratsim> then benchmarks to make sure it's useful.
15:44:30jkenI am having a dumb moment, I can't seem to write this for loop using coutndown.. for ( int col=width-1; col>0; col-- )
15:45:00FromDiscord<haxscramper> `for i in countdown(width - 1, 1)`
15:45:53FromDiscord<haxscramper> It yields all values including first and last, just like `..`
15:46:11FromDiscord<haxscramper> Though IMO `..` should just work for reversed ranges
15:48:04*Vladar quit (Quit: Leaving)
15:48:12FromDiscord<Rika> I don't actually understand why it does not
15:49:19FromDiscord<haxscramper> I wanted to pr this, but hen I looked at source code, it had `magic: "DotDot"` and I went like no, thank you
15:50:08FromDiscord<Rika> Man someone needs to document where all these magics come from
15:51:32FromDiscord<haxscramper> `mDotDot, # this one is only necessary to give nice compile time warnings`
15:56:15FromDiscord<dom96> The magics are fairly easy to find, just search for `m` + the name of the magic in the compiler
15:59:32FromDiscord<hotdog> Anyone here using Tabnine pro with Nim? If so would you recommend it?
16:00:34FromGitter<bung87> no, I remember it use about 2gb ram right ?
16:01:35FromDiscord<hotdog> @Bung87 I think the pro version has the option to offload stuff to the cloud. I don't know how much memory it uses with/without that
16:03:20Oddmongerarrrhhh … just try « nim game javascript » in your favorite search engine, and all you get is « game of nim » written in javascript
16:03:23FromGitter<bung87> I use it in another languages, work pretty well, I only have 8gb mac so I never try again
16:07:42*NimBot joined #nim
16:08:05FromDiscord<dom96> I used it for a bit, got irritated by some of its poor completions, in particular for .md files (I don't want it to be guessing very poorly what I am trying to write...)
16:08:22FromDiscord<dom96> And I couldn't figure it out how to disable it in comments which had the same problem
16:13:57FromDiscord<krisppurg> in general how many lines should a nim file have? recommended
16:15:17FromDiscord<mratsim> Personally anything between 200-1000 lines
16:15:34FromDiscord<mratsim> I like to access any part of the code in 3 scrolls maximum
16:18:14FromDiscord<krisppurg> what about how many files?
16:20:07FromDiscord<krisppurg> (trying to split files for my library, but I want to achieve minimalism)
16:22:40*asie quit (Quit: WeeChat 2.9)
16:23:41FromDiscord<haxscramper> Well, it depends on how many things you have of course
16:24:22FromDiscord<haxscramper> But I'd probbaly go with 3+n, where first three files are 'base types', "misc helpers" and "core logic" or something
16:24:30FromDiscord<haxscramper> And then go from this
16:24:55*leorize joined #nim
16:24:58FromDiscord<haxscramper> But as long as you don't go full-on java mode I think it is good
16:29:44*lritter quit (Ping timeout: 256 seconds)
16:30:45*Vladar joined #nim
16:37:40FromDiscord<mratsim> java issue is the directory nesting
16:38:41disruptekmratsim: as i said, you have to convince me that the state machine composes as elegantly as just doing transfers via types. 😉
16:38:45FromDiscord<mratsim> I'd rather have a mess in the same folder like here: https://github.com/libtom/libtommath/
16:39:00FromDiscord<haxscramper> Java issue is class implementations with 47 lnies
16:39:11FromDiscord<haxscramper> in addition to directory nesting
16:39:19FromDiscord<mratsim> well I don't implement Java, I only try to scan through the code :p
16:39:39FromDiscord<mratsim> Carpal Tunnel syndrome is because of Java directories
16:39:39FromDiscord<haxscramper> Neither do I, but when some paper has implementation in java
16:39:53FromDiscord<haxscramper> Because apparently this is the language for parsers
16:39:59FromDiscord<haxscramper> I want to kill myself
16:40:02FromDiscord<mratsim> wait what?
16:40:13FromDiscord<mratsim> a language with no ADT?
16:40:24FromDiscord<mratsim> I thought it was OCaml
16:40:27FromDiscord<haxscramper> Well, not really, but for some reason almost everything I've read for source diffing had example in C++ or java
16:40:49FromDiscord<haxscramper> And just unimaginable amount of thigns written in java for parser etc.
16:40:49FromDiscord<mratsim> likely because of Eclipse sponsored research
16:41:13FromDiscord<haxscramper> LLVM is written in OOP-heavy C++ and that speaks a lot about need for ADT
16:41:27FromDiscord<mratsim> they emulate ADTs with visitors
16:41:35FromDiscord<mratsim> well double dispatch
16:42:02FromDiscord<haxscramper> This is not ADT, it is just ad-hoc implementation of closed object hierarchies
16:42:13FromDiscord<haxscramper> wrong wording
16:43:04FromDiscord<haxscramper> Though I understand value of OOP approach to AST construction when you have million of repluggable parts that each should be able to provide override
16:43:18FromDiscord<haxscramper> AST and beyond
16:43:54FromDiscord<mratsim> The OOP approach is really plugging the ADT hole.
16:44:03FromDiscord<sealmove> Guys I am inside my macro and I have a NimNode (StmtList). I want to call a template that the user of my library defines, and give it as argument my NimNode, so I can inject code into a user-defined template. Is this possible?
16:44:12FromDiscord<haxscramper> > inside my macro
16:44:22FromDiscord<haxscramper> I just nearly choked on this
16:44:29FromDiscord<sealmove> haha
16:44:38FromGitter<bung87> @mratsim I check chronos testasyncstream.nim when use the TLSServerAsyncStream then the wrapped transport not touch anymore ?
16:44:57FromDiscord<mratsim> accept the template name as an untyped parameter, use getAst and regenerate a fresh template
16:45:11FromDiscord<sealmove> the template name is not a problem
16:45:14FromDiscord<sealmove> it can be fixed
16:45:31FromDiscord<mratsim> @Bung87, ask in the #async channel of Nimbus: https://discord.gg/N35rMFrB
16:45:33FromDiscord<sealmove> so I can just generate a template call?
16:46:00FromDiscord<mratsim> with getAST
16:46:04FromDiscord<mratsim> or quote do magic
16:46:16FromDiscord<mratsim> sorry "regenerate a fresh template" is wrong
16:46:17FromGitter<bung87> @mratisim thanks!
16:51:40FromDiscord<sealmove> mratsim getAst on what?
16:51:57FromDiscord<haxscramper> On template that you passed as argument
16:52:12FromDiscord<haxscramper> You need to accept `userTemplate: typed` and then
16:52:31FromDiscord<haxscramper> `userTemplate.getAst()` as long as it resolved correctly
16:53:11FromDiscord<sealmove> But I don't accept any template in my macro. I want to pass an argument to a template that already exists. Let's assume I know its name.
16:53:32*vsantana joined #nim
16:53:50FromDiscord<sealmove> what I wonder is if I can just generate a template call and pass it a NimNode.
16:54:41FromDiscord<haxscramper> Just `newCall("yourTemplate", argumentNode)` then
16:54:57FromDiscord<sealmove> ok, if this works then great
16:54:58FromDiscord<haxscramper> Will generate `yourTemplate(<what-was-inside-argumentNode>)`
16:55:24FromDiscord<shadow.> @krisppurg you still confused w the macros?
16:55:25FromDiscord<shadow.> i can help
16:59:00FromDiscord<sealmove> why do I get 'undeclared identifier' inside a template? do I need to mark it as dirty or something?
16:59:38FromDiscord<haxscramper> If you use something defined outside of a template you might need to `{.inject.}` it
16:59:43FromDiscord<haxscramper> But better show the code
17:00:02FromDiscord<sealmove> yeah I probably need this. btw templates can't use `quote do` right?
17:01:11FromDiscord<sealmove> oh, i can use backticks but without quote do?
17:01:17FromDiscord<mratsim> yes
17:01:23FromDiscord<mratsim> look for the identifier construction
17:01:30FromDiscord<shadow.> well a template is essentially a quote do in itself
17:01:35FromDiscord<mratsim> in macro "undeclared identifier" means that semcheck failed.
17:01:49FromDiscord<mratsim> don't worry too much about the identifier that is mentioned
17:02:24FromDiscord<mratsim> apparently getting a better error message is hard because of needing type that need the macro to resolve correctly or something like that :/
17:03:17FromDiscord<sealmove> how do I tell nim to not do semcheck? the variable is not even in params, but I know it's generated from other code of my
17:06:08FromDiscord<haxscramper> `untyped` argument
17:07:12*habamax quit (Ping timeout: 256 seconds)
17:09:33FromDiscord<sealmove> eh, but it's fixed, I don't want it as parameter if possible
17:11:57FromDiscord<sealmove> hum, it works https://play.nim-lang.org/#ix=2J23
17:12:56FromDiscord<sealmove> even this: https://play.nim-lang.org/#ix=2J25
17:15:36disruptekmratsim: i looked at your timers tickets. if you're willing to entertain moving away from timer futures, then i'd just write a custom queue.
17:16:07disruptekthis stuff is too simple to waste time with, imo.
17:17:02FromDiscord<mratsim> For chronos I don't think we'll move stuff until there is a new need i think
17:17:31FromDiscord<mratsim> but I plan to have something efficient for whatever I end up cooking
17:34:32FromDiscord<sealmove> wow what I was trying to do works :))))))))) now the user can mix the generated code by the dsl with his custom code
17:42:03*opal quit (Remote host closed the connection)
17:42:37*opal joined #nim
17:43:40Zevvnice sealmove
17:44:17*mfiano quit (Ping timeout: 246 seconds)
17:44:38*wowi42_ quit (Ping timeout: 246 seconds)
17:44:54*wowi42 joined #nim
17:46:29*mfiano joined #nim
17:50:09FromDiscord<krisppurg> Hour has passed
17:52:55*wowi42 quit (Quit: Kowa Bunga!!!)
17:53:40*wowi42 joined #nim
17:54:44FromDiscord<sealmove> ok I am getting gcc errors for the first time 😄
17:55:28FromDiscord<sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2J2g
17:57:55FromDiscord<lqdev> congratulations! you have now entered the nonsense zone
17:58:08FromDiscord<sealmove> Ikr...
17:59:12FromDiscord<sealmove> i just hope there is something wrong with my code
17:59:50FromDiscord<haxscramper> Are you assigning some kind of closure to tuple field?
18:00:38FromDiscord<haxscramper> Though most likely this is not a closure
18:00:57FromDiscord<haxscramper> IIRC they have `colonanonymous<xxxx>`
18:01:51FromDiscord<sealmove> not using any kind of closure
18:02:09FromDiscord<sealmove> I am indeed assigning to a tuple field
18:04:44*Zevv quit (Quit: Lost terminal)
18:07:20FromDiscord<sealmove> looks like a compiler bug tbh
18:10:11FromDiscord<sealmove> ok I figured it out
18:11:13FromDiscord<sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2J2m
18:11:39FromDiscord<mratsim> looking
18:12:28FromDiscord<sealmove> not exactly, but when I did the declaration outside the template, it worked.
18:13:24FromDiscord<haxscramper> `x` is also gensymed. Try `x {.inject.}`
18:13:55FromDiscord<sealmove> ah ok yeah that's the problem
18:13:55FromDiscord<haxscramper> But that is not guaranteed to work, it depends on what `templateCall` doe exactly
18:14:16FromDiscord<sealmove> so it's safer that i moved the declaration outside the template
18:18:30*a_chou joined #nim
18:20:19FromDiscord<mratsim> @krisppurg https://play.nim-lang.org/#ix=2J2q
18:26:33*Zevv joined #nim
18:34:38*klaufir_ quit (Ping timeout: 260 seconds)
18:48:00FromDiscord<krisppurg> Thank you.
18:51:28reversem3what is a good plotting library that I can import a csv or txt file to get a graph for work?
18:51:45disruptek!repo ggplotnim
18:51:45disbothttps://github.com/Vindaar/ggplotnim -- 9ggplotnim: 11A port of ggplot2 for Nim 15 84⭐ 8🍴
18:53:05*vicfred joined #nim
18:53:12reversem3cool thanks
18:53:15FromDiscord<tiatomee> What's the best way to parse a string that starts with a number and then some other stuff?
18:53:27disruptekparse it how?
18:53:32FromDiscord<tiatomee> I'd have to find out the length of the digit sequence first
18:53:42FromDiscord<tiatomee> I mean a `parseInt` kind of thing
18:53:58FromDiscord<tiatomee> Ideally I'd want something like a `s.takeWhile(isDigit)`
18:54:09FromDiscord<tiatomee> and then use `parseInt` and get the rest of the string
18:54:17FromDiscord<tiatomee> but I don't see anything like `takeWhile`
18:54:48disruptekthere are templates that are suitable for this in sequtils.
18:56:34FromDiscord<tiatomee> I don't see something like `takeWhile` there (apart from building it myself using a fold). I can't use a filter because there is another number later
18:56:53FromDiscord<tiatomee> Huh, I guess I can use `s.split(separator)` and get the two number chunks directly
18:57:19FromDiscord<haxscramper> Also https://nim-lang.org/docs/parseutils.html#skipWhile%2Cstring%2Cset%5Bchar%5D%2Cint
18:57:22disruptekin the time it has taken you to type this, you could have written the loop "by hand".
18:57:59FromDiscord<tiatomee> disruptek: sure, but I'm here to get used to the Nim API and not to speed code :P
18:59:00FromDiscord<haxscramper> Nim api is aproximately `let str = "123hello"; let intVal = parseInt(str[0..skipWhile(str, Digit))`
18:59:51FromDiscord<haxscramper> sequtils just has map/fold/filter
19:00:15disruptekwell, i was thinking you'd compose as you iterate, but.. sure.
19:00:28FromDiscord<haxscramper> I'm not smart
19:00:36mipristrscans and re work as well here
19:01:26FromDiscord<haxscramper> what
19:01:30FromDiscord<haxscramper> oh
19:01:56*JustTakingALook quit (Remote host closed the connection)
19:02:13FromDiscord<mratsim> strscans is probably the simplest here
19:02:16FromDiscord<tiatomee> strscans seems very interesting!
19:02:33FromDiscord<tiatomee> Huh, doesn't seem to do unsigned numbers though
19:02:52FromDiscord<tiatomee> I don't need them that big that the sign bit matters, so it's fine for now
19:03:50*ex_nihilo quit (Quit: Leaving)
19:09:49Zevv>+Digit * >OtherStuff
19:14:57FromDiscord<dom96> parseutils is likely even simpler
19:18:57FromDiscord<dom96> wtf no `pairs` for SharedTable?
19:19:25disruptekZevv: so i'm starting the 2nd part of this atomics talk and it seems that lock tainting isn't supported outside C11.
19:19:51disrupteki mean, the compiler won't protect us. we have to impl it ourself.
19:20:10disrupteki'm like 9mins in fwiw.
19:21:32FromDiscord<shadow.> @mratsim @krisppurg for the someify, wouldn't it↵1. have to be recursive↵2. not someify some fields?
19:21:47FromDiscord<shadow.> because there are nested fields that need to be turned into options
19:21:51FromDiscord<shadow.> and there are fields which are not options
19:21:53FromDiscord<sealmove> @PMunch, @giaco, plugin system is implemented :>
19:32:08*PMunch joined #nim
19:33:34jkenIs there a way to write this for in nim, without converting it to a while? for (int start = ((DEPTH*i)+i)+1; start < ((DEPTH*i)+i)+DEPTH+1; ++start)
19:35:03PMunchfor start in (((DEPTH*i)+i)+1)..<(((DEPTH*i)+i)+DEPTH+1)
19:35:36*hnOsmium0001 joined #nim
19:35:47jkenderp, of course .. can be used that way.
19:35:53jkenThanks PMunch
19:35:56PMunchNo problem .)
19:36:18Zevvdisruptek: so, it's good info, right
19:36:55PMunchnarimiran, @shadow., todays AoC stream is live now: https://www.twitch.tv/pmunche https://www.youtube.com/watch?v=RMJCCBviYCg
19:37:27narimiranthanks, will watch if i don't fall asleep :)
19:39:13FromDiscord<PMunch[IRC]> (edit) narimiran, @shadow., todays AoC stream is live now: https://www.twitch.tv/pmunche https://www.youtube.com/watch?v=RMJCCBviYCg
19:39:57PMunchUhm, what was that FromDiscord..
19:41:34FromDiscord<dom96> Seems removing the embeds caused it
19:41:47FromDiscord<shadow.> oh bet ill watch
19:41:48FromDiscord<mratsim> @shadow. the use case @krisppurg wants has no recursivity I think
19:42:05FromDiscord<shadow.> really? in dimscord embeds some subfields need to be options as well
19:42:06FromDiscord<shadow.> iirc
19:42:43FromDiscord<mratsim> well in that case it's better to create initializer procs
19:43:18FromDiscord<shadow.> pmunch: do you have twitch chat linked this time?
19:43:25FromDiscord<mratsim> anyway, the point is that converter are a source of problem and there are way to avoid them while keeping anice syntax
19:43:41FromDiscord<shadow.> i remember last time u had it popping up at the top as well as discord
19:44:24FromDiscord<mratsim> @Zevv now my plan is to find time to watch this one: https://www.youtube.com/watch?v=_fu0gx-xseY
19:44:58FromDiscord<mratsim> negative overhead = underhead?
19:48:37FromDiscord<dom96> Oh how I missed working on both the underlying containers and the library using them... and then trying to figure out which part is broken. Seems to happen quite often with Nim for me 🙂
19:52:20FromDiscord<sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2J2X
19:52:45Zevv"negative overhead abstraction"
19:52:46Zevvright
20:04:08FromDiscord<mratsim> I don't miss static and generics type resolution bugs
20:04:22FromDiscord<mratsim> which tends to happen when working on containers
20:04:52FromDiscord<mratsim> and "toSeq" visibility issues when used in a generic proc and applied to a non-seq collection like HashSet
20:04:54FromDiscord<mratsim> grmblblbl
20:05:07FromDiscord<dom96> it was a hidden lock 🙂
20:05:48FromDiscord<mratsim> this for example is just painful https://media.discordapp.net/attachments/371759389889003532/790671381527265330/unknown.png
20:16:20narimiranPMunch: that's not the correct solution for the example ;)
20:17:09narimiranPMunch: the solution is 5
20:18:01FromDiscord<dom96> ugh, this rabbit hole is getting deeper and deeper
20:20:04*a_chou quit (Remote host closed the connection)
20:21:29FromDiscord<tiatomee> Is there a procedure for counting the number of 1-bits in a number? There's x86 instructions for that, so it would be wasted to do it in software
20:21:42FromDiscord<mratsim> @zevv, another talk which I have to fit in my schedule that looks reeeaaall nice: https://www.youtube.com/watch?v=mlP1MKP8d_Q
20:21:56FromDiscord<mratsim> @tiatomee import bitops and use popcount or countSetBits
20:22:28FromDiscord<tiatomee> Perfect, thank you!
20:23:09FromDiscord<mratsim> if you do a lot of raw bytes handling, there is endians as well, though now I use the Status stew libraries (https://github.com/status-im/nim-stew/blob/master/stew/bitops2.nim)
20:23:17FromDiscord<mratsim> disclaimer I work at Status
20:23:50FromDiscord<shadow.> im going to pr `+=, -=, and =` for hashsets, do you recommend i should do `-+-=` as well or is that too verbose
20:24:23narimirannah, it was rejected last time i did it ;)
20:25:17Prestigewhat would that last one mean?
20:25:25narimiransymmetric difference
20:25:52FromDiscord<shadow.> += was rejected?
20:25:53Prestigeah. Seems odd with operators to me
20:26:02FromDiscord<tiatomee> I'm just doing advent of code and day 14 has a lot of bit mask things going on, but good to know there's more tools!
20:26:06FromDiscord<mratsim> yeah, incl/excl are fine
20:26:39FromDiscord<shadow.> nari, you did the first three?
20:26:54narimirani think so, let me try to find it
20:27:21disruptekzevv: it's good info, but so far i'm not seeing explicit evidence that lock taint will work for us.
20:27:23FromDiscord<mratsim> @miran I think you missed my request from yesterday for a new blog post: https://gist.github.com/mratsim/61b2e25d098df0634143d501a77d8599
20:27:31narimiranhttps://github.com/nim-lang/Nim/pull/7036
20:27:32disbot`sets` assign operators
20:27:56disruptekZevv: basically, this isn't changing any assumption of mine yet.
20:27:58FromDiscord<mratsim> disrupted: what is this lock tian you talk about? something different than the {.lock: FOo.} pragma?
20:28:04FromDiscord<mratsim> taint
20:28:42disruptekyou said the c compiler was smart enough to taint accesses within a lock so that they don't cause stale cache reads.
20:28:43FromDiscord<mratsim> how do I PR this? Directly in the post folder of nim/website?
20:29:04FromDiscord<mratsim> it's the CPU
20:29:10disruptekokay.
20:29:22FromDiscord<mratsim> there are instruction called lockadd locksub etc
20:29:30disruptekwe'll see i guess.
20:29:35FromDiscord<mratsim> the CPU must respect flushing/reloading cache lines
20:29:41FromDiscord<Recruit_main707> cant i pass a seq[NimNode] to a proc that expects varargs[NimNode
20:29:41*lum quit (Quit: Lum: Bye!)
20:29:42disruptekmaybe i need to make a ticket for clyybber to tag as CPSBUG.
20:29:46FromDiscord<Recruit_main707> ?
20:29:51disrupteksure.
20:30:02disruptekit won't get unrolled, of course.
20:30:09FromDiscord<Recruit_main707> i get `Error: cannot convert seq[NimNode] to varargs[NimNode]`
20:30:19FromDiscord<mratsim> and for memory operand like mov, x86 has a strong memory model so this is guaranteed and atomic load/store have no extra cost except if requested with full seuential consistency
20:30:21disrupteka seq is not a NimNode.
20:31:06*lum joined #nim
20:31:09FromDiscord<mratsim> on ARM and Power those are different and so atomic load/store have a different cost depending on relaxed or acquire/release
20:31:23disruptekyeah, i'm fine with that.
20:31:39disruptekso far, so good.
20:31:44FromDiscord<mratsim> Also cache coherency is formally verified nowadays 😉
20:31:58FromDiscord<mratsim> https://lamport.azurewebsites.net/tla/intel-excerpt.html
20:32:21disrupteki guess i will watch the rest of this thing.
20:32:51FromDiscord<mratsim> it's also I think the main reason why we don't see 100+ cores CPU except "network-on-chip" and "cluter-on-chip" design that do not guarantee memory coherency but require synchronization via (hardware) channels
20:33:25FromDiscord<mratsim> and a motivation of Weave. It's likely that due to hardware limitations, multicore CPU will have hardware channel and memory coherency will be emulated.
20:33:28disrupteki'm assuming we will have that, though.
20:33:29FromDiscord<Clyybber> disruptek: rejoin telegram
20:33:38disruptekwut
20:33:39FromDiscord<Clyybber> we are talking about the bug there
20:33:39FromDiscord<Recruit_main707> disruptek: then how can i pass it several NimNodes?
20:33:51FromDiscord<mratsim> seq[NimNodes]
20:34:11disruptekrecruit: write a macro or change the api.
20:34:20FromDiscord<mratsim> the thing is, sequences in macro tend to become array.
20:34:27FromDiscord<mratsim> use a proc ASAP.
20:34:28FromGitter<kayabaNerve> Why does Nim 1.4 print a ton of periods?
20:34:36FromDiscord<Recruit_main707> i am in a ct proc
20:34:40FromDiscord<mratsim> ah
20:35:12disruptekkayabaNerve: it's an "upgrade" from hint[Processing].
20:35:36FromDiscord<mratsim> varargs[NimNode] might become nnkArg while seq[NimNode] become nnkBracket
20:35:44FromDiscord<mratsim> hence the mismatch
20:35:52FromDiscord<mratsim> not sure if this was ever fixed.
20:36:22disruptekclyybber: well, talk about it here or invite me. i'd rather brush my teeth than hack telegram again today.
20:36:45FromGitter<kayabaNerve> disruptek: Thanks for the reasoning.
20:37:02FromGitter<kayabaNerve> And can Defects still be caught? They can, right?
20:37:15FromGitter<kayabaNerve> Sorry, not defects. Fatal Exceptions
20:37:23FromGitter<kayabaNerve> There may be a distinction there I'm not sure of
20:37:48FromGitter<kayabaNerve> Notably considering IndexError, which I have a ton of deprecation warnings for in front of me...
20:38:29FromDiscord<Clyybber> disruptek: nothing new really; I messaged you on telegram
20:38:38FromDiscord<Clyybber> disruptek: Its just that I don't see Araq here too often
20:39:04FromGitter<kayabaNerve> *They are now defects. IndexDefect can only be caught with panics:off...
20:41:44disrupteki'm not sure why we don't want to do CPS development in the CPS repo.
20:41:53disruptekit's designed for this and it works quite well.
20:42:05disruptekit's not like CPS is a secret.
20:42:19disruptekwe can use discussions. issues. pull requests. CI.
20:43:30disruptekkayabaNerve: fatal exceptions are, by definition, fatal.
20:43:45disruptekdefects no longer inherit from CatchableException.
20:46:25*Q-Master quit (Ping timeout: 240 seconds)
20:46:25disruptekthis !requires bug is weird. the query works, and i have a valid github auth, etc. it's just... github's api tells me there are no results.
20:46:51*lum quit (Quit: Lum: Bye!)
20:47:07disruptekfeels like github changed something.
20:47:31narimiranPMunch: spoiler alert: this will be wrong
20:49:08*lum joined #nim
20:49:41Zevvwho wants to see my day20
20:49:44narimiranPMunch: you sorted the wrong thing
20:50:23Zevv42 lines of code
20:50:30narimiranZevv: no way
20:51:00Zevvhttp://zevv.nl/div/d20.png
20:51:22Zevvpart 1, that is :)
20:51:33narimiranwhat are the arrows?
20:51:38Zevvmatching edges
20:51:49ZevvI just generated a dot graph from the matching edges
20:51:58*Q-Master joined #nim
20:53:06Zevvno sea monsters yet tho :(
20:53:07narimiranZevv: now you'll do pt.2 in no time
20:53:24Zevvno because I got the graph, but the knowledge is in dot, not in my code :)
20:53:39ZevvI lost all knowledge of the original images and the transformations
20:53:41Zevvit's just the graph
20:53:49Zevvdidnt' see part II coming :)
20:56:57Zevvwell, pmunch actually did the whole thing pretty compact
20:57:10PMunchIt's not the whole thing :(
20:57:13Zevvah right
20:57:22PMunchI have where each tile goes, just not rotation or flip..
20:57:25*Q-Master quit (Ping timeout: 256 seconds)
20:57:28PMunchWouldn't be too hard to add that though
20:58:46narimiranPMunch: regarding sorting: i've used OrderedTable, which can be sorted, made my life much easier
20:59:14FromDiscord<dom96> Why Firefox, why https://media.discordapp.net/attachments/371759389889003532/790684827816820756/unknown.png
21:04:54FromDiscord<dom96> Andddd another bug caused by closure capturing in loops
21:07:16*narimiran quit (Ping timeout: 240 seconds)
21:07:47*lum quit (Quit: Lum: Bye!)
21:08:27*lum joined #nim
21:09:40disrupteki don't believe it.
21:10:13*lum quit (Client Quit)
21:10:52*lum joined #nim
21:10:53*klaufir_ joined #nim
21:13:11*lum quit (Client Quit)
21:14:53FromDiscord<mratsim> closureScope or capture are supposed to solve this
21:14:57*lum joined #nim
21:16:01*lum quit (Client Quit)
21:18:09*lum joined #nim
21:19:32FromDiscord<dom96> yep, I also needed to write `var x = x` though inside the closureScope for some reason
21:19:47FromDiscord<dom96> I guess maybe that's just how it works
21:25:54*lum quit (Quit: Lum: Bye!)
21:28:30*lum joined #nim
21:31:39*Q-Master joined #nim
21:32:24FromDiscord<mratsim> personally I don't understand those stuff :p
21:32:29*nikki93 quit (Ping timeout: 244 seconds)
21:33:00*rayman22201 quit (Ping timeout: 244 seconds)
21:33:57*rayman22201 joined #nim
21:34:13*nikki93 joined #nim
21:37:18*Q-Master quit (Ping timeout: 268 seconds)
21:48:28*PMunch quit (Quit: leaving)
21:55:44FromDiscord<mratsim> @Araq, does `var a {.goto.} = State` work in javascript?
22:07:55*astronavt quit (Remote host closed the connection)
22:08:14*astronavt joined #nim
22:12:12*Jesin quit (Quit: Leaving)
22:12:54*Vladar quit (Quit: Leaving)
22:19:13*lritter joined #nim
22:20:03FromDiscord<mratsim> some questions to sleep on @disruptek @zevv: https://github.com/nim-lang/RFCs/issues/295#issuecomment-749228257
22:20:04disbotnext steps for CPS ; snippet at 12https://play.nim-lang.org/#ix=2Gti
22:23:06disrupteki'm messing with ref-free cps.
22:24:08*Q-Master joined #nim
22:24:09disruptekit'll be a pita, no doubt.
22:24:39disruptekand it'll require "unsafe" code.
22:24:50FromDiscord<mratsim> I have some ideas about that
22:24:59FromDiscord<mratsim> but more with coroutines
22:25:14FromDiscord<mratsim> it will require alloca and "heap allocation elision"
22:25:29FromDiscord<mratsim> (i.e. the compiler tells me when something escapes its frame)
22:25:34*Jesin joined #nim
22:25:53FromDiscord<mratsim> I have yet to understand how Kotlin mixes coroutines with continuations and state machines
22:26:15FromDiscord<mratsim> going to sleep.
22:26:26Zevvah what does "resume with input" mean
22:26:29disruptekmost of your list i don't want. i want javascript -- because it proves the generality -- and i want resume on input.
22:26:40Zevvi want a lot of yesses
22:26:40disruptekthere's no overhead beyond a fn() in the current cps.
22:26:46Zevvno arch asm
22:27:07disruptekcompile-time, of course, because otherwise what's the point.
22:27:18FromDiscord<mratsim> the paper mentions that CPC has high overhead compared to fn call
22:27:34disruptekignore cpc.
22:27:42FromDiscord<mratsim> compile time as in proc a() {.compileTime.}
22:28:14disrupteki think we don't want to limit the quantity of continuations and i don't even know how you'd go about doing that.
22:28:22FromDiscord<mratsim> or static: cps()
22:28:26*Jesin quit (Remote host closed the connection)
22:28:30FromDiscord<mratsim> it's simple
22:28:43FromDiscord<juliuskiesian> what is the optimal way to invert some range of an array?
22:28:43Zevvah what does "resume with input" mean
22:28:46FromDiscord<mratsim> 4GB, if your continuation require 100B you deduce how many you can have
22:28:57disruptekzevv: it means, iterate with this new value, etc.
22:29:09disruptekmratsim: but available memory has nothing to do with it.
22:29:13Zevvhm yes that would be nice, but not striclty required
22:29:38disrupteki hate to say i require it, but i will probably demand it in whatever i use.
22:29:39FromDiscord<juliuskiesian> for example, given [1, 2, 3, 4, 5], invert the range 1..3, you get [1, 4, 3, 2, 5].
22:30:19FromDiscord<mratsim> use a var openarray
22:30:35FromDiscord<sealmove> how to traverse an ordered table in reverse order?
22:30:47FromDiscord<ElegantBeef> Isnt a `var openArray` expiremental? 😄
22:30:56FromDiscord<mratsim> convert to seq or sort it in reverse @sealmove
22:31:10FromDiscord<mratsim> no, it has been working for years
22:31:20FromDiscord<sealmove> algorithm.reverse will work?
22:31:27FromDiscord<mratsim> what's experimental is first class var and first class openarrays (aka view types)
22:31:38FromDiscord<mratsim> reverse requires an openarray
22:31:39FromDiscord<ElegantBeef> Yea i thought you meant a view
22:31:50*Jesin joined #nim
22:31:52FromDiscord<mratsim> you neet to pass a compare function to OrderedTable.sort
22:31:53disrupteki think frosty is a good showcase example.
22:31:56FromDiscord<mratsim> or convert to seq
22:32:07FromDiscord<sealmove> and there is no way to index it and get a tuple? 😐
22:32:09disruptekmaybe zevv has something meaty.
22:32:27FromDiscord<ElegantBeef> What do you want seal?
22:32:43disruptekbut this ref thing... it's pretty gnarly.
22:33:25FromDiscord<sealmove> nothing, I probably need an array of tuple instead of an ordered table
22:33:38FromDiscord<ElegantBeef> Internally ordered table stores last/first element, so i assume you could add functionality to iterate it in reverse order
22:44:27*lritter quit (Quit: Leaving)
22:45:39FromDiscord<bark> is casting to byte address the best way to do pointer arithmetic 🤔
22:46:35FromDiscord<ElegantBeef> Why are you wanting to do pointer arithmetic?
22:47:20FromDiscord<bark> for now just learning, eventually mayhaps a custom seq type optimized for looking up the last value
22:47:37FromDiscord<bark> or some other datatypes fine tuned for certain operations
22:47:56FromDiscord<bark> looking up the last value shouldn't be too bad anyways 🤔 with nim's seq
22:47:57FromDiscord<ElegantBeef> well we've got `ptr UncheckedArray[T]`, which means you can just offset the access manually
22:48:37FromDiscord<ElegantBeef> But i suppose casting to a `int` then offsetting then casting back to a `ptr T` might work 😄
22:49:05FromDiscord<bark> I'm doing that except I'm casting to byte address
22:49:10FromDiscord<bark> it works okay I suppose
22:49:41FromDiscord<bark> well ByteAdress = int in the end anyways
22:51:42FromDiscord<bark> wait what if I cast a memory range into an unchecked array
22:51:53FromDiscord<bark> it's essentially just doing the pointer arithmetic I'd be doing
22:52:35FromDiscord<ElegantBeef> a `ptr UncheckedArray[T]` is the nim equivalent of a pointer to the first element of an array
22:53:16FromDiscord<ElegantBeef> It let's you index it as you would want to ie `a[0]` returns first element and `a[1]` the second and so on
22:53:40FromDiscord<ElegantBeef> So you probably should be using an unchecked array
22:54:05FromDiscord<bark> isn't it the same as doing a few casts and doing start + index sizeof(T)
22:54:13FromDiscord<bark> + of course checking for overflow
22:54:30FromDiscord<bark> I don't see what I'd gain
22:54:47FromDiscord<ElegantBeef> Well you get easy use of `[]` 😛
22:54:54FromDiscord<bark> I can define `[]`
22:55:01FromDiscord<ElegantBeef> `easy use`
22:55:05FromDiscord<ElegantBeef> I'm a numpty so disregard me
22:55:18FromDiscord<bark> well maybe it saves a bit of dev time
22:55:36FromDiscord<bark> I haven't tried using any ptr in larger projects yet, so I really can't know how it'll work out in the end
22:56:12FromDiscord<ElegantBeef> This is where i say most of the time `ptr` isnt idiomatic 😛
22:57:34FromDiscord<guzba> @ElegantBeef fyi since you were asking about zip files and tarballs, i have added support for tarballs to zippy (.tar and .tar.gz + variants)
22:57:37FromDiscord<guzba> example creating tarball from dir: https://github.com/guzba/zippy/blob/master/examples/tarball_create.nim and example extracting tarball: https://github.com/guzba/zippy/blob/master/examples/tarball_extract.nim
22:57:45FromDiscord<ElegantBeef> Fuck that was quick
22:57:47FromDiscord<guzba> it tested across my windows and mac as well as using nim's source tarball so it should be working pretty well. it is hot off the press tho so the usual trust but verify applies
22:57:48FromDiscord<ElegantBeef> Good job 😄
22:58:26FromDiscord<bark> if it's just a matter of running nimble test I can test on linux
22:58:54FromDiscord<ElegantBeef> Eh it's pure nim, it works on mac and windows it probably works "everywhere" 😄
22:59:11FromDiscord<ElegantBeef> I'll be testing it anyway on linux as i implement it
22:59:25FromDiscord<ElegantBeef> Thanks guzba
22:59:28FromDiscord<guzba> its true, though there are a few things where i'm like "hope this is ok?" for example, internally should it be unix path separators or are windows ok?
22:59:35FromDiscord<guzba> it seems windows are ok on mac but idk about all possible impls
22:59:44FromDiscord<ElegantBeef> just use the `/` operator
22:59:46FromDiscord<guzba> and using unix on windows is its own opposite thing? nim seems to handle
22:59:52FromDiscord<guzba> i do, but i more mean
22:59:56FromDiscord<guzba> if i create a tar on windows with /
23:00:08FromDiscord<guzba> then someone tries to extract using some other tool, will it blow up on windows path separators?
23:00:24FromDiscord<ElegantBeef> Windows uses `\` and `/` so possibly, but idk
23:00:26FromDiscord<bark> afaik it's a nim operator that outputs "\\" on windows
23:00:33FromDiscord<bark> or isn't there a os.dirSep or something
23:00:48FromDiscord<ElegantBeef> `/` is just string `&` using `os.dirSep`
23:01:00FromDiscord<guzba> anyway, its probably fine and if not ill find out when an issue is opened
23:01:01FromDiscord<bark> https://media.discordapp.net/attachments/371759389889003532/790715476702920744/unknown.png
23:01:09FromDiscord<guzba> then ill have a case to verify against
23:01:11FromDiscord<bark> wait windows uses
23:01:14FromDiscord<bark> both?
23:01:18FromDiscord<ElegantBeef> It accepts both
23:01:19FromDiscord<guzba> windows is flexible
23:01:25FromDiscord<ElegantBeef> `\` is the preferred
23:04:36FromDiscord<sealmove> is there a way to get inner type of an Option?
23:05:18FromDiscord<sealmove> for example if you have a var of type `Option[Something]`, how do you get `Something`?
23:06:09FromDiscord<guzba> awesome, let me know if you notice anything odd. there are some judgements that had to be made around paths that you may run into and have thoughts on
23:06:40FromDiscord<guzba> (edit) "awesome, let me know if you notice anything odd. there are some judgements that had to be made around paths ... that" added "inside the tarball"
23:10:19FromDiscord<ElegantBeef> Well i'm using it just to compress/ship Unity games, so hopefully i dont run into that
23:19:51*guestWebNodeChat joined #nim
23:20:56guestWebNodeChatIs it acceptable to ask dumb questions here? Having an issue with proc references...
23:21:03FromDiscord<ElegantBeef> Yep
23:21:08FromDiscord<ElegantBeef> I'm here so it's only fitting
23:22:11*kinkinkijkin quit (Ping timeout: 272 seconds)
23:22:11*zielmicha__ quit (Ping timeout: 272 seconds)
23:22:14*l1x quit (Ping timeout: 264 seconds)
23:22:29guestWebNodeChatI have a handful of "proc foo1(x: SomeType): seq[char]" and I want to create a "seq[proc (x: SomeType): seq[char]]" with "@[foo1, foo2, foo3]"
23:22:32*nikki93 quit (Ping timeout: 260 seconds)
23:22:35*Evolver quit (Ping timeout: 258 seconds)
23:22:45*rayman22201 quit (Ping timeout: 268 seconds)
23:22:59guestWebNodeChatThe pragmas(?) or whatever you call the {.noSideEffect.} things seem to be different so it's not working?
23:23:23FromDiscord<ElegantBeef> Yea those are pragmas, what's the code?
23:23:51guestWebNodeChatError: type mismatch: got <proc (tile: Tile): seq[char]{.noSideEffect, gcsafe, locks: <unknown>.}> but expected 'proc (tile: Tile): seq[char]{.noSideEffect, gcsafe, locks: 0.}'
23:24:12guestWebNodeChatDoes the full type with pragmas need to be specified as a reference to a proc?
23:26:13miprithe playground's down?
23:26:16FromDiscord<ElegantBeef> Yep
23:26:17guestWebNodeChatNot sure how to treat a proc as a variable other than calling it directly by name
23:26:35disrupteklet p = myproc
23:26:54mipriif you make a simplified example with three procs that get put into arrays and called in a row to add their seq[char]s to a result, it works just fine.
23:27:29miprilet procs = @[foo1, foo2, foo3]; ... for p in procs. Nothing to it. There's no magic.
23:27:32guestWebNodeChatBy variable I meant seq of them, sorry
23:27:40mipribut yes the pragmas make them incompatible types.
23:27:45miprican make them.
23:27:47disruptekspecify locks: 0
23:27:55miprisince pragmas do things like completely change how a function needs to be called.
23:28:40guestWebNodeChatSome of them use .map(x => ...) with sugar, so I guess that changes the type
23:30:13mipriyou've just discovered that it does. sugar gets pretty magical.
23:30:30guestWebNodeChatIt kind of seems like the colored function problem
23:31:43mipriit's really just that Nim isn't an FP lang and macros related to procs, like those in sugar, aren't designed with FP use patterns as a concern
23:32:39mipriprobably the concern there was to make the most restrictive proc possible so that you can use sugar with receivers that only work with e.g. gcsafe noSideEffect locks: 0 functions.
23:34:19mipriyou can resolve this in the direction in defining your procs to definitely have a consistent type, or by passing seq[SomeEnum] around and calling different procs based on that.
23:34:36guestWebNodeChatIs there a way to opt into runtime checking if I only care about the input and output types, and know the underlying data so nothing weird will happen?
23:35:11mipriI doubt that there's an option like that.
23:35:34FromDiscord<ElegantBeef> Seems like something that would bite you in the ass, so something that wouldnt be allowed
23:35:37guestWebNodeChatI don't really know what the pragmas will do, especially locks, and how that would change the sugar stuff... so an academic but correct answer? :) I'll need to read about that stuff
23:36:19miprijust use proc() instead of sugar for a use like this.
23:36:44guestWebNodeChatMeaning don't use the FP syntax and call it without sugar?
23:37:01mipriyes, just use proc() instead of sugar.
23:40:51FromDiscord<ajusa> Does anyone have a link to a good tutorial on Nim templates? I've read through the one in the docs but I still don't fully understand them/can't get them to work in my code
23:42:23FromDiscord<ElegantBeef> They're just basic code substitution take the args and throw them around in the template body
23:43:05FromDiscord<sealmove> Unfortunately I don't think there is a way for the user of binarylang to alter the type of the parsed value 😐 but at least he can perform arbitrary operations on it and even chain them!
23:43:27FromDiscord<ajusa> Okay, that's what I thought. I just got my code to work actually, I was missing the untyped return value so that the code would actually be substituted
23:43:40FromDiscord<ajusa> (edit) "value" => "type"
23:44:24FromDiscord<ElegantBeef> Ah yea, that's a requirement for if you return in the body, to satisfy nim's compiler
23:44:58guestWebNodeChatOk thanks all
23:45:03*guestWebNodeChat left #nim (#nim)
23:46:01FromDiscord<ajusa> Wait now it isn't working lol. Is it possible to make a template that could fill in elements of a seq? For example,↵`[1, 2, templateCode, 3, 4]` getting turned into `[1, 2, 3, 5, 6, 7, 3, 4]`↵The numbers are completely arbitrary but I think you get the point.
23:46:26FromDiscord<ajusa> (edit) "a seq?" => "an array?"
23:47:05miprino, that's not possible.
23:47:51mipriyou could do it with someMacro: [1, 2, anythingHere, 3, 4]
23:48:08mipribut there's nothing a template could possibly return in that case that would work.
23:48:36mipriyou'd be better off with [1,2] & someProc() & [3, 4], and you could do that in a static context so the concatenation isn't at runtime
23:49:03FromDiscord<ajusa> That
23:49:13FromDiscord<ajusa> That's intelligent, I'll try that. Thanks!
23:52:28jkenIs there an iterator like pairs, but for N number of items in a chunk?
23:53:00FromDiscord<ElegantBeef> you can do `toOpenArray(start, end)`
23:53:20miprihttps://nim-lang.org/docs/sequtils.html#distribute%2Cseq%5BT%5D%2CPositive
23:53:45jkennice!
23:54:00FromDiscord<ElegantBeef> Or what you actually want from mipri 😄
23:56:38FromDiscord<ajusa> mipri: might be a dumb question but is there anyway to concat over multiple lines?↵someProc & someProc &↵someProc↵Or should I just make a list of them and then concat all at the end?
23:56:58mipriput the & at the end of the previous line
23:58:16FromDiscord<ajusa> okay I swear that wasn't working a moment ago since that's literally what I sent
23:58:17*tane quit (Quit: Leaving)