00:01:14 | FromDiscord | <KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2IVC |
00:02:08 | FromDiscord | <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:47 | FromDiscord | <ElegantBeef> giaco cant you just do this? https://play.nim-lang.org/#ix=2IVD |
00:02:53 | FromDiscord | <KingDarBoja> ;:/ |
00:02:53 | FromDiscord | <KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2IVE |
00:03:03 | FromDiscord | <ElegantBeef> Look at your error |
00:03:13 | FromDiscord | <ElegantBeef> Look at what it expects |
00:03:17 | FromDiscord | <ElegantBeef> Look at the mismatch position |
00:05:05 | FromDiscord | <ElegantBeef> https://media.discordapp.net/attachments/371759389889003532/790369207736467456/unknown.png |
00:05:37 | FromDiscord | <ElegantBeef> Learning to read the error message will make life easier |
00:05:48 | FromDiscord | <ElegantBeef> ~~Plus when i get colourized output done it'll be easier~~ |
00:05:49 | FromDiscord | <KingDarBoja> Agh, I thought I was using `writeFile` |
00:06:20 | FromDiscord | <KingDarBoja> (edit) "Agh, I thought I was using `writeFile` ... " added "🤦♂️" |
00:06:50 | giaco | Elegantbeef, yes, I can. Not sure why I went with concat |
00:06:57 | FromDiscord | <ElegantBeef> Yea this would probably make it easier and less wall of texty 😛 https://media.discordapp.net/attachments/371759389889003532/790369679704981554/unknown.png |
00:07:22 | FromDiscord | <ElegantBeef> Idk using con cat sounds like you dont like cats, so i can see why you'd use it |
00:08:04 | FromDiscord | <KingDarBoja> Indeed |
00:08:33 | FromDiscord | <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:37 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=2IVF |
00:10:25 | FromDiscord | <KingDarBoja> Ty |
00:10:49 | FromDiscord | <KingDarBoja> Sorry for the noise 😛 |
00:39:48 | leorize | disruptek: this is pretty next-level: https://github.com/nim-lang/nimble/blob/3e07ffe71052735b6fc1d9ab06c195ce091ccb80/src/nimblepkg/packageinstaller.nim#L59-L75 |
00:40:12 | leorize | nimble installs a `.cmd` and one without any extensions for binaries on windows |
00:41:16 | leorize | so, 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:36 | giaco | sealmove, your last update works nicely! :D sweet. Thanks |
00:47:11 | * | fowl joined #nim |
00:47:36 | FromDiscord | <shadow.> aoc day 20 |
00:47:37 | FromDiscord | <shadow.> my brain is hurting |
00:47:56 | * | sirn joined #nim |
00:48:17 | giaco | I'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:43 | leorize | depends on what your `foo` is |
00:49:46 | giaco | foo is same thing in both cases, that would be seq[uint8] in my case |
00:50:50 | leorize | can you check if it fits the limitations described in: |
00:50:52 | leorize | ~mcs |
00:50:53 | disbot | mcs: 11method call syntax, or UFCS in popular lingo; see https://nim-lang.org/docs/manual.html#procedures-method-call-syntax -- leorize |
00:51:11 | leorize | https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax |
00:51:15 | leorize | ^ would be that one instead |
00:51:43 | leorize | ~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:44 | disbot | mcs-limits: 11limitations of Nim's method call syntax: https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax |
00:52:59 | giaco | thanks. 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:30 | giaco | apparently 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:43 | Prestige | Are these limitations something that's planned to be addressed as a special case? Or do we just not care about these cases |
01:37:23 | FromDiscord | <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:40 | Prestige | I really need a good Nim project to create at work for our next hack day... |
01:38:57 | Prestige | Would be nice to start using Nim at work. It's made me dislike Js lol |
01:39:24 | FromDiscord | <ElegantBeef> Clearly write nim and output the js and pretend you write code like that 😛 |
01:40:12 | Prestige | I'd need to figure out how to interface with our JS framework and all |
01:40:41 | FromDiscord | <ElegantBeef> Nah just `importC` the procs you need and `exportC` the procs you write 😛 |
01:41:01 | FromDiscord | <ElegantBeef> That's atleast how i half assed my interop for the webrtc api |
01:41:24 | Prestige | I'd be interested in seeing that actually |
01:41:42 | FromDiscord | <ElegantBeef> https://github.com/beef331/mrapi/blob/master/src/mrapi.nim |
01:42:08 | Prestige | Oh, neat |
01:42:11 | FromDiscord | <ElegantBeef> It can be done smarter using promises/async but i couldnt get await to work on Nim's side |
01:42:28 | FromDiscord | <ElegantBeef> There's also an example |
01:42:57 | FromDiscord | <ElegantBeef> If you want to see what the test does it's here https://www.jasonbeetham.com/elementest/ |
01:44:01 | FromDiscord | <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:18 | FromDiscord | <ElegantBeef> But eh, it "works" |
01:46:19 | FromDiscord | <ElegantBeef> I'd remove those callbacks if i could've got await to work, but it just wouldnt |
01:49:04 | leorize | disruptek: just released setup-nim 0.1.1, should fix your issue |
02:15:43 | FromDiscord | <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:48 | leorize | we don't have CI for Mac M1 |
02:17:19 | FromDiscord | <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:28 | leorize | because currently no providers provide M1... |
02:17:48 | leorize | you should be able to build nim on m1 |
02:17:58 | leorize | clone https://github.com/nim-lang/csources_v1 |
02:18:12 | FromDiscord | <Quibono> I've tried but I'm willing to follow instructions lol. |
02:18:14 | FromDiscord | <Rika> more like getting an experimental car that isnt street legal yet 😛 |
02:18:47 | FromDiscord | <Quibono> Lol my car has a fan, but I haven't heard it once. Tis scary |
02:18:57 | FromDiscord | <Quibono> @leorize Okay clone csources_v1 |
02:19:04 | leorize | clone nim-lang/Nim too |
02:19:45 | leorize | copy csources_v1 to Nim then `cd Nim/csources_v1` |
02:19:49 | leorize | run `./build.sh` |
02:19:53 | leorize | `cd ..` |
02:19:56 | leorize | `bin/nim c koch` |
02:20:04 | leorize | `./koch boot -d:release` |
02:20:17 | leorize | then add `bin` to PATH |
02:20:22 | leorize | and you got yourself a compiler |
02:20:28 | leorize | `./koch tools` |
02:20:38 | leorize | and you got the tooling ready |
02:21:55 | FromDiscord | <Quibono> When you say run ./build.sh, am I doing sh build.sh? |
02:22:32 | leorize | yea |
02:23:11 | FromDiscord | <Quibono> sent a code paste, see https://play.nim-lang.org/#ix=2IW5 |
02:23:53 | leorize | try this ./build.sh --cpu arm64 |
02:24:19 | FromDiscord | <Quibono> Same. |
02:26:09 | leorize | please report that as a bug against csources_v1 |
02:26:40 | leorize | https://github.com/nim-lang/csources_v1/blob/2fbbfb191dffdfe0f62460a6aad93f7a1ccd2f5c/build.sh#L6403-L6406 |
02:26:45 | leorize | looks like it's still not supported |
02:27:03 | leorize | funny how we generate sources for ia64 and powerpc but not arm |
02:29:35 | FromDiscord | <Quibono> https://github.com/nim-lang/csources_v1/issues/1 |
02:29:36 | disbot | ➥ sh build.sh --cpu arm64 results in linker command failure. |
02:29:49 | leorize | Quibono does rosetta work for normal x86_64 Nim? |
02:29:59 | FromDiscord | <Quibono> O |
02:30:05 | FromDiscord | <Quibono> I'm not sure how to test it |
02:30:21 | FromDiscord | <Quibono> If you instruct me on how I'll happily test lol. |
02:30:38 | leorize | https://github.com/nim-lang/nightlies/releases/download/2020-12-21-devel-051477b314acae9141eb697ff369385643f1bbbf/nim-1.5.1-macosx_x64.tar.xz |
02:30:43 | leorize | download and extract that |
02:30:50 | leorize | try running bin/nim in there |
02:31:04 | leorize | if it works then we can use it to help you bootstrap arm Nim |
02:34:37 | FromDiscord | <Quibono> So run the unix executable in bin? |
02:35:11 | Evolver | How do I get the first part of a path, e.g. `foo/bar/baz`? This should return `foo`. |
02:35:56 | leorize | @Quibono yes |
02:36:27 | FromDiscord | <Quibono> Okay it ran, how do I confirm it ran properly lol |
02:37:02 | leorize | let's use it to build you an arm64 compiler :P |
02:37:13 | FromDiscord | <Quibono> Lol okay. |
02:37:27 | leorize | `bin/nim c --cpu:arm64 --out:bin/nim compiler/nim.nim` |
02:38:18 | FromDiscord | <Quibono> Sooooo how do I run it with those arguments instead of it autoexecuting? |
02:38:31 | leorize | you run it in the terminal |
02:38:51 | FromDiscord | <Quibono> So cd into it |
02:38:54 | leorize | yep |
02:41:03 | FromDiscord | <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:28 | leorize | `cd ..` |
02:41:37 | leorize | then run `bin/nim` instead of `nim` |
02:42:17 | FromDiscord | <Quibono> Okay that seems to have executed just fine |
02:43:48 | leorize | bin/nim --version |
02:43:59 | leorize | what do you see |
02:44:26 | FromDiscord | <Quibono> Nim Compiler Version 1.5.1 [MacOSX: arm64] |
02:44:44 | leorize | congrats, you now have an arm64 compiler :) |
02:44:52 | leorize | copy bin/nim into <Nim source>/bin |
02:45:03 | leorize | then redo the bootstrapping steps |
02:45:26 | leorize | and you got yourself a Nim installation |
02:45:37 | FromDiscord | <Quibono> Sooo, clone nim from github, then copy, then redo these steps? |
02:46:12 | leorize | xhttps://irclogs.nim-lang.org/21-12-2020.html#02:19:56 <- do from this one |
02:46:17 | FromDiscord | <Quibono> I'm not trying to be obtuse I'm just still pretty new at this. |
02:46:49 | leorize | the path to getting an arm64 compiler is a bit convoluted atm :p |
02:47:18 | FromDiscord | <Quibono> So out of actual curiosity, if I could do it in 20 minutes, why isn't it supported? lol |
02:47:47 | leorize | M1 is not supported by any CI platform yet, so we can't test it |
02:48:21 | FromDiscord | <Quibono> Why not call it an experimental release lol |
02:49:03 | leorize | I 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:23 | leorize | koch needs some fixes to be able to cross-compile a compiler |
02:51:06 | FromDiscord | <Quibono> Gotcha, I appreciate the help. |
02:52:09 | FromDiscord | <Quibono> So I did the step before koch boot -d:release |
02:53:14 | FromDiscord | <Quibono> cd'ed into the source directory, when I do the koch release step it says koch not found |
02:54:45 | leorize | have you did `bin/nim c koch`? |
02:54:59 | FromDiscord | <Quibono> Yep |
02:55:17 | FromDiscord | <Quibono> If I go out a dir and do nim/koch... I get |
02:55:27 | leorize | you need `./koch` :P |
02:55:33 | * | sagax joined #nim |
02:55:39 | leorize | you can only omit the `./` when the folder is in your PATH |
02:56:10 | FromDiscord | <Quibono> lol |
02:56:13 | FromDiscord | <Quibono> Thanks |
02:56:20 | FromDiscord | <Quibono> Is newb |
02:56:49 | FromDiscord | <Quibono> Compiling is still kind of black magic to me. |
02:57:23 | leorize | so bash will look for `<app executable>` in `PATH` |
02:57:39 | leorize | and by default "the current folder" is never in PATH |
02:58:03 | FromDiscord | <Quibono> So you're just saying "hey stupid look here" |
02:58:09 | leorize | yep |
03:02:25 | FromDiscord | <Quibono> Okay now to figure out how to edit PATH on big sur |
03:03:41 | FromDiscord | <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:53 | leorize | restart your terminal |
03:03:56 | leorize | should have it then |
03:04:25 | leorize | .bash_profile, .bashrc are only read on bash startup |
03:07:08 | FromDiscord | <Rika> big sur uses zsh now i believe |
03:07:17 | FromDiscord | <Quibono> Yeah that was the problem |
03:09:17 | FromDiscord | <Quibono> And zsh seems even weirder to update fml |
03:11:57 | FromDiscord | <Quibono> Okay needed to do nano .zprofile THEN change it |
03:12:04 | FromDiscord | <Quibono> Thank you to everyone |
03:13:04 | leorize | you're welcome :) |
03:14:13 | disruptek | leorize: sweet, i'll try it, thanks. |
03:18:57 | disruptek | ironic... big sir is my stripper name. |
03:19:38 | * | klaufir_ quit (Ping timeout: 268 seconds) |
03:19:40 | disruptek | so if you have a working arm build, you can provide the gitnim distro for m1. |
03:20:23 | disruptek | leorize: 0.1.1 doesn't help me. 😢 |
03:21:05 | leorize | logs please? |
03:22:37 | FromDiscord | <Quibono> Rut roh guys when I do nim ... in the terminal it says command not found nim |
03:22:54 | disruptek | https://github.com/nim-lang/nimble/blob/3e07ffe71052735b6fc1d9ab06c195ce091ccb80/sr |
03:22:59 | disruptek | oops. |
03:23:05 | disruptek | https://github.com/disruptek/skiplists/runs/1586727780?check_suite_focus=true |
03:23:08 | disruptek | stupid wayland c+p. |
03:23:43 | disruptek | quibono: echo $PATH and see what they've done to you. |
03:24:19 | FromDiscord | <Quibono> /usr/local/bin /usr/bin /bin /usr/sbin /sbin $/Users/me/nimproj/Nim/bin |
03:24:57 | FromDiscord | <Quibono> Did I copy in the wrong stuff? |
03:25:00 | leorize | disruptek: try `testes.cmd`, if that works file a nimble bug |
03:25:00 | disruptek | well, there's your problem, sport. |
03:25:07 | FromDiscord | <Rika> what is that $ doing there |
03:25:16 | disruptek | send me your $. |
03:25:21 | disruptek | you don't need it. |
03:25:32 | disruptek | leorize: cool. |
03:26:09 | FromDiscord | <Quibono> Aaaand nim works, you're officially all awesome. |
03:26:20 | FromDiscord | <Quibono> Some guide had the $ there, removing it fixed it |
03:26:44 | leorize | https://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:38 | disruptek | hard 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:40 | leorize | and it is a nimble bug |
03:31:43 | leorize | how fun |
03:33:13 | disruptek | .cmd works, though. |
03:33:25 | leorize | yep, I saw it |
03:33:56 | disruptek | findExe should find it, right? |
03:34:12 | disruptek | i feel like that'd be a kinda reasonable expectation. |
03:34:31 | leorize | ofc it can't :) |
03:34:54 | disruptek | so why does nimble create .cmd? |
03:35:11 | leorize | poor man's shim |
03:35:27 | disruptek | sometimes i wish people would just not even attempt engineering. |
03:35:46 | disruptek | like, if you aren't equipped to solve the problem completely, please just don't even design in any solution at all. |
03:35:52 | leorize | https://github.com/alaviss/setup-nim/runs/1586282771?check_suite_focus=true#step:9:189 <- a view into what nimble creates |
03:35:53 | disruptek | just design out the mere hint of a solution. |
03:36:12 | leorize | a file w/o extension for "git bash", and a `.cmd` for Windows cmd |
03:36:21 | leorize | no .exe because who uses it, right? :) |
03:36:36 | disruptek | that's madness. |
03:37:33 | leorize | nimble used to just build all the things and copy them to `.nimble/bin/` |
03:37:41 | leorize | something changed so nimble now try to "symlink" |
03:37:53 | leorize | but that stuff doesn't work on windows |
03:37:56 | Evolver | Is the use of `options` recommended? |
03:37:58 | disruptek | https://github.com/alaviss/setup-nim/runs/1586282771?check_suite_focus=true#step:9:29 |
03:38:03 | disruptek | "building loaf.exe" |
03:38:47 | disruptek | wish i could see the XSuccess hint here. |
03:39:05 | disruptek | Evolver: yes. |
03:39:12 | disruptek | results is really nice, too. |
03:39:15 | disruptek | !repo badresults |
03:39:16 | disbot | https://github.com/disruptek/badresults -- 9badresults: 11like results but worse 15 1⭐ 0🍴 |
03:55:47 | Evolver | If I get a redefinition error, is there any way for me to allow it anyway? |
03:55:54 | disruptek | no. |
03:56:09 | disruptek | why would you attempt to define the same thing twice? |
03:56:35 | Evolver | First time it's `Option[string]`. Second time I want it to be `string` because I already quit if it was none. |
03:56:50 | disruptek | let's see the code. |
03:57:14 | FromDiscord | <Moral Craft> These bots are cool ngl. |
03:58:21 | Evolver | disruptek: https://paste.ee/p/BMj4Y (The whole repo is not public yet since it's a WIP.) |
03:58:23 | disruptek | dom96: 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:55 | disruptek | use a block: to create a new scope or use a new variable name. |
03:59:06 | disruptek | shadowing with a type change is code smell. |
03:59:10 | disruptek | ~disrupstyle |
03:59:11 | disbot | disrupstyle: 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:55 | FromDiscord | <ElegantBeef> Disruptek i'm disappointed, i expected it to say "dont write code" |
04:03:09 | * | muffindrake joined #nim |
04:04:20 | giaco | I'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:33 | FromDiscord | <ElegantBeef> Can we see the code? |
04:05:30 | disruptek | elegantbeef: write whatever you want, just don't show it to me. |
04:05:44 | FromDiscord | <ElegantBeef> lol |
04:05:59 | FromDiscord | <ElegantBeef> I mean i agree with everything you said there |
04:06:36 | giaco | yes but gnome just failed and copypaste is no more working, let me restart gui |
04:10:00 | giaco | ElegantBeef, here -> https://termbin.com/fv7qb . The object I'm trying to read is type OpusTy |
04:10:30 | FromDiscord | <ElegantBeef> Minimal examples save lives |
04:11:31 | FromDiscord | <ElegantBeef> What's the issue anywho |
04:12:55 | giaco | all 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:35 | FromDiscord | <ElegantBeef> You just check the kind of the object then you can access any sub field |
04:15:57 | FromDiscord | <ElegantBeef> So if it's of type `okHead` you should be able to access the `head` field |
04:18:25 | giaco | ElegantBeef, but how? obj.kind -> Error: undeclared field: 'kind' for type parsers.OpusTy |
04:19:58 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=2IWB |
04:20:14 | FromDiscord | <ElegantBeef> Are you calling this from another module? |
04:20:21 | FromDiscord | <ElegantBeef> If so add the `` on the fields |
04:20:51 | FromDiscord | <ElegantBeef> so it turns into `head: T` |
04:23:06 | Evolver | disruptek: OK. I put it in a `block`: https://paste.ee/p/bhgHv |
04:23:38 | disruptek | no, the last let statement and wherever you wish to use such a shadow. |
04:24:11 | disruptek | but sure. |
04:24:16 | disruptek | i guess this works. |
04:24:17 | Evolver | I don't follow. |
04:24:23 | Evolver | It works but what am I missing |
04:25:09 | disruptek | var repo: Option[string] ... repo = some("string") ... block: let repo = get repo ... |
04:25:23 | giaco | ElegantBeef, thanks, but I didn't get it. Do you know the docs page that talks about this `` thing? |
04:25:28 | disruptek | i /think/ you can get away with that last let statement reusing the symbol, but i'm not 100%. |
04:25:45 | FromDiscord | <ElegantBeef> ah sorry |
04:25:47 | disruptek | like i said, it's code smell because the type changed. |
04:25:47 | FromDiscord | <ElegantBeef> it's an asterix |
04:25:51 | FromDiscord | <ElegantBeef> It's called a export marker |
04:25:52 | Evolver | disruptek: I will refactor it. Thanks. |
04:26:02 | FromDiscord | <ElegantBeef> https://nim-lang.org/docs/manual.html#procedures-export-marker |
04:26:03 | disruptek | just a style nit. if it works, it works. |
04:30:32 | * | fputs joined #nim |
04:31:40 | giaco | ElegantBeef, 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:54 | FromDiscord | <ElegantBeef> expose the `kind` aswell |
04:32:12 | FromDiscord | <ElegantBeef> It can be applied to any field you want exposed |
04:32:26 | giaco | thanks! |
04:33:13 | giaco | btw 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:46 | FromDiscord | <ElegantBeef> Yea i know |
04:35:49 | FromDiscord | <ElegantBeef> I checked the logs |
04:36:31 | FromDiscord | <ElegantBeef> For some reason inside backticks it gets turned into a >= sign in the irc bridge |
04:36:59 | giaco | interesting :D |
04:37:19 | giaco | problem solved anyway. Object variants acquired! |
04:52:02 | * | spiderstew joined #nim |
04:55:22 | * | spiderstew_ quit (Ping timeout: 260 seconds) |
04:55:22 | giaco | in 150 lines of nim I've achieved what I did in 500 lines of golang |
04:55:36 | FromDiscord | <Rika> congrats |
04:55:58 | FromDiscord | <Rika> oversimplicity results into complexity which is funny |
04:55:59 | giaco | I know it is not a measure, but it is really nicer to read and write |
04:56:02 | * | narimiran joined #nim |
04:56:45 | FromDiscord | <ElegantBeef> That was inferred by you saying golang 😛 |
04:57:24 | giaco | haha |
05:00:40 | disruptek | nicer to read and write /is/ a measure, as is less code. |
05:07:53 | FromDiscord | <ElegantBeef> It's now that i want to use my colourful output branch that i realize choosenim is lacking |
05:12:33 | disruptek | leorize: here's a weird one: https://github.com/disruptek/jason/runs/1587029260?check_suite_focus=true#step:4:39 |
05:13:35 | disruptek | the test failed, the exec should have raised (in nimble's nimscript) on osx but it didn't. |
05:14:09 | disruptek | looks like the hash is back in the compiler's --version, so that's good. |
05:16:26 | * | a_chou joined #nim |
05:21:22 | giaco | is 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:40 | disruptek | take the addr of the first element. |
05:22:00 | giaco | are seq really sequential in memory? |
05:22:06 | FromDiscord | <ElegantBeef> Yes |
05:22:06 | disruptek | what else? |
05:22:14 | giaco | thanks! |
05:25:07 | * | fputs quit (Ping timeout: 260 seconds) |
05:33:04 | FromDiscord | <ElegantBeef> We should play tricks on people and have sequences just fuck cache locality |
05:33:55 | disruptek | just 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:00 | FromGitter | <gogolxdong> Is there a way to qualify strformat.& when conflicting with `&` symbol from another module? |
05:54:34 | FromDiscord | <Rika> exactly how you just wrote it but with backticks around & |
05:57:46 | FromGitter | <gogolxdong> ah,ok , thanks! |
06:02:02 | disruptek | ~& |
06:02:02 | disbot | &: 11unreachable |
06:04:20 | * | ex_nihilo joined #nim |
06:09:47 | giaco | how 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:49 | giaco | 5555? |
06:10:34 | FromGitter | <jrfondren> https://forum.nim-lang.org/t/7143 |
06:14:19 | giaco | bindAddr was the answer! Thanks |
06:18:07 | * | vicfred quit (Quit: Leaving) |
06:20:44 | giaco | I 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:00 | FromGitter | <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:26 | disruptek | !repos udp |
06:22:27 | disbot | https://github.com/treeform/netty -- 9netty: 11Netty - reliable UDP connection library for games in Nim. 15 55⭐ 4🍴 |
06:22:27 | disbot | https://github.com/fowlmouth/nimrod-enet -- 9nimrod-enet: 11ENet reliable UDP networking library - wrapper for Nimrod 15 12⭐ 2🍴 |
06:22:27 | disbot | https://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:09 | disruptek | you can get 9 results, total, if you speak to disbot directly. |
06:23:24 | disruptek | disbot: are you in the mood to be helpful? |
06:23:25 | disbot | without a doubt. |
06:23:31 | disruptek | aight, there you go. |
06:23:41 | giaco | :D |
06:24:05 | giaco | disbot: udp raw socket |
06:24:06 | disbot | 😕 |
06:24:33 | disruptek | you have to /msg it, chucklehead. |
06:24:34 | giaco | wait, I got it |
06:24:50 | giaco | haha /me dumb |
06:25:05 | disruptek | at least you're on irc. |
06:25:20 | Zevv | like, if you don't know what a TCP FIN is, keep your hands off the internet |
06:25:21 | disruptek | it's impossible for people on discord because yardanico hates them. |
06:25:28 | FromDiscord | <Rika> lol |
06:25:44 | Zevv | oh that came out wrong |
06:25:48 | FromDiscord | <Rika> this time it isnt even because of you disliking discord its just a limitation of the bridge bot haha |
06:26:21 | FromDiscord | <Rika> zevv i assume you mean "keep your hands off of manipulating packets" |
06:26:21 | disruptek | it's due to a limitation of a human. |
06:26:41 | FromDiscord | <Rika> many things can be boiled down to that haha |
06:27:12 | Zevv | no, I mean that in the broadest sense possible |
06:27:31 | Zevv | that would make the world a better place, trust me |
06:27:47 | Zevv | go read a book |
06:28:20 | Zevv | but, nooo, lets make our worlds revolve around facebook and twitter |
06:29:01 | FromDiscord | <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:15 | Zevv | right, and how is that bad |
06:29:22 | disruptek | true, we did nothing else in those days. |
06:29:40 | disruptek | it was only when pornhub came along that i forgot about tcp. |
06:29:49 | Zevv | we just read dickens and got drunk, remember |
06:30:15 | Zevv | the halcyon days |
06:30:41 | disruptek | remember ice-cold server rooms? |
06:31:00 | FromDiscord | <mratsim> cheap threads are not where it's at, cheap tasks are |
06:31:13 | Zevv | dude, I totally forgot of those. and that smell and dry air |
06:31:37 | disruptek | remember vt100 terminal cables? |
06:32:02 | Zevv | rs-232 consoles is in my daily work |
06:32:08 | disruptek | oh, that's right. |
06:32:12 | Zevv | I drop my DTR to log out |
06:32:22 | disruptek | okay, how about tape backup? |
06:32:40 | Zevv | I saved my tapes and 1 DD drive |
06:32:54 | Zevv | I recovered a 90's email a few weeks back |
06:33:16 | Zevv | it has SCSI with, like, 60 pins on the flatcable |
06:33:26 | disruptek | how 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:42 | disruptek | like, it had a hook button on the handset or whatever. |
06:33:56 | FromDiscord | <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:06 | disruptek | i had a 100mb scsi drive that weighed like 15lbs. |
06:34:25 | * | fputs quit (Client Quit) |
06:34:59 | disruptek | adaptec 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:20 | disruptek | remember IDE master/slave jumpers? |
06:35:29 | FromDiscord | <mratsim> remember Zip drives? |
06:35:35 | disruptek | jazz? |
06:35:40 | FromDiscord | <mratsim> Jaz |
06:35:50 | disruptek | the iomega boom, that was crazy. |
06:35:55 | disruptek | s/boom/bubble/ |
06:36:31 | disruptek | remember zmodem? |
06:36:57 | disruptek | remember pc games that came on 37 floppies? |
06:37:17 | disruptek | remember people calling the 3.5" floppy "hard disk" because... it was harder than the 5.25" floppies? |
06:37:43 | mipri | no. What PC game came on 37 floppies? |
06:37:44 | disruptek | remember when you had a floppy with all your games on it? |
06:37:47 | FromDiscord | <mratsim> 37 floppies was a recipe for a "CRC32 checksum failed" error |
06:38:00 | disruptek | Return to Zork was a big one. |
06:38:00 | FromDiscord | <mratsim> I remember games on 5 CDs though |
06:38:20 | Zevv | rika: well, people who dont know about doctoring, typically keep their hands from other people, right? |
06:38:27 | FromDiscord | <mratsim> remember Encarta? |
06:39:03 | Zevv | No, i never ran windows |
06:39:09 | FromDiscord | <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:25 | disruptek | remember the early dictionaries where you could listen to the pronunciation of words like, `cocksucker` and `motherfucker` for hours on end? |
06:39:51 | FromDiscord | <mratsim> I didn't speak or write english at the time |
06:40:10 | disruptek | remember the pc speaker music from star control? |
06:40:18 | disruptek | that was a mindfuck at the time. |
06:41:44 | disruptek | remember BBSes? |
06:41:50 | disruptek | c'mon, man. |
06:42:02 | disruptek | remember bbs "doors"? |
06:42:55 | FromDiscord | <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:52 | giaco | I don't understand if net high-level interface is capable or not in preserving udp packet boundaries |
06:45:54 | disruptek | remember aperture grill CRTs? |
06:46:55 | disruptek | how about the first time you saw VGA gradients? |
06:47:18 | FromDiscord | <mratsim> I have a neural network book from the 80s that mention graphic.h |
06:47:50 | FromDiscord | <mratsim> graphics.h |
06:48:24 | disruptek | lol |
06:49:13 | disruptek | i was thinking today about writing a MUD. |
06:50:21 | * | Zevv quit (Quit: Lost terminal) |
06:50:43 | * | Zevv joined #nim |
06:51:12 | Zevv | its 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:25 | Zevv | why now? what changed, and why not 10 years ago |
06:51:40 | Zevv | this is 70's stuff |
06:51:49 | disruptek | even the cpc paper is 15 years old. |
06:51:52 | Zevv | remember continuations? |
06:52:02 | Zevv | that smell? |
06:52:13 | giaco | because lazy is hipster, and hipster is good |
06:52:27 | Zevv | disruptek: ikr |
06:56:36 | disruptek | i dunno, i couldn't sleep for two days after araq dropped that paper. |
06:57:51 | FromDiscord | <Rika> zevv: they generally keep away from doctoring complicated diseases but no they still talk and touch people |
07:01:38 | Zevv | yeah, it's not that bad of course. It's not like people wihout president skills become president or anything. |
07:02:11 | disruptek | and presidents without medical skills never dispense medical advice. |
07:03:02 | Zevv | anyway, let's don't go there. There's kids around here |
07:03:05 | FromDiscord | <Rika> the analogy is incorrect then |
07:03:24 | FromDiscord | <Rika> why? well you changed the range |
07:04:28 | Zevv | my excuse is that I just got out of bed |
07:08:34 | FromDiscord | <mratsim> @Zevv, neural networks were from the 80s as well |
07:08:47 | Zevv | there you have it. "neural networks" |
07:09:15 | FromDiscord | <mratsim> My father gave me 3 books for implementing them from that time. |
07:09:20 | FromDiscord | <mratsim> they came with floppy disks |
07:09:35 | FromDiscord | <mratsim> and used graphics.h |
07:09:40 | Zevv | I did that as well, but I only had one book :( |
07:09:44 | Zevv | see where that brought me. |
07:09:51 | Zevv | my father was cruel |
07:10:14 | FromDiscord | <mratsim> well he gave that to me after I did Arraymancer .... |
07:10:17 | FromDiscord | <mratsim> so it was too late :p |
07:10:23 | Zevv | hehe :) |
07:13:04 | Zevv | and 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:35 | FromDiscord | <InventorMatt> I think the perceptron was first created in the 50s but gradient descent was the 80s which advanced it significantly |
07:14:12 | disruptek | i feel like if he's not able to talk /and/ write on the board, he should write on the board before class. |
07:14:25 | disruptek | i'm not fucking paying you to write COMPUTER SCIENCE goddamnit. |
07:14:42 | Zevv | oh you payed |
07:15:00 | Zevv | don't start that course, it's like 40 episodes like that |
07:15:04 | disruptek | i'm paying by having to look at this balding fuck in those pants. |
07:15:04 | Zevv | but man is it great stuff |
07:15:04 | FromDiscord | <mratsim> @InventorMatt People even did a physical perceptron iirc |
07:16:00 | FromDiscord | <mratsim> After pushing everyone to use CPS you dare judge a book by its cover? |
07:16:02 | FromDiscord | <mratsim> come on |
07:16:20 | Zevv | who is pushing who? |
07:16:37 | Zevv | (where's that fingerpointing meme thing) |
07:17:17 | FromDiscord | <mratsim> Python mail from 1999 explaining coroutines, continuations and generators https://mail.python.org/pipermail/python-dev/1999-July/000467.html |
07:18:06 | Zevv | "I've often suspected theorists were *surprised* (and maybe appalled when the language folks went on to *implement* the continuation idea. |
07:18:09 | Zevv | Don't really know, but suppose it doesn't matter anyway. The fact is we're |
07:18:12 | Zevv | stuck with them now <wink>." |
07:20:35 | FromDiscord | <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:34 | FromDiscord | <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:50 | disruptek | hey, my old uni. |
07:22:56 | disruptek | i don't know that prof though. |
07:23:30 | Zevv | A van Wijngaarden. he dutch |
07:24:21 | disruptek | you guys are making me sleepy. |
07:24:49 | disruptek | i think maybe mamy is gonna need another couple weeks to steep. |
07:24:54 | disruptek | at this rate, anyway. |
07:25:18 | Zevv | steep? sleep? steepy? |
07:25:50 | disruptek | he needs to let it roll around his head a bit. |
07:25:56 | disruptek | steep like tea. |
07:27:17 | disruptek | probably he will rewrite the whole thing in synthesis. |
07:28:20 | FromDiscord | <mratsim> you joke but I was thinking about that yesterday :p |
07:28:37 | disruptek | nah, i'm not joking. 😉 |
07:38:16 | disruptek | i think ray told me that rust uses a state machine design. |
07:38:56 | disruptek | but although it'd be faster and ... tighter, it's not as versatile. |
07:39:24 | disruptek | it's the better way to impl the static approach w/o fn, but it gives up too much power. |
07:39:52 | disruptek | when you are ready to do it in synthesis, look at my chain demo first. |
07:40:41 | disruptek | i think it makes a compelling argument. and it gives up less, at moderate cost. we don't lose any static analysis. |
07:40:57 | disruptek | https://github.com/disruptek/cps/blob/master/experiments/chain.nim |
07:41:15 | FromDiscord | <mratsim> Ray? |
07:41:28 | disruptek | rayman222O1 |
07:41:55 | FromDiscord | <mratsim> Rust iterators are compiled to a state machine for sure. For Rust async/await I think the state machine is implicit. |
07:42:42 | disruptek | yeah, but it's kinda one-dimensional. |
07:43:14 | disruptek | i can be taught, though. maybe you will convince me. 😀 |
07:43:19 | FromDiscord | <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:39 | disruptek | i think it's a waste. |
07:45:33 | FromDiscord | <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:15 | disruptek | yeah, iirc zachary carter fucked around with that one, too. |
07:46:33 | disruptek | but "i don't care." 😁 |
07:46:35 | FromDiscord | <mratsim> I wanted to implement it in Nim but didn't find the time. |
07:46:55 | FromDiscord | <mratsim> That was my plan for Weave IO before looking into CPS |
07:47:10 | disruptek | more important to have something that is trivially portable, i think. |
07:47:12 | FromDiscord | <mratsim> only thing I'm wary of with it is stuff around floating point registers |
07:47:19 | disruptek | i trust the compiler to take care of us. |
07:47:28 | FromDiscord | <mratsim> yes, that's why I didn't implement Weave using that |
07:47:33 | disruptek | s/compiler/c compiler/ 🤣 |
07:47:47 | FromDiscord | <mratsim> but stackless Python for example as assembly for all arch |
07:48:04 | disruptek | true, but cps runs on web-browsers right now. |
07:49:13 | disruptek | anyway, we can always reimpl a lower level in asm later. |
07:49:17 | FromDiscord | <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:22 | disruptek | the important thing is to nail the ergonomics. |
07:49:26 | disruptek | that's what nim's all about. |
07:49:40 | FromDiscord | <mratsim> Yes that's what I'm thinking about |
07:49:48 | disruptek | right. |
07:49:52 | FromDiscord | <mratsim> so in terms of ergonomics |
07:50:05 | FromDiscord | <mratsim> we need to specify a threadpool interface for cps link |
07:50:14 | FromDiscord | <mratsim> should be easy enough |
07:50:28 | disruptek | dispatcher problem, but yes. |
07:50:32 | FromDiscord | <mratsim> "level 1" would be the 5 primitives on the paper |
07:50:47 | FromDiscord | <mratsim> apparently cpc_spawn can be build on top of those primitives? |
07:50:57 | disruptek | i mean, forget the paper. |
07:51:09 | FromDiscord | <mratsim> I'd do level 1.5 = cpc_spawn, Lua coroutines, ... |
07:51:48 | FromDiscord | <mratsim> level 2 = reimplementing closure iterators, async/await, and D-ranges/C++ ranges |
07:51:51 | FromDiscord | <mratsim> and streams |
07:52:22 | FromDiscord | <mratsim> and maybe npeg with runtime grammar 😉 |
07:52:28 | FromDiscord | <mratsim> or a protobuf compiler at runtime |
07:52:40 | disruptek | well, 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:32 | disruptek | one idea i had was to use the effects system to auto-cps-ify i/o by tainting symbols of painted types. |
07:54:13 | disruptek | user pragma expr would let us invoke the same proc in a cps context or outside. |
07:54:22 | FromDiscord | <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:41 | disruptek | i'm in favor of user stories, yes. |
07:55:57 | disruptek | you should be able to come up with some thorny async problems from status. |
07:57:33 | * | PMunch joined #nim |
07:58:22 | disruptek | frosty wants to use cps to serialize unbounded memory graphs. |
07:58:46 | disruptek | gram wants cps to do queries of the graph via multiple cores. |
07:58:59 | disruptek | (hence skiplists) |
07:59:35 | disruptek | testes wants to clone testes and do criterion runs with them "in the background." |
07:59:35 | FromDiscord | <mratsim> Async problems in Status are: tracking unattended futures, cancellation, thousands to millions of timers, low memory overhead |
07:59:56 | disruptek | why is millions of timers a problem? |
08:00:11 | FromDiscord | <mratsim> Graph queries are CPU bound, use Weave. |
08:00:38 | FromDiscord | <mratsim> not sure why but at one point we had a lot and they were leaking. |
08:00:41 | disruptek | yes, but i want to wrap them in cps in any event. |
08:00:48 | FromDiscord | <mratsim> and it was a pain to track those leaks |
08:00:54 | FromDiscord | <mratsim> also debuggability. |
08:01:11 | FromDiscord | <mratsim> basically a compelling story is maintenance+debuggability |
08:01:22 | disruptek | i cannot fathom why that would be an issue, but maybe someone can write it up for us. |
08:01:31 | FromDiscord | <mratsim> that's our main woes with current event loop + closure iterators |
08:01:40 | disruptek | should be a trivial application for millions of continuations -- timers or anything else, honestly. |
08:03:31 | disruptek | the maintenance story means less code, and simpler code. |
08:04:14 | FromDiscord | <mratsim> sent a long message, see http://ix.io/2IXm |
08:04:21 | disruptek | debugging is something that zevv hates, but it's a fact that people want tracing and exceptions. |
08:05:04 | FromDiscord | <mratsim> Basically, debugging experience makes or break building complex applications |
08:05:15 | disruptek | you 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:24 | FromDiscord | <mratsim> and P2P applications are a pain to debug given that it's very hard to test and reproduce some bugs. |
08:05:44 | FromDiscord | <mratsim> we are using Result instead of Exception as much as possible |
08:05:47 | disruptek | well, play with it. i'm pretty happy with it and it was trivial to impl. |
08:06:33 | disruptek | if you're doing timers with ioselectors then you've already lost. |
08:06:50 | FromDiscord | <mratsim> anyway, I have some ideas to add threadsafe priorities and timers to an IO scheduler |
08:06:50 | disruptek | i would just have a priority queue but what do i know? |
08:07:20 | FromDiscord | <mratsim> chronos uses a heap |
08:07:40 | disruptek | i will look at these tickets after i take a nap. 🙂 |
08:08:01 | disruptek | but, y'know, we're still waiting for clyybber to bring the juice. |
08:08:09 | disruptek | need some of these bugs locked down. |
08:11:15 | FromDiscord | <mratsim> synthesis doesn't work in the browser I think, it uses undocumented `var a {.goto.} = Label` |
08:11:34 | FromDiscord | <mratsim> though if JS has a goto it should be possible to implement it. |
08:13:09 | disruptek | shouldn't be a problem, but i don't think you'll want to go that route in any event. |
08:13:32 | disruptek | Label is a nskLabel in macro-speak, right? |
08:26:02 | * | klaufir_ joined #nim |
08:32:51 | FromDiscord | <mratsim> it's an enum |
08:33:24 | FromDiscord | <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:48 | FromDiscord | <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:25 | FromDiscord | <mratsim> and Nim goto pragma example: https://forum.nim-lang.org/t/1320#8332 |
08:47:52 | Zevv | I hate nothing about that |
08:48:04 | Zevv | good 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:31 | FromDiscord | <dom96> @disruptek, @leorize don’t blame Nimble for Windows’ limitations 🙂 |
09:12:03 | * | hnOsmium0001 quit (Quit: Connection closed for inactivity) |
09:13:21 | FromDiscord | <dom96> I don’t even think we can create a shim with an exe extension |
09:34:13 | * | habamax joined #nim |
09:40:58 | leorize[m] | dom96 you already made some for choosenim |
09:41:25 | FromDiscord | <Rika> chocolatey uses exe shims |
09:41:41 | leorize[m] | scoop uses exe shims too if that matters |
09:42:11 | FromDiscord | <Rika> yeah and they do it better because chocolatey shims dont have the proper icon lmaooooo |
09:44:59 | FromDiscord | <dom96> Yeah. And people hate that too |
09:45:31 | leorize[m] | well your issue rn is that the software doesn't work as expected |
09:49:12 | FromDiscord | <dom96> Yep. It’s definitely a bug. |
09:56:26 | PMunch | Sorry 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:05 | FromDiscord | <mratsim> whether closure iterators, CPS, coroutines/fibers are functionally equivlent and can each be implemented from each other |
09:58:15 | FromDiscord | <mratsim> or I assume that's @dom96 inquiry |
10:05:02 | PMunch | Aah |
10:05:19 | PMunch | I mean I was using closure iterators in order to implement my coroutines |
10:05:23 | PMunch | Which worked pretty well |
10:06:35 | Zevv | ok dom96, it seems Ar4q is clear on this, right? |
10:06:48 | Zevv | see 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:15 | FromDiscord | <sealmove> what's the difference between `tuple or object` and `tuple|object`? |
11:01:29 | FromDiscord | <mratsim> 4 characters |
11:02:48 | FromDiscord | <Rika> nothing in practicality i believe |
11:04:29 | FromDiscord | <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:47 | FromDiscord | <mratsim> Now I'm wondering if I could make continuation the basic building block of that |
11:10:53 | PMunch | Wait, how are you going to unify those? |
11:15:41 | FromDiscord | <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:18 | FromDiscord | <dom96> > ok dom96, it seems Ar4q is clear on this, right?↵yep, I think that clarifies many things. |
11:16:30 | FromDiscord | <mratsim> a code transformation transforms that to proc foo(x, y: int, env = TypedEnv()): int |
11:16:38 | FromDiscord | <dom96> I think mratsim's question is a good one as well in that RFC |
11:17:15 | FromDiscord | <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:29 | PMunch | So syntax similar to what I made here: https://github.com/PMunch/fibers/blob/master/example.nim#L5 |
11:17:52 | FromDiscord | <mratsim> to get inline iterators efficiency: you can auto tag it inline if it never escapes it's scope |
11:18:20 | FromDiscord | <mratsim> and the env is carried in a regular object |
11:18:27 | FromDiscord | <mratsim> that can only be moved or mutated. |
11:18:50 | FromDiscord | <mratsim> and this can be send to a scheduler or across thread |
11:18:53 | PMunch | Wouldn't that still add a bit of overhead to normal iterators? |
11:19:33 | FromDiscord | <mratsim> I think withan inline function call that should be OK but that can be easily measured |
11:19:42 | FromDiscord | <mratsim> and you can do composition. |
11:20:23 | FromDiscord | <mratsim> lifting the environment canbe done either using the compiler logic or what zevv and disruptek developed in CPS |
11:21:32 | FromDiscord | <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:41 | FromDiscord | <mratsim> see Kotlin coroutines that use CPS transform: https://labs.pedrofelix.org/guides/kotlin/coroutines/coroutines-and-state-machines |
11:22:36 | FromDiscord | <mratsim> also CPS is an alternative intermediate representation to SSA in compilers |
11:23:07 | FromDiscord | <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:34 | FromDiscord | <mratsim> This also gives us lazy evaluation that is dear to haskell |
11:31:54 | FromDiscord | <mratsim> and zero cost functional programming without intermediate buffer or allocation |
11:51:06 | FromDiscord | <krisppurg> sent a code paste, see https://paste.rs/3bO |
11:51:41 | FromDiscord | <Rika> the {} is needed to make it term rewriting |
11:51:54 | FromDiscord | <mratsim> the {} will make the compiler automatically look for the expression enclose and replace them with the body of toOption |
11:51:58 | FromDiscord | <Rika> and it only works with the function you specify |
11:52:14 | FromDiscord | <mratsim> so it avoids having to explicitly do toOption |
11:52:15 | FromDiscord | <krisppurg> I have no clue what to specify |
11:52:22 | FromDiscord | <mratsim> but it's more granular than converter |
11:52:34 | FromDiscord | <mratsim> well why did you want to make a toOption converter? |
11:52:41 | * | zahary quit (Quit: Connection closed for inactivity) |
11:55:04 | Zevv | mratsim: the promises keep heaping up. zero proper fp and lazyness, yay |
11:55:11 | FromDiscord | <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:35 | FromDiscord | <krisppurg> (sorry for the ping hooble) |
11:55:40 | FromDiscord | <krisppurg> (edit) "hooble)" => "hobble)" |
11:55:48 | FromDiscord | <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:52 | FromDiscord | <hobbledehoy> all good |
11:56:48 | Zevv | mratsim: i got time to read one, which one do i pick |
11:57:07 | FromDiscord | <mratsim> the first |
11:59:25 | Zevv | so they save the stack frame on a yield |
11:59:27 | Zevv | with a copy |
11:59:57 | Zevv | and do the transformation similar to waht disruptek does |
12:02:39 | PMunch | How do closure iterators in Nim do this right now by the way? |
12:03:47 | FromDiscord | <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:49 | disbot | ➥ every 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:06 | FromDiscord | <mratsim> I yes, forgot about this one |
12:07:30 | FromDiscord | <mratsim> it doesn't do lazy evaluation alone but it does give you inline iterator fusion and chaining |
12:07:51 | FromDiscord | <mratsim> mmmh actually it does give you alzy evaluation. |
12:08:05 | FromDiscord | <mratsim> so I guess it's better for compile-time |
12:12:15 | FromDiscord | <mratsim> And you need to reify this for coroutines/fibers. |
12:15:32 | Zevv | mratsim: do you have any insights on lifting vs copying the stack frame? |
12:15:59 | Zevv | you pay for the copy, but code accessing stack data will typically run faster then code working with lifted data |
12:16:22 | Zevv | so its context switch overhead vs locals access overhead, is that right? |
12:16:28 | FromDiscord | <mratsim> In Weave I just copy, but I require the dev to tell me what to copy. |
12:16:58 | Zevv | right, I guess lifting is friendlier for the user |
12:17:14 | FromDiscord | <mratsim> and I use a hack that {.nimcall, gcsafe.} tagged functions check for invalid capture and missing local variable |
12:17:53 | Zevv | you probably also need some specific platform or os support to manipulate the stack in the first place |
12:18:18 | FromDiscord | <mratsim> either you use setjmp longjmp |
12:18:31 | FromDiscord | <mratsim> or you need assembly to store the stack pointer and base pointer |
12:18:39 | FromDiscord | <mratsim> but that's all |
12:18:43 | Zevv | also with setjmp longjmp you need to bootstrap a new stack |
12:19:23 | FromDiscord | <mratsim> see here: https://github.com/chaoran/fibril/blob/master/src/fibrili.c#L22-L24↵↵mov rsp, mov rbp, jmp |
12:19:56 | Zevv | right, been there |
12:19:59 | PMunch | Aah, all this brings back memories from uni where we were implementing a task scheduling OS in C/assembly |
12:20:18 | Zevv | good they still teach that to the kids these days |
12:20:27 | Zevv | you need to go there at least once imho |
12:20:46 | PMunch | Unfortunately the class has been phased out in other universities that had it |
12:21:02 | Zevv | id love if this would all work with safe nim only, tho |
12:21:13 | Zevv | no platform or arch specific code, no need for setjmp |
12:21:15 | PMunch | My university still has it as a requirement, and I think the same course is optional at Princeton |
12:23:03 | FromDiscord | <dom96> @mratsim does chronos implement what I added to asyncdispatch: instrumentation for the futures that are alive and pending? |
12:23:13 | FromDiscord | <dom96> That really helps with tracking down leaks |
12:23:33 | FromDiscord | <dom96> Why is cancellation a problem? Wasn't this solved in Chronos? |
12:24:26 | FromDiscord | <mratsim> sent a long message, see https://paste.rs/zpq |
12:24:29 | FromDiscord | <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:35 | PMunch | Hmm, this is acting up on recent versions of Nim: https://github.com/PMunch/getmac/blob/master/src/getmac.nim#L74 |
12:24:49 | FromDiscord | <mratsim> with argsTy being a tuple representation of all the parameters |
12:24:53 | PMunch | Says that "expression expected, but found 'keyword else'" |
12:25:01 | PMunch | Did something change with `when` statements? |
12:25:12 | FromDiscord | <mratsim> because tuples can be named, they are really nace for packing unpacking |
12:25:37 | FromDiscord | <dom96> PMunch: sounds like a regression, report it |
12:26:31 | FromDiscord | <mratsim> @dom96 We have a lot of logging, tracking and metrics in chronos now |
12:26:57 | FromDiscord | <mratsim> https://github.com/status-im/nim-chronos/search?q=chronosFutureTracking |
12:27:04 | PMunch | I mean the simple case seems to work fine |
12:27:04 | FromDiscord | <dom96> So these problems are already resolved? |
12:27:37 | FromDiscord | <mratsim> cancellation is a problem because it's manual |
12:27:44 | FromDiscord | <mratsim> there is no "async garbage collection" |
12:28:03 | FromDiscord | <mratsim> so you need to not forget that a cancellable future needs to be manually garbage collected |
12:28:12 | PMunch | Hmm, seems like it's using the result as a block that's the issue |
12:29:11 | FromDiscord | <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:21 | PMunch | https://play.nim-lang.org/#ix=2J01 <- works on 1.2.8, not on 1.4.x |
12:29:54 | FromDiscord | <dom96> I'm not sure how you wish futures to be cancelled automatically to be honest |
12:30:22 | PMunch | Huh, but this is the other way round: https://play.nim-lang.org/#ix=2J02 |
12:30:33 | FromDiscord | <mratsim> you have an interface/trait "onCancellation" that will be called. |
12:30:43 | FromDiscord | <mratsim> and you put your garbage handling here |
12:30:52 | FromDiscord | <mratsim> just like we have `=destroy` |
12:31:13 | FromDiscord | <dom96> But that's what should happen when a cancellation occurs |
12:31:28 | FromDiscord | <mratsim> I am clear about the problems. Zevv was asking about what caused issues in async. |
12:32:03 | FromDiscord | <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:24 | FromDiscord | <mratsim> and any solutions that would replace that needs to provide this. |
12:33:28 | FromDiscord | <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:14 | FromDiscord | <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:08 | FromDiscord | <mratsim> this is resolved in chronos, I don't know the state in asyncdispatch |
12:35:30 | FromDiscord | <mratsim> also if the futures didn't allocate, we wouldn't have these problems in the first place |
12:35:41 | FromDiscord | <dom96> Ahh, that's not clear from what you've said. |
12:35:59 | FromDiscord | <dom96> Which problems are still unresolved in chronos? |
12:36:08 | FromDiscord | <dom96> (edit) "Which ... problems" added "of those" |
12:37:46 | FromDiscord | <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:47 | disbot | ➥ [RFC] Async I/O with structural control flow (a.k.a. Enforced Awaits) ; snippet at 12https://play.nim-lang.org/#ix=2j7c |
12:38:26 | FromDiscord | <mratsim> https://github.com/status-im/nim-chronos/issues/66#issuecomment-582430083 |
12:38:28 | disbot | ➥ macro code size explosion ; snippet at 12https://play.nim-lang.org/#ix=2J05 |
12:38:46 | FromDiscord | <mratsim> but I think this is a scheduler problem |
12:38:55 | FromDiscord | <mratsim> not closure iterators/cps/coroutine problem |
12:39:16 | FromGitter | <bung87> my framework qps thousands faster than jester with std now |
12:42:02 | FromDiscord | <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:38 | FromDiscord | <flywind> What's difference between using syscall and libc function? |
12:43:04 | FromDiscord | <flywind> https://man7.org/linux/man-pages/man2/getrandom.2.html#top_of_page |
12:43:27 | FromDiscord | <mratsim> syscall is in the kernel |
12:43:47 | FromDiscord | <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:57 | FromDiscord | <flywind> I see they use `syscall(random)` instead of `getrandom` as their system random implementation |
12:44:17 | FromDiscord | <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:18 | disbot | ➥ Concepts building on each other: duplicated procs in C codegen ; snippet at 12https://play.nim-lang.org/#ix=2y08 |
12:45:08 | FromDiscord | <mratsim> My big issue with closure iterators is that I can't work with them easily in a multithreaded scheduler. |
12:46:04 | FromDiscord | <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:41 | FromDiscord | <mratsim> this is solvable by having proper coroutines/fibers/continuations |
12:46:58 | FromDiscord | <dom96> Why can't you work with them easily in a multithreaded scheduler? |
12:47:01 | FromDiscord | <mratsim> I have to see the implementation of closure iterators though |
12:47:47 | FromDiscord | <mratsim> I need owned nocopy objects |
12:47:58 | FromDiscord | <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:06 | FromDiscord | <dom96> (edit) "party-by-part," => "part-by-part," |
12:48:22 | FromDiscord | <mratsim> you get one alloc per closure iterator |
12:48:34 | FromDiscord | <mratsim> it's an implementation limit. |
12:48:55 | FromDiscord | <Clyybber> @mratsim yeah, afaik araq was on that |
12:49:04 | FromDiscord | <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:13 | FromDiscord | <dom96> I see. So either we free them or replace them with CPS |
12:51:26 | FromDiscord | <dom96> (edit) "I see. So either we free them ... or" added "(from their limitations)" |
12:51:42 | FromDiscord | <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:18 | FromDiscord | <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:36 | FromDiscord | <mratsim> and they happen to use continuation inside to handle resume. |
12:52:59 | FromDiscord | <dom96> Cool, sounds good |
12:53:04 | FromDiscord | <mratsim> and on top of those coroutines, Kotlin create launch/await abstraction |
12:53:36 | FromDiscord | <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:24 | FromDiscord | <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:36 | FromDiscord | <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:47 | FromDiscord | <mratsim> swap(a[i], b[i]) |
12:58:23 | FromDiscord | <juliuskiesian> sent a code paste, see https://play.nim-lang.org/#ix=2J0e |
12:58:43 | FromDiscord | <juliuskiesian> if i pass Genomes to crossOver, are these copied? |
12:59:31 | FromDiscord | <juliuskiesian> (edit) "https://play.nim-lang.org/#ix=2J0e" => "https://play.nim-lang.org/#ix=2J0f" |
13:00:05 | FromDiscord | <dom96> That depends on if they're `ref`s or not |
13:00:34 | FromDiscord | <mratsim> actually it depends on the size of Genome |
13:01:03 | FromDiscord | <mratsim> if it's ref/seq/string those are internally just pointers, so no copy of data occurs |
13:01:30 | FromDiscord | <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:41 | FromDiscord | <mratsim> same rule if it's a big object. |
13:03:13 | * | lritter quit (Ping timeout: 264 seconds) |
13:03:24 | FromDiscord | <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:44 | FromDiscord | <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:30 | FromDiscord | <juliuskiesian> sorry, what do you mean 2 passes? |
13:07:50 | * | lritter joined #nim |
13:09:04 | FromDiscord | <mratsim> `var babyA = a` is one pass over Genome a |
13:09:10 | FromDiscord | <mratsim> then the for loop is another pass |
13:12:24 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#ix=2J0l |
13:13:21 | FromDiscord | <mratsim> On a recent CPU, the if should have no cost even in a tight loop because they are very predictable. |
13:13:38 | FromDiscord | <mratsim> and you do a single pass over the data only |
13:14:03 | FromDiscord | <mratsim> the newSeqUnitialized might not work for Genome, not sure what's behind the type. |
13:32:41 | FromDiscord | <krisppurg> Any answers? |
13:32:58 | FromDiscord | <krisppurg> https://discord.com/channels/371759389889003530/371759389889003532/790547175393722370 |
13:37:13 | PMunch | @krisp, what was your question? |
13:39:18 | FromDiscord | <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:09 | FromDiscord | <mratsim> I don't understand why you need converter from that |
13:40:37 | FromDiscord | <mratsim> or doing some(something) |
13:40:50 | * | revere joined #nim |
13:43:14 | FromDiscord | <krisppurg> sent a code paste, see https://play.nim-lang.org/#ix=2J0x |
13:44:26 | FromDiscord | <krisppurg> _ _ ^^^ |
13:46:10 | FromGitter | <ynfle> Can anyone help me with this `{.borrow.}` https://play.nim-lang.org/#ix=2J0z? |
13:46:32 | FromDiscord | <lqdev> sent a code paste, see https://play.nim-lang.org/#ix=2J0A |
13:46:42 | FromDiscord | <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:56 | FromDiscord | <lqdev> mratsim please no |
13:46:59 | FromDiscord | <mratsim> though @lqdev solution is better |
13:47:12 | FromDiscord | <lqdev> don't encourage him to use term rewriting templates when there clearly exist much simpler solutions |
13:47:13 | FromDiscord | <krisppurg> I mean for example |
13:47:35 | FromDiscord | <dom96> That but don't name the constructor `embed`, either `initEmbed` or `newEmbed` |
13:47:38 | FromDiscord | <krisppurg> embed is an example of specifying so much `some`s |
13:47:47 | FromDiscord | <dom96> (`new` for ref objects) |
13:48:06 | FromDiscord | <lqdev> @dom96 why? |
13:48:31 | FromDiscord | <lqdev> imo constructors should only be named with the `initT` convention iff they do some extra initialization logic |
13:48:43 | FromDiscord | <mratsim> @ynfle report on Github |
13:48:55 | FromDiscord | <mratsim> likely that borrow for iterators doesn't work |
13:49:07 | FromDiscord | <krisppurg> Another example is https://krisppurg.github.io/dimscord/dimscord/restapi.html#editGuild%2CRestApi%2Cstring%2Cstring |
13:49:16 | FromDiscord | <dom96> @lqdev no, the convention is to always name this way |
13:49:26 | * | Q-Master quit (Ping timeout: 256 seconds) |
13:49:27 | FromDiscord | <lqdev> but i don't like that convention. |
13:49:45 | FromDiscord | <dom96> fair enough, but that is the convention 🙂 |
13:49:59 | FromDiscord | <mratsim> there are at least one, maybe 2 RFC for that |
13:50:10 | FromGitter | <ynfle> @mratsim `pairs` works https://play.nim-lang.org/#ix=2J0E |
13:50:31 | FromDiscord | <mratsim> at status we use `proc init(T: typedesc, a: int, b:float, c:string): T` convention. |
13:50:47 | FromDiscord | <mratsim> so taht you can use Embed.init(a, b, c) |
13:51:10 | FromDiscord | <haxscramper> I use `make` too, and `ć͘͡҉̗̝̼o̸̵̴n̷̛̟d̷̶̡é́͜n͍͟͝s̷̺͝e̶̻͝` |
13:51:26 | FromDiscord | <mratsim> maybe items doesn't use lent return value then? |
13:51:26 | FromDiscord | <haxscramper> `makeRect` |
13:51:34 | FromDiscord | <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:40 | FromDiscord | <lqdev> well it does have a lot of fields and thus proc params but compilers are smart enough to inline that anyways |
13:53:02 | FromDiscord | <krisppurg> It would be a hassle to write a constructor, so why not a simple solution. |
13:53:21 | FromDiscord | <lqdev> well you're saying it's a hassle to write `some` everywhere |
13:53:26 | FromDiscord | <lqdev> you can always just macro it |
13:53:29 | FromDiscord | <krisppurg> Yes |
13:54:19 | FromDiscord | <krisppurg> how could I? |
13:55:28 | FromDiscord | <krisppurg> re |
13:55:35 | FromDiscord | <krisppurg> (edit) "re" => "re: ^" |
13:55:51 | FromDiscord | <mratsim> believe me, it's way more of a hassle to hunt down converter / autocovnersion bugs |
13:56:10 | FromDiscord | <mratsim> write a macro that overload with a default parameter |
13:57:07 | FromGitter | <ynfle> @mratsim https://nim-lang.org/docs/iterators.html#items.i%2Cseq%5BT%5D |
13:57:27 | FromDiscord | <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:49 | FromGitter | <ynfle> Was that for me? |
13:57:59 | FromDiscord | <mratsim> you can use that as a base to create a proc or template that put the needed "some" |
13:58:18 | FromGitter | <ynfle> I'm guessing not |
13:58:45 | FromDiscord | <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:44 | FromDiscord | <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:08 | FromDiscord | <krisppurg> instead of body.add use newCall |
14:02:24 | FromDiscord | <krisppurg> What does overloaded name supposed to mean? |
14:02:30 | FromDiscord | <mratsim> the best way to learn is to use echo "treerepr" to see the before/after |
14:02:49 | FromDiscord | <mratsim> echo node.treerepr |
14:02:56 | FromDiscord | <shadow.> mratsmim newCall ident is deprecated |
14:03:02 | FromDiscord | <shadow.> use newCall(string, untyped) |
14:03:37 | FromGitter | <ynfle> @mratsim https://github.com/nim-lang/Nim/blob/version-1-4/lib/system/iterators.nim#L1 |
14:03:40 | FromDiscord | <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:49 | FromDiscord | <mratsim> @shadow. Ah thanks |
14:03:52 | FromDiscord | <shadow.> np |
14:04:01 | FromDiscord | <krisppurg> So proc name? |
14:04:06 | FromDiscord | <shadow.> yup |
14:04:16 | FromDiscord | <shadow.> newCall("echo", newLit("hello, world")) |
14:04:26 | FromDiscord | <shadow.> what kind of macro are you making again? |
14:04:30 | FromDiscord | <shadow.> im sure i could contribute |
14:04:45 | FromDiscord | <mratsim> something to remove noisy "some" in a constructor |
14:05:04 | FromDiscord | <mratsim> but not having to define a proc each time we want a "someless" constructor |
14:05:07 | FromDiscord | <shadow.> nono i knew that but |
14:05:10 | FromDiscord | <shadow.> how would that be accomplished |
14:05:25 | FromDiscord | <mratsim> @ynfle, yes but why is it lent2 and not lent |
14:05:47 | FromGitter | <ynfle> :shrug: |
14:06:00 | FromGitter | <ynfle> I guess that's why it can't borrow |
14:06:00 | FromDiscord | <krisppurg> im confused still, do I have to make the constructor? |
14:06:02 | * | tane joined #nim |
14:06:04 | FromDiscord | <mratsim> you take the base proc or type or expression and you replace arguments by some arg |
14:06:15 | FromDiscord | <mratsim> probably not |
14:06:33 | FromDiscord | <mratsim> you can do "somify(Embed(foo: a, bar: b, ...))" |
14:06:48 | FromDiscord | <mratsim> with somify being a macro that rewrites the expression with some |
14:07:38 | FromDiscord | <mratsim> so transforms that to: Embed(foo: some a, bar: some b, ...) |
14:07:47 | FromDiscord | <krisppurg> right |
14:07:48 | FromDiscord | <mratsim> it can be AoC day 21 😉 |
14:08:01 | FromGitter | <ynfle> @mratsim, it was actually to fix your issue https://github.com/nim-lang/Nim/issues/14421 |
14:08:03 | disbot | ➥ `items` is 20%~30% slower than iteration via an index ; snippet at 12https://play.nim-lang.org/#ix=2J0N |
14:08:45 | FromGitter | <ynfle> https://github.com/nim-lang/Nim/pull/14447 |
14:08:46 | disbot | ➥ fix #14421 items uses lent T ; snippet at 12https://play.nim-lang.org/#ix=2pTy |
14:08:53 | FromDiscord | <mratsim> ah i see it's backward compat https://github.com/nim-lang/Nim/pull/14447/files#diff-c22ce16c62c4ea2da575b120827e8f0a21bfb4156d370c9492fa31db56b78d5aR1 |
14:08:54 | disbot | ➥ fix #14421 items uses lent T ; snippet at 12https://play.nim-lang.org/#ix=2pTy |
14:09:39 | * | revere quit (Quit: quit) |
14:09:49 | FromDiscord | <krisppurg> Right |
14:17:45 | Fish-Face | I started trying to use `nimeval` to do day 19 part 2 but it seems like a terrible idea |
14:18:07 | narimiran | Fish-Face: what did you use for d19p1? |
14:18:24 | Fish-Face | npeg + render to regex |
14:18:58 | narimiran | Fish-Face: do you want some hints for pt.2? |
14:19:14 | Fish-Face | Only nim-related hints I think |
14:19:23 | Fish-Face | although |
14:19:43 | narimiran | i think you need to realize what do new rules really do |
14:20:03 | FromDiscord | <flywind> Does vmops work in JS backend? |
14:20:18 | FromDiscord | <flywind> !eval import math; static: echo arctan2(0.0, -1.0) |
14:20:20 | NimBot | <no output> |
14:20:56 | FromDiscord | <flywind> For example, this doesn't work with `nim js -r` and gives `Error: cannot 'importc' variable at compile time; arctan2`. |
14:21:31 | Fish-Face | if 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:45 | Fish-Face | but maybe I just screwed it up |
14:22:30 | narimiran | Fish-Face: for pt.2, you need to do it manually first - to realize what's going on there |
14:22:48 | Fish-Face | do what manually? expand the new rules a few times? |
14:23:09 | * | revere joined #nim |
14:23:12 | narimiran | i 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:44 | Fish-Face | I 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:28 | narimiran | ok, half-way there ;) |
14:25:42 | narimiran | "...and where do they occur" |
14:26:15 | Fish-Face | one after the other, which is the other thing I was saying with the a^n stuff :P |
14:26:35 | Zevv | I had an interesting experience with 19 |
14:26:47 | Fish-Face | hence my question of whether the language is in fact regular, in spite of the "same number of..." appearing :P |
14:26:47 | Zevv | I rewrote my input to an nepg grammar in vi |
14:26:48 | Zevv | ran it |
14:26:50 | Zevv | and got the wrong answer |
14:27:04 | Zevv | but I got so nauseous looking at the aaabbabababaabaaabaa that I gave up debugging |
14:27:26 | Fish-Face | Zevv: because PEGs are deterministic, basically I think |
14:28:00 | Zevv | that was my idea, but then I propably didn't read the assignment properly |
14:28:03 | Zevv | that's usually my problem |
14:28:09 | Zevv | I start coding and read after |
14:28:22 | Fish-Face | I 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:03 | Fish-Face | that's why I was trying to rewrite to `nimly` since it's a BNF parser rather than PEG |
14:29:18 | Fish-Face | but I wanted to do it programmatically rather than in vi :P |
14:29:46 | Zevv | well, the thing is: it's not documented, but you can build npeg grammars programmatically |
14:29:53 | Zevv | that's what npeg does when it parses the grammar |
14:30:11 | Fish-Face | hmm, but doesn't `npeg` have the same issue that it is deterministic? |
14:30:20 | Zevv | so you can do `let a = newPat("a"); let b = newPat("b"); let c = a * a * b * b * b` |
14:30:27 | Zevv | then c is a grammar that matches "aabbb" |
14:30:31 | Zevv | yes it does |
14:30:38 | Zevv | so that's out. It would have been fun though :) |
14:30:42 | Fish-Face | yeah |
14:30:49 | Fish-Face | that's useful to know though |
14:31:02 | Fish-Face | I used `pegs` because the primary interface is run-time :P |
14:31:04 | Zevv | when all you have is npeg, everything looks like a grammar |
14:31:16 | Zevv | sure pegs is better suited here |
14:31:17 | Fish-Face | wee-eell, this *is* a grammar question we're talking about! |
14:31:29 | Zevv | :) |
14:31:34 | Fish-Face | but I think narimiran is trying to say that the language might actually be regular |
14:31:59 | Zevv | I saw a 12 line python version that made me pretty angry |
14:32:07 | Fish-Face | oh? |
14:32:29 | narimiran | Zevv: because it could be done in 11 lines? |
14:32:34 | Zevv | haha |
14:33:02 | Zevv | anyway, 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:10 | Zevv | for me it's less error prone than split() etc |
14:33:16 | Fish-Face | heheh |
14:33:29 | Zevv | I just did today in my lunch break |
14:33:46 | Fish-Face | I am 1.5 hours into my lunch break |
14:33:50 | Fish-Face | should probably go back to work |
14:33:56 | Zevv | I skipped a few days tho |
14:33:59 | Fish-Face | have been looking at 19 tho |
14:34:00 | Zevv | yesterday looked fun |
14:34:03 | FromDiscord | <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:16 | Fish-Face | 20 part 2 is annoying because it involves rotating stuff |
14:34:28 | FromDiscord | <Shucks> Whats the reason of using `when true:` or `when false:` blocks? Saw them on github and stdlib sometimes. |
14:34:35 | Zevv | rotating by 90° is trivial |
14:34:52 | Zevv | Shucks: usually leftovers from debugging |
14:34:58 | Zevv | its like #if 1 or #if 0 |
14:35:14 | Fish-Face | it's not that it's hard it's just annoying and error-prone |
14:35:15 | narimiran | Zevv: yesterday looked fun?? |
14:35:21 | Zevv | no? |
14:35:30 | Zevv | I have the solution in my head |
14:35:37 | narimiran | Zevv: for pt.1 or pt.2? |
14:35:42 | Zevv | haven't seen pt 2 |
14:35:47 | narimiran | lol |
14:35:52 | Zevv | but for 1 I'd create an int for each possible of the 8 edges of a tile |
14:35:52 | Fish-Face | pt 1 is fine |
14:35:57 | Zevv | and then match up by indexing edges |
14:35:58 | Zevv | what was 2? |
14:36:05 | Fish-Face | you have to actually construct the map |
14:36:08 | narimiran | pt.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:09 | Fish-Face | rotate all the tiles correctly |
14:36:15 | Fish-Face | narimiran: yes indeed |
14:36:30 | Fish-Face | another situation where there is a HUGE shortcut not specified in the text :P |
14:36:45 | Fish-Face | and in fact pt2 also benefits from that |
14:37:11 | narimiran | i haven't solve pt.2 as it looks like too much work |
14:37:17 | Fish-Face | but I did not finish writing the solver for part 2 |
14:37:19 | Zevv | For #1 you would just find the tiles with edges that don't match, right |
14:37:29 | narimiran | Zevv: almost there |
14:37:33 | Fish-Face | more or less |
14:37:53 | Zevv | but 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:55 | Fish-Face | the shortcut being there's no guarantee in the text that there are any tiles with non-matching edges |
14:38:02 | Fish-Face | there are no duplicates |
14:38:10 | Zevv | then it's not "hard" as such |
14:38:23 | Fish-Face | yes. just annoying and error-prone :) |
14:38:29 | Zevv | pick a tile, place it at 0, 0, and for each of the neighbours find a matching tile in the list you collected |
14:38:34 | Zevv | sure, error-prone, I believe that :) |
14:38:57 | Fish-Face | in particular you have to track your rotations and flips |
14:39:15 | Zevv | no you don't. You can create 8 permutations of each tile and index on each of the "8" edges |
14:39:21 | Zevv | and then handle them as individual tiles. |
14:39:30 | Zevv | only thing is: if you use 1 of the 8, you discard the other 7 |
14:39:39 | Fish-Face | hmph |
14:39:46 | Zevv | not? |
14:39:47 | Fish-Face | I don't like the memory inflation :P |
14:39:54 | Zevv | masochist |
14:39:55 | Fish-Face | yes |
14:40:24 | Fish-Face | it was also masochistic to do AoC in a language I never heard of before December |
14:40:29 | Fish-Face | :D |
14:40:42 | Zevv | and, how does that work for you |
14:41:03 | Zevv | I 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:09 | Zevv | you just get chased over the stdlib |
14:41:32 | * | abm joined #nim |
14:42:01 | Fish-Face | I am collecting a list of irritations as I go |
14:42:14 | Zevv | there's a few |
14:42:15 | narimiran | Fish-Face: how large is it? |
14:42:22 | Fish-Face | not that large |
14:42:33 | Zevv | the bad thing is that most people seem to just learn to live with those |
14:43:12 | Zevv | http://zevv.nl/div/grammar.png |
14:43:33 | Fish-Face | I think the biggest thing is the conflation of mutability and reference semantics in function parameters |
14:44:01 | Zevv | does that actually bite you? |
14:44:14 | narimiran | Zevv: btw, here's my first ever npeg usage: https://github.com/narimiran/AdventOfCode2020/blob/master/nim/day19.nim |
14:44:29 | Zevv | good boi, you'll get the hang of it |
14:44:39 | Zevv | did it hurt? |
14:44:40 | Fish-Face | it has done. I think you could just deal with it by copying the value within the function but it seems janky |
14:45:07 | narimiran | Zevv: a bit, but that was me shooting myself |
14:45:08 | FromDiscord | <Rika> well i dont understand how mutability and reference semantics are supposed to be separated |
14:45:10 | Fish-Face | also some things go weird if you use reference types. I don't know why you have to define `$` for instance |
14:45:15 | Zevv | I wonder; I used to be bothered but I kind of forgot about that |
14:45:21 | narimiran | Zevv: plan to learn it a bit more and (ab)use it for other AoC tasks |
14:45:41 | Zevv | narimiran: https://github.com/zevv/aoc2020/blob/master/21/main.nim |
14:45:50 | Zevv | Fish-Face: "go weird"? |
14:45:54 | Fish-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:56 | narimiran | Zevv: yeah, already took a peek at that |
14:46:03 | FromDiscord | <Quibono> How do you deserialize a seq that contains both some of ObjectA and ObjectB? |
14:46:19 | Zevv | Fish-Face: /to me/ is your problem then? |
14:46:27 | FromDiscord | <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:34 | Zevv | It's a C++ & |
14:46:36 | Zevv | no more, no less |
14:46:43 | Fish-Face | which is called a `ref`erence :) |
14:46:44 | Zevv | it's *literally* that, if you look at the generated source |
14:46:56 | * | JustTakingALook joined #nim |
14:47:05 | Zevv | yeah but no one says that we should use the same nomenclature as C++ does |
14:47:16 | Zevv | it's the semantics and some words. |
14:47:23 | Zevv | a "ref" is a "traced pointer" (?) here |
14:47:31 | Zevv | how do you call that in c++? |
14:47:33 | * | xet7 quit (Quit: Leaving) |
14:47:36 | Fish-Face | he |
14:47:37 | Fish-Face | h |
14:47:41 | FromDiscord | <Rika> smart prolly |
14:48:07 | FromDiscord | <Rika> im not sure why it doesnt make sense |
14:48:12 | Zevv | so, I don't think this annoyence is one that will stick. It's just something to make your own |
14:48:12 | FromDiscord | <Rika> to you i mean |
14:48:32 | Zevv | I guess that it's hard to unlearn things |
14:48:36 | Zevv | harder then learning, typically |
14:48:53 | Zevv | so if it's called a "reference" in your head, yeah, that'll take some more effort |
14:48:54 | FromDiscord | <Rika> true |
14:49:00 | FromDiscord | <Rika> makes sense |
14:49:05 | Zevv | and "var" is maybe a bad choice, I don't know. But for me it's no problem |
14:49:36 | Fish-Face | I 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:57 | FromDiscord | <Rika> that doesnt make sense to me now |
14:50:03 | Fish-Face | it's not that big a deal though. |
14:50:04 | Zevv | right, so the re-use of "var" is the problem here |
14:50:10 | Zevv | it's the same word having two distinct meanings |
14:50:11 | Fish-Face | Zevv: I think so yes |
14:50:19 | FromDiscord | <Rika> thats understandable |
14:50:19 | Zevv | well, luckily we don't have "static" in C |
14:50:23 | Fish-Face | HAH |
14:50:25 | FromDiscord | <Rika> lol static |
14:50:27 | Zevv | meaning, like, 5 different things? |
14:50:32 | FromDiscord | <Rika> absolute pain to understand |
14:50:35 | Fish-Face | that keyword is an abomination |
14:50:57 | Zevv | well, I guess they did that deliberately to not pollute the keyword name space |
14:51:04 | Fish-Face | I remember at some point finding out about another usage of it. I'd already used C, albeit not much, for some years |
14:51:17 | Fish-Face | but that was a true WTF moment |
14:51:41 | Zevv | I had one of those when we had a discussion among collueges on different ways for initialization in C++ we could think of |
14:52:29 | Zevv | /why/ so many. |
14:53:09 | Zevv | ah here it is: https://mikelui.io/2019/01/03/seriously-bonkers.html |
14:53:16 | Fish-Face | I 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:36 | Zevv | yeah, but I only have that 4 weeks a year |
14:54:00 | Zevv | typically from dec 1 to dec 24 |
14:54:28 | Zevv | Nim is not very strong yet on the fp front. Lot of this stuff is not properly optimized and causes copies |
14:54:35 | Zevv | ~repo zerofunctional |
14:54:35 | disbot | no footnotes for `repo`. 🙁 |
14:54:38 | Zevv | !repo zerofunctional |
14:54:39 | disbot | no results 😢 |
14:54:41 | Zevv | what |
14:54:52 | Zevv | !repo zero-functional |
14:54:53 | disbot | https://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:00 | Fish-Face | hehe |
14:56:37 | FromDiscord | <Rika> !repo zero_functional |
14:56:37 | disbot | https://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:42 | FromDiscord | <Rika> ????????????????????????????? |
14:56:53 | FromDiscord | <Rika> also sequtils has an any |
14:56:54 | FromDiscord | <Rika> and an all |
14:57:02 | FromDiscord | <Rika> not sure if math has a sum though |
14:57:14 | Zevv | math has sum |
14:57:30 | FromDiscord | <Rika> prolly does but you need to make sure the seq's inner type can fit the sum |
14:57:34 | Zevv | and indeed we have all and any |
14:57:47 | FromDiscord | <Rika> but yeah i wish we had better fp |
14:57:47 | Zevv | The toSeq is annoying, it's a limitation of the uniform call thingy |
14:58:04 | FromDiscord | <Rika> the ufcs toSeq issue i hear should be fixed soon? |
14:58:12 | FromDiscord | <Rika> but i dont know for i am not smart |
14:58:44 | Fish-Face | yeah I figured at least some of those things would be in other bits of the stdlib I hadn't found yet |
14:59:30 | FromDiscord | <Rika> i tried reading all of the docs i could find and now i have a big brain xddddd |
14:59:37 | FromDiscord | <Rika> (i kid, i am very dumb) |
14:59:46 | narimiran | Fish-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:31 | Fish-Face | I'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:37 | Fish-Face | either that or assumed it was in sequtils |
15:00:43 | Fish-Face | if anywhere |
15:01:43 | * | PMunch quit (Quit: leaving) |
15:01:50 | FromDiscord | <shadow.> is ufcs limited in pragmas as well? |
15:02:05 | FromDiscord | <shadow.> bc i've noticed i can do `{.pragma(a).}` but not `{.a.pragma.}` |
15:02:11 | FromDiscord | <Rika> that's just cursed |
15:02:15 | FromDiscord | <shadow.> well |
15:02:18 | FromDiscord | <Rika> absolutely cursed |
15:02:25 | FromDiscord | <shadow.> its for dimscord and i wanted to be able to do `{.discord.event.}` |
15:02:28 | FromDiscord | <Rika> i believe so |
15:02:33 | FromDiscord | <shadow.> instead of `{.event(discord).}` |
15:02:34 | FromDiscord | <Rika> since pragmas are just macros sometimes |
15:02:38 | FromDiscord | <shadow.> hmm |
15:02:41 | FromDiscord | <shadow.> last time it didn't work |
15:02:44 | FromDiscord | <shadow.> i suppose i'll do more testing |
15:03:00 | FromDiscord | <Rika> i mean "i believe so" to this |
15:03:04 | FromDiscord | <shadow.> ohhh |
15:03:34 | Fish-Face | right |
15:03:38 | Fish-Face | I will stop slacking so much |
15:04:09 | FromDiscord | <shadow.> sent a code paste, see https://play.nim-lang.org/#ix=2J1m |
15:05:57 | * | Kaivo quit (Quit: WeeChat 2.9) |
15:07:13 | FromDiscord | <dom96> I prefer `event(discord)` 🙂 |
15:07:26 | FromDiscord | <shadow.> rly? |
15:07:28 | FromDiscord | <shadow.> fair enough lol |
15:13:03 | * | leorize quit (Ping timeout: 240 seconds) |
15:13:22 | Evolver | As I am learning Nim, I am going to start posting generalized questions and their answers on StackOverflow. |
15:13:29 | FromDiscord | <shadow.> lol good idea |
15:13:34 | FromDiscord | <shadow.> or make a website |
15:13:36 | Evolver | Don't downvote me please |
15:13:36 | FromDiscord | <shadow.> using jester 😉 |
15:13:57 | FromDiscord | <shadow.> you could make like a |
15:14:01 | FromDiscord | <shadow.> nim tutorial faq |
15:14:02 | FromDiscord | <shadow.> or something |
15:14:14 | FromDiscord | <Rika> downvoted, duplicate of |
15:14:34 | Evolver | If 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:16 | FromDiscord | <Clyybber> yeah I need to finish up my PR |
15:16:22 | FromDiscord | <shadow.> Evolver: that's true |
15:20:32 | FromDiscord | <krisppurg> what do I put in the second param? (`_`) |
15:21:37 | FromDiscord | <mratsim> you replace by the param a, b, c you collected in someify(Embed(fieldA: a, fieldB: b, fieldC: c, ...)) |
15:22:10 | FromDiscord | <krisppurg> ? |
15:22:48 | FromDiscord | <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:22 | FromDiscord | <mratsim> you will see that the a b c that you need have some structure |
15:23:23 | FromDiscord | <krisppurg> well I mean what do I need to exactly put in newCall |
15:23:35 | FromDiscord | <krisppurg> shadow pointed it out what you provided was deprecated |
15:23:47 | FromDiscord | <mratsim> you need to get them and put them in that newCall |
15:24:03 | FromDiscord | <krisppurg> get the params? |
15:24:07 | FromDiscord | <mratsim> yes |
15:24:13 | FromDiscord | <krisppurg> from where? |
15:24:24 | FromDiscord | <mratsim> from "Embed(fieldA: a, fieldB: b, fieldC: c, ...)" |
15:24:48 | FromDiscord | <mratsim> your macro will transform that into "Embed(fieldA: some a, fieldB: some b, fieldC: some c, ...)" |
15:25:14 | FromDiscord | <krisppurg> newCall("some", a, b, c) |
15:25:22 | FromDiscord | <mratsim> no |
15:25:50 | FromDiscord | <mratsim> it needs to be newCall("some", a) then newCall("some", b) then newCall("some", c) |
15:26:10 | FromDiscord | <krisppurg> right |
15:26:12 | FromDiscord | <mratsim> those a b c are at some index of the ast[i] |
15:26:21 | FromDiscord | <mratsim> so you will have a for loop |
15:26:52 | FromDiscord | <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:02 | FromDiscord | <mratsim> and you use treeRepr to get a representation of the AST |
15:27:14 | FromDiscord | <krisppurg> https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/linear_algebra/helpers/overload.nim#L17 |
15:27:31 | FromDiscord | <mratsim> this is for a proc |
15:27:50 | FromDiscord | <mratsim> but if you don't want a proc and directly transform an constructor call the AST is different |
15:28:28 | FromDiscord | <mratsim> you can use "dumpTree: Embed(foo: a, bar: b, baz: c)" to get an idea |
15:28:46 | FromDiscord | <mratsim> or within a macro: "echo treeRepr(myAst)" |
15:29:11 | FromDiscord | <juliuskiesian> i see. |
15:30:18 | FromDiscord | <juliuskiesian> sent a code paste, see https://play.nim-lang.org/#ix=2J1r |
15:30:24 | FromDiscord | <juliuskiesian> that's the Genome type. |
15:30:45 | FromDiscord | <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:38 | FromDiscord | <mratsim> then you reconstruct the Embed call with the "some" instead of plain parameters |
15:31:58 | FromDiscord | <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:13 | FromDiscord | <mratsim> if you can wait a hour I'll show you |
15:32:20 | FromDiscord | <krisppurg> right |
15:32:28 | FromDiscord | <mratsim> ping me if I forget |
15:32:30 | FromDiscord | <juliuskiesian> @mratsim Direction is just an enum. |
15:32:35 | FromDiscord | <krisppurg> sure. |
15:33:41 | FromDiscord | <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:36 | FromDiscord | <juliuskiesian> hm, sorry for the bad naming, dnaSeq is actually an array. |
15:36:45 | FromDiscord | <mratsim> array are fine as well |
15:37:18 | FromDiscord | <juliuskiesian> sent a code paste, see https://play.nim-lang.org/#ix=2J1v |
15:37:19 | FromDiscord | <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:00 | FromDiscord | <mratsim> before optimizing though, you should ensure that your code is correct and have a test suite |
15:38:14 | FromDiscord | <mratsim> then benchmarks to make sure it's useful. |
15:44:30 | jken | I 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:00 | FromDiscord | <haxscramper> `for i in countdown(width - 1, 1)` |
15:45:53 | FromDiscord | <haxscramper> It yields all values including first and last, just like `..` |
15:46:11 | FromDiscord | <haxscramper> Though IMO `..` should just work for reversed ranges |
15:48:04 | * | Vladar quit (Quit: Leaving) |
15:48:12 | FromDiscord | <Rika> I don't actually understand why it does not |
15:49:19 | FromDiscord | <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:08 | FromDiscord | <Rika> Man someone needs to document where all these magics come from |
15:51:32 | FromDiscord | <haxscramper> `mDotDot, # this one is only necessary to give nice compile time warnings` |
15:56:15 | FromDiscord | <dom96> The magics are fairly easy to find, just search for `m` + the name of the magic in the compiler |
15:59:32 | FromDiscord | <hotdog> Anyone here using Tabnine pro with Nim? If so would you recommend it? |
16:00:34 | FromGitter | <bung87> no, I remember it use about 2gb ram right ? |
16:01:35 | FromDiscord | <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:20 | Oddmonger | arrrhhh … just try « nim game javascript » in your favorite search engine, and all you get is « game of nim » written in javascript |
16:03:23 | FromGitter | <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:05 | FromDiscord | <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:22 | FromDiscord | <dom96> And I couldn't figure it out how to disable it in comments which had the same problem |
16:13:57 | FromDiscord | <krisppurg> in general how many lines should a nim file have? recommended |
16:15:17 | FromDiscord | <mratsim> Personally anything between 200-1000 lines |
16:15:34 | FromDiscord | <mratsim> I like to access any part of the code in 3 scrolls maximum |
16:18:14 | FromDiscord | <krisppurg> what about how many files? |
16:20:07 | FromDiscord | <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:41 | FromDiscord | <haxscramper> Well, it depends on how many things you have of course |
16:24:22 | FromDiscord | <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:30 | FromDiscord | <haxscramper> And then go from this |
16:24:55 | * | leorize joined #nim |
16:24:58 | FromDiscord | <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:40 | FromDiscord | <mratsim> java issue is the directory nesting |
16:38:41 | disruptek | mratsim: as i said, you have to convince me that the state machine composes as elegantly as just doing transfers via types. 😉 |
16:38:45 | FromDiscord | <mratsim> I'd rather have a mess in the same folder like here: https://github.com/libtom/libtommath/ |
16:39:00 | FromDiscord | <haxscramper> Java issue is class implementations with 47 lnies |
16:39:11 | FromDiscord | <haxscramper> in addition to directory nesting |
16:39:19 | FromDiscord | <mratsim> well I don't implement Java, I only try to scan through the code :p |
16:39:39 | FromDiscord | <mratsim> Carpal Tunnel syndrome is because of Java directories |
16:39:39 | FromDiscord | <haxscramper> Neither do I, but when some paper has implementation in java |
16:39:53 | FromDiscord | <haxscramper> Because apparently this is the language for parsers |
16:39:59 | FromDiscord | <haxscramper> I want to kill myself |
16:40:02 | FromDiscord | <mratsim> wait what? |
16:40:13 | FromDiscord | <mratsim> a language with no ADT? |
16:40:24 | FromDiscord | <mratsim> I thought it was OCaml |
16:40:27 | FromDiscord | <haxscramper> Well, not really, but for some reason almost everything I've read for source diffing had example in C++ or java |
16:40:49 | FromDiscord | <haxscramper> And just unimaginable amount of thigns written in java for parser etc. |
16:40:49 | FromDiscord | <mratsim> likely because of Eclipse sponsored research |
16:41:13 | FromDiscord | <haxscramper> LLVM is written in OOP-heavy C++ and that speaks a lot about need for ADT |
16:41:27 | FromDiscord | <mratsim> they emulate ADTs with visitors |
16:41:35 | FromDiscord | <mratsim> well double dispatch |
16:42:02 | FromDiscord | <haxscramper> This is not ADT, it is just ad-hoc implementation of closed object hierarchies |
16:42:13 | FromDiscord | <haxscramper> wrong wording |
16:43:04 | FromDiscord | <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:18 | FromDiscord | <haxscramper> AST and beyond |
16:43:54 | FromDiscord | <mratsim> The OOP approach is really plugging the ADT hole. |
16:44:03 | FromDiscord | <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:12 | FromDiscord | <haxscramper> > inside my macro |
16:44:22 | FromDiscord | <haxscramper> I just nearly choked on this |
16:44:29 | FromDiscord | <sealmove> haha |
16:44:38 | FromGitter | <bung87> @mratsim I check chronos testasyncstream.nim when use the TLSServerAsyncStream then the wrapped transport not touch anymore ? |
16:44:57 | FromDiscord | <mratsim> accept the template name as an untyped parameter, use getAst and regenerate a fresh template |
16:45:11 | FromDiscord | <sealmove> the template name is not a problem |
16:45:14 | FromDiscord | <sealmove> it can be fixed |
16:45:31 | FromDiscord | <mratsim> @Bung87, ask in the #async channel of Nimbus: https://discord.gg/N35rMFrB |
16:45:33 | FromDiscord | <sealmove> so I can just generate a template call? |
16:46:00 | FromDiscord | <mratsim> with getAST |
16:46:04 | FromDiscord | <mratsim> or quote do magic |
16:46:16 | FromDiscord | <mratsim> sorry "regenerate a fresh template" is wrong |
16:46:17 | FromGitter | <bung87> @mratisim thanks! |
16:51:40 | FromDiscord | <sealmove> mratsim getAst on what? |
16:51:57 | FromDiscord | <haxscramper> On template that you passed as argument |
16:52:12 | FromDiscord | <haxscramper> You need to accept `userTemplate: typed` and then |
16:52:31 | FromDiscord | <haxscramper> `userTemplate.getAst()` as long as it resolved correctly |
16:53:11 | FromDiscord | <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:50 | FromDiscord | <sealmove> what I wonder is if I can just generate a template call and pass it a NimNode. |
16:54:41 | FromDiscord | <haxscramper> Just `newCall("yourTemplate", argumentNode)` then |
16:54:57 | FromDiscord | <sealmove> ok, if this works then great |
16:54:58 | FromDiscord | <haxscramper> Will generate `yourTemplate(<what-was-inside-argumentNode>)` |
16:55:24 | FromDiscord | <shadow.> @krisppurg you still confused w the macros? |
16:55:25 | FromDiscord | <shadow.> i can help |
16:59:00 | FromDiscord | <sealmove> why do I get 'undeclared identifier' inside a template? do I need to mark it as dirty or something? |
16:59:38 | FromDiscord | <haxscramper> If you use something defined outside of a template you might need to `{.inject.}` it |
16:59:43 | FromDiscord | <haxscramper> But better show the code |
17:00:02 | FromDiscord | <sealmove> yeah I probably need this. btw templates can't use `quote do` right? |
17:01:11 | FromDiscord | <sealmove> oh, i can use backticks but without quote do? |
17:01:17 | FromDiscord | <mratsim> yes |
17:01:23 | FromDiscord | <mratsim> look for the identifier construction |
17:01:30 | FromDiscord | <shadow.> well a template is essentially a quote do in itself |
17:01:35 | FromDiscord | <mratsim> in macro "undeclared identifier" means that semcheck failed. |
17:01:49 | FromDiscord | <mratsim> don't worry too much about the identifier that is mentioned |
17:02:24 | FromDiscord | <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:17 | FromDiscord | <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:08 | FromDiscord | <haxscramper> `untyped` argument |
17:07:12 | * | habamax quit (Ping timeout: 256 seconds) |
17:09:33 | FromDiscord | <sealmove> eh, but it's fixed, I don't want it as parameter if possible |
17:11:57 | FromDiscord | <sealmove> hum, it works https://play.nim-lang.org/#ix=2J23 |
17:12:56 | FromDiscord | <sealmove> even this: https://play.nim-lang.org/#ix=2J25 |
17:15:36 | disruptek | mratsim: 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:07 | disruptek | this stuff is too simple to waste time with, imo. |
17:17:02 | FromDiscord | <mratsim> For chronos I don't think we'll move stuff until there is a new need i think |
17:17:31 | FromDiscord | <mratsim> but I plan to have something efficient for whatever I end up cooking |
17:34:32 | FromDiscord | <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:40 | Zevv | nice 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:09 | FromDiscord | <krisppurg> Hour has passed |
17:52:55 | * | wowi42 quit (Quit: Kowa Bunga!!!) |
17:53:40 | * | wowi42 joined #nim |
17:54:44 | FromDiscord | <sealmove> ok I am getting gcc errors for the first time 😄 |
17:55:28 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2J2g |
17:57:55 | FromDiscord | <lqdev> congratulations! you have now entered the nonsense zone |
17:58:08 | FromDiscord | <sealmove> Ikr... |
17:59:12 | FromDiscord | <sealmove> i just hope there is something wrong with my code |
17:59:50 | FromDiscord | <haxscramper> Are you assigning some kind of closure to tuple field? |
18:00:38 | FromDiscord | <haxscramper> Though most likely this is not a closure |
18:00:57 | FromDiscord | <haxscramper> IIRC they have `colonanonymous<xxxx>` |
18:01:51 | FromDiscord | <sealmove> not using any kind of closure |
18:02:09 | FromDiscord | <sealmove> I am indeed assigning to a tuple field |
18:04:44 | * | Zevv quit (Quit: Lost terminal) |
18:07:20 | FromDiscord | <sealmove> looks like a compiler bug tbh |
18:10:11 | FromDiscord | <sealmove> ok I figured it out |
18:11:13 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2J2m |
18:11:39 | FromDiscord | <mratsim> looking |
18:12:28 | FromDiscord | <sealmove> not exactly, but when I did the declaration outside the template, it worked. |
18:13:24 | FromDiscord | <haxscramper> `x` is also gensymed. Try `x {.inject.}` |
18:13:55 | FromDiscord | <sealmove> ah ok yeah that's the problem |
18:13:55 | FromDiscord | <haxscramper> But that is not guaranteed to work, it depends on what `templateCall` doe exactly |
18:14:16 | FromDiscord | <sealmove> so it's safer that i moved the declaration outside the template |
18:18:30 | * | a_chou joined #nim |
18:20:19 | FromDiscord | <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:00 | FromDiscord | <krisppurg> Thank you. |
18:51:28 | reversem3 | what is a good plotting library that I can import a csv or txt file to get a graph for work? |
18:51:45 | disruptek | !repo ggplotnim |
18:51:45 | disbot | https://github.com/Vindaar/ggplotnim -- 9ggplotnim: 11A port of ggplot2 for Nim 15 84⭐ 8🍴 |
18:53:05 | * | vicfred joined #nim |
18:53:12 | reversem3 | cool thanks |
18:53:15 | FromDiscord | <tiatomee> What's the best way to parse a string that starts with a number and then some other stuff? |
18:53:27 | disruptek | parse it how? |
18:53:32 | FromDiscord | <tiatomee> I'd have to find out the length of the digit sequence first |
18:53:42 | FromDiscord | <tiatomee> I mean a `parseInt` kind of thing |
18:53:58 | FromDiscord | <tiatomee> Ideally I'd want something like a `s.takeWhile(isDigit)` |
18:54:09 | FromDiscord | <tiatomee> and then use `parseInt` and get the rest of the string |
18:54:17 | FromDiscord | <tiatomee> but I don't see anything like `takeWhile` |
18:54:48 | disruptek | there are templates that are suitable for this in sequtils. |
18:56:34 | FromDiscord | <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:53 | FromDiscord | <tiatomee> Huh, I guess I can use `s.split(separator)` and get the two number chunks directly |
18:57:19 | FromDiscord | <haxscramper> Also https://nim-lang.org/docs/parseutils.html#skipWhile%2Cstring%2Cset%5Bchar%5D%2Cint |
18:57:22 | disruptek | in the time it has taken you to type this, you could have written the loop "by hand". |
18:57:59 | FromDiscord | <tiatomee> disruptek: sure, but I'm here to get used to the Nim API and not to speed code :P |
18:59:00 | FromDiscord | <haxscramper> Nim api is aproximately `let str = "123hello"; let intVal = parseInt(str[0..skipWhile(str, Digit))` |
18:59:51 | FromDiscord | <haxscramper> sequtils just has map/fold/filter |
19:00:15 | disruptek | well, i was thinking you'd compose as you iterate, but.. sure. |
19:00:28 | FromDiscord | <haxscramper> I'm not smart |
19:00:36 | mipri | strscans and re work as well here |
19:01:26 | FromDiscord | <haxscramper> what |
19:01:30 | FromDiscord | <haxscramper> oh |
19:01:56 | * | JustTakingALook quit (Remote host closed the connection) |
19:02:13 | FromDiscord | <mratsim> strscans is probably the simplest here |
19:02:16 | FromDiscord | <tiatomee> strscans seems very interesting! |
19:02:33 | FromDiscord | <tiatomee> Huh, doesn't seem to do unsigned numbers though |
19:02:52 | FromDiscord | <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:49 | Zevv | >+Digit * >OtherStuff |
19:14:57 | FromDiscord | <dom96> parseutils is likely even simpler |
19:18:57 | FromDiscord | <dom96> wtf no `pairs` for SharedTable? |
19:19:25 | disruptek | Zevv: so i'm starting the 2nd part of this atomics talk and it seems that lock tainting isn't supported outside C11. |
19:19:51 | disruptek | i mean, the compiler won't protect us. we have to impl it ourself. |
19:20:10 | disruptek | i'm like 9mins in fwiw. |
19:21:32 | FromDiscord | <shadow.> @mratsim @krisppurg for the someify, wouldn't it↵1. have to be recursive↵2. not someify some fields? |
19:21:47 | FromDiscord | <shadow.> because there are nested fields that need to be turned into options |
19:21:51 | FromDiscord | <shadow.> and there are fields which are not options |
19:21:53 | FromDiscord | <sealmove> @PMunch, @giaco, plugin system is implemented :> |
19:32:08 | * | PMunch joined #nim |
19:33:34 | jken | Is 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:03 | PMunch | for start in (((DEPTH*i)+i)+1)..<(((DEPTH*i)+i)+DEPTH+1) |
19:35:36 | * | hnOsmium0001 joined #nim |
19:35:47 | jken | derp, of course .. can be used that way. |
19:35:53 | jken | Thanks PMunch |
19:35:56 | PMunch | No problem .) |
19:36:18 | Zevv | disruptek: so, it's good info, right |
19:36:55 | PMunch | narimiran, @shadow., todays AoC stream is live now: https://www.twitch.tv/pmunche https://www.youtube.com/watch?v=RMJCCBviYCg |
19:37:27 | narimiran | thanks, will watch if i don't fall asleep :) |
19:39:13 | FromDiscord | <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:57 | PMunch | Uhm, what was that FromDiscord.. |
19:41:34 | FromDiscord | <dom96> Seems removing the embeds caused it |
19:41:47 | FromDiscord | <shadow.> oh bet ill watch |
19:41:48 | FromDiscord | <mratsim> @shadow. the use case @krisppurg wants has no recursivity I think |
19:42:05 | FromDiscord | <shadow.> really? in dimscord embeds some subfields need to be options as well |
19:42:06 | FromDiscord | <shadow.> iirc |
19:42:43 | FromDiscord | <mratsim> well in that case it's better to create initializer procs |
19:43:18 | FromDiscord | <shadow.> pmunch: do you have twitch chat linked this time? |
19:43:25 | FromDiscord | <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:41 | FromDiscord | <shadow.> i remember last time u had it popping up at the top as well as discord |
19:44:24 | FromDiscord | <mratsim> @Zevv now my plan is to find time to watch this one: https://www.youtube.com/watch?v=_fu0gx-xseY |
19:44:58 | FromDiscord | <mratsim> negative overhead = underhead? |
19:48:37 | FromDiscord | <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:20 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2J2X |
19:52:45 | Zevv | "negative overhead abstraction" |
19:52:46 | Zevv | right |
20:04:08 | FromDiscord | <mratsim> I don't miss static and generics type resolution bugs |
20:04:22 | FromDiscord | <mratsim> which tends to happen when working on containers |
20:04:52 | FromDiscord | <mratsim> and "toSeq" visibility issues when used in a generic proc and applied to a non-seq collection like HashSet |
20:04:54 | FromDiscord | <mratsim> grmblblbl |
20:05:07 | FromDiscord | <dom96> it was a hidden lock 🙂 |
20:05:48 | FromDiscord | <mratsim> this for example is just painful https://media.discordapp.net/attachments/371759389889003532/790671381527265330/unknown.png |
20:16:20 | narimiran | PMunch: that's not the correct solution for the example ;) |
20:17:09 | narimiran | PMunch: the solution is 5 |
20:18:01 | FromDiscord | <dom96> ugh, this rabbit hole is getting deeper and deeper |
20:20:04 | * | a_chou quit (Remote host closed the connection) |
20:21:29 | FromDiscord | <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:42 | FromDiscord | <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:56 | FromDiscord | <mratsim> @tiatomee import bitops and use popcount or countSetBits |
20:22:28 | FromDiscord | <tiatomee> Perfect, thank you! |
20:23:09 | FromDiscord | <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:17 | FromDiscord | <mratsim> disclaimer I work at Status |
20:23:50 | FromDiscord | <shadow.> im going to pr `+=, -=, and =` for hashsets, do you recommend i should do `-+-=` as well or is that too verbose |
20:24:23 | narimiran | nah, it was rejected last time i did it ;) |
20:25:17 | Prestige | what would that last one mean? |
20:25:25 | narimiran | symmetric difference |
20:25:52 | FromDiscord | <shadow.> += was rejected? |
20:25:53 | Prestige | ah. Seems odd with operators to me |
20:26:02 | FromDiscord | <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:06 | FromDiscord | <mratsim> yeah, incl/excl are fine |
20:26:39 | FromDiscord | <shadow.> nari, you did the first three? |
20:26:54 | narimiran | i think so, let me try to find it |
20:27:21 | disruptek | zevv: it's good info, but so far i'm not seeing explicit evidence that lock taint will work for us. |
20:27:23 | FromDiscord | <mratsim> @miran I think you missed my request from yesterday for a new blog post: https://gist.github.com/mratsim/61b2e25d098df0634143d501a77d8599 |
20:27:31 | narimiran | https://github.com/nim-lang/Nim/pull/7036 |
20:27:32 | disbot | ➥ `sets` assign operators |
20:27:56 | disruptek | Zevv: basically, this isn't changing any assumption of mine yet. |
20:27:58 | FromDiscord | <mratsim> disrupted: what is this lock tian you talk about? something different than the {.lock: FOo.} pragma? |
20:28:04 | FromDiscord | <mratsim> taint |
20:28:42 | disruptek | you said the c compiler was smart enough to taint accesses within a lock so that they don't cause stale cache reads. |
20:28:43 | FromDiscord | <mratsim> how do I PR this? Directly in the post folder of nim/website? |
20:29:04 | FromDiscord | <mratsim> it's the CPU |
20:29:10 | disruptek | okay. |
20:29:22 | FromDiscord | <mratsim> there are instruction called lockadd locksub etc |
20:29:30 | disruptek | we'll see i guess. |
20:29:35 | FromDiscord | <mratsim> the CPU must respect flushing/reloading cache lines |
20:29:41 | FromDiscord | <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:42 | disruptek | maybe i need to make a ticket for clyybber to tag as CPSBUG. |
20:29:46 | FromDiscord | <Recruit_main707> ? |
20:29:51 | disruptek | sure. |
20:30:02 | disruptek | it won't get unrolled, of course. |
20:30:09 | FromDiscord | <Recruit_main707> i get `Error: cannot convert seq[NimNode] to varargs[NimNode]` |
20:30:19 | FromDiscord | <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:21 | disruptek | a seq is not a NimNode. |
20:31:06 | * | lum joined #nim |
20:31:09 | FromDiscord | <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:23 | disruptek | yeah, i'm fine with that. |
20:31:39 | disruptek | so far, so good. |
20:31:44 | FromDiscord | <mratsim> Also cache coherency is formally verified nowadays 😉 |
20:31:58 | FromDiscord | <mratsim> https://lamport.azurewebsites.net/tla/intel-excerpt.html |
20:32:21 | disruptek | i guess i will watch the rest of this thing. |
20:32:51 | FromDiscord | <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:25 | FromDiscord | <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:28 | disruptek | i'm assuming we will have that, though. |
20:33:29 | FromDiscord | <Clyybber> disruptek: rejoin telegram |
20:33:38 | disruptek | wut |
20:33:39 | FromDiscord | <Clyybber> we are talking about the bug there |
20:33:39 | FromDiscord | <Recruit_main707> disruptek: then how can i pass it several NimNodes? |
20:33:51 | FromDiscord | <mratsim> seq[NimNodes] |
20:34:11 | disruptek | recruit: write a macro or change the api. |
20:34:20 | FromDiscord | <mratsim> the thing is, sequences in macro tend to become array. |
20:34:27 | FromDiscord | <mratsim> use a proc ASAP. |
20:34:28 | FromGitter | <kayabaNerve> Why does Nim 1.4 print a ton of periods? |
20:34:36 | FromDiscord | <Recruit_main707> i am in a ct proc |
20:34:40 | FromDiscord | <mratsim> ah |
20:35:12 | disruptek | kayabaNerve: it's an "upgrade" from hint[Processing]. |
20:35:36 | FromDiscord | <mratsim> varargs[NimNode] might become nnkArg while seq[NimNode] become nnkBracket |
20:35:44 | FromDiscord | <mratsim> hence the mismatch |
20:35:52 | FromDiscord | <mratsim> not sure if this was ever fixed. |
20:36:22 | disruptek | clyybber: well, talk about it here or invite me. i'd rather brush my teeth than hack telegram again today. |
20:36:45 | FromGitter | <kayabaNerve> disruptek: Thanks for the reasoning. |
20:37:02 | FromGitter | <kayabaNerve> And can Defects still be caught? They can, right? |
20:37:15 | FromGitter | <kayabaNerve> Sorry, not defects. Fatal Exceptions |
20:37:23 | FromGitter | <kayabaNerve> There may be a distinction there I'm not sure of |
20:37:48 | FromGitter | <kayabaNerve> Notably considering IndexError, which I have a ton of deprecation warnings for in front of me... |
20:38:29 | FromDiscord | <Clyybber> disruptek: nothing new really; I messaged you on telegram |
20:38:38 | FromDiscord | <Clyybber> disruptek: Its just that I don't see Araq here too often |
20:39:04 | FromGitter | <kayabaNerve> *They are now defects. IndexDefect can only be caught with panics:off... |
20:41:44 | disruptek | i'm not sure why we don't want to do CPS development in the CPS repo. |
20:41:53 | disruptek | it's designed for this and it works quite well. |
20:42:05 | disruptek | it's not like CPS is a secret. |
20:42:19 | disruptek | we can use discussions. issues. pull requests. CI. |
20:43:30 | disruptek | kayabaNerve: fatal exceptions are, by definition, fatal. |
20:43:45 | disruptek | defects no longer inherit from CatchableException. |
20:46:25 | * | Q-Master quit (Ping timeout: 240 seconds) |
20:46:25 | disruptek | this !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:07 | disruptek | feels like github changed something. |
20:47:31 | narimiran | PMunch: spoiler alert: this will be wrong |
20:49:08 | * | lum joined #nim |
20:49:41 | Zevv | who wants to see my day20 |
20:49:44 | narimiran | PMunch: you sorted the wrong thing |
20:50:23 | Zevv | 42 lines of code |
20:50:30 | narimiran | Zevv: no way |
20:51:00 | Zevv | http://zevv.nl/div/d20.png |
20:51:22 | Zevv | part 1, that is :) |
20:51:33 | narimiran | what are the arrows? |
20:51:38 | Zevv | matching edges |
20:51:49 | Zevv | I just generated a dot graph from the matching edges |
20:51:58 | * | Q-Master joined #nim |
20:53:06 | Zevv | no sea monsters yet tho :( |
20:53:07 | narimiran | Zevv: now you'll do pt.2 in no time |
20:53:24 | Zevv | no because I got the graph, but the knowledge is in dot, not in my code :) |
20:53:39 | Zevv | I lost all knowledge of the original images and the transformations |
20:53:41 | Zevv | it's just the graph |
20:53:49 | Zevv | didnt' see part II coming :) |
20:56:57 | Zevv | well, pmunch actually did the whole thing pretty compact |
20:57:10 | PMunch | It's not the whole thing :( |
20:57:13 | Zevv | ah right |
20:57:22 | PMunch | I have where each tile goes, just not rotation or flip.. |
20:57:25 | * | Q-Master quit (Ping timeout: 256 seconds) |
20:57:28 | PMunch | Wouldn't be too hard to add that though |
20:58:46 | narimiran | PMunch: regarding sorting: i've used OrderedTable, which can be sorted, made my life much easier |
20:59:14 | FromDiscord | <dom96> Why Firefox, why https://media.discordapp.net/attachments/371759389889003532/790684827816820756/unknown.png |
21:04:54 | FromDiscord | <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:40 | disruptek | i 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:53 | FromDiscord | <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:32 | FromDiscord | <dom96> yep, I also needed to write `var x = x` though inside the closureScope for some reason |
21:19:47 | FromDiscord | <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:24 | FromDiscord | <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:44 | FromDiscord | <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:03 | FromDiscord | <mratsim> some questions to sleep on @disruptek @zevv: https://github.com/nim-lang/RFCs/issues/295#issuecomment-749228257 |
22:20:04 | disbot | ➥ next steps for CPS ; snippet at 12https://play.nim-lang.org/#ix=2Gti |
22:23:06 | disruptek | i'm messing with ref-free cps. |
22:24:08 | * | Q-Master joined #nim |
22:24:09 | disruptek | it'll be a pita, no doubt. |
22:24:39 | disruptek | and it'll require "unsafe" code. |
22:24:50 | FromDiscord | <mratsim> I have some ideas about that |
22:24:59 | FromDiscord | <mratsim> but more with coroutines |
22:25:14 | FromDiscord | <mratsim> it will require alloca and "heap allocation elision" |
22:25:29 | FromDiscord | <mratsim> (i.e. the compiler tells me when something escapes its frame) |
22:25:34 | * | Jesin joined #nim |
22:25:53 | FromDiscord | <mratsim> I have yet to understand how Kotlin mixes coroutines with continuations and state machines |
22:26:15 | FromDiscord | <mratsim> going to sleep. |
22:26:26 | Zevv | ah what does "resume with input" mean |
22:26:29 | disruptek | most of your list i don't want. i want javascript -- because it proves the generality -- and i want resume on input. |
22:26:40 | Zevv | i want a lot of yesses |
22:26:40 | disruptek | there's no overhead beyond a fn() in the current cps. |
22:26:46 | Zevv | no arch asm |
22:27:07 | disruptek | compile-time, of course, because otherwise what's the point. |
22:27:18 | FromDiscord | <mratsim> the paper mentions that CPC has high overhead compared to fn call |
22:27:34 | disruptek | ignore cpc. |
22:27:42 | FromDiscord | <mratsim> compile time as in proc a() {.compileTime.} |
22:28:14 | disruptek | i 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:22 | FromDiscord | <mratsim> or static: cps() |
22:28:26 | * | Jesin quit (Remote host closed the connection) |
22:28:30 | FromDiscord | <mratsim> it's simple |
22:28:43 | FromDiscord | <juliuskiesian> what is the optimal way to invert some range of an array? |
22:28:43 | Zevv | ah what does "resume with input" mean |
22:28:46 | FromDiscord | <mratsim> 4GB, if your continuation require 100B you deduce how many you can have |
22:28:57 | disruptek | zevv: it means, iterate with this new value, etc. |
22:29:09 | disruptek | mratsim: but available memory has nothing to do with it. |
22:29:13 | Zevv | hm yes that would be nice, but not striclty required |
22:29:38 | disruptek | i hate to say i require it, but i will probably demand it in whatever i use. |
22:29:39 | FromDiscord | <juliuskiesian> for example, given [1, 2, 3, 4, 5], invert the range 1..3, you get [1, 4, 3, 2, 5]. |
22:30:19 | FromDiscord | <mratsim> use a var openarray |
22:30:35 | FromDiscord | <sealmove> how to traverse an ordered table in reverse order? |
22:30:47 | FromDiscord | <ElegantBeef> Isnt a `var openArray` expiremental? 😄 |
22:30:56 | FromDiscord | <mratsim> convert to seq or sort it in reverse @sealmove |
22:31:10 | FromDiscord | <mratsim> no, it has been working for years |
22:31:20 | FromDiscord | <sealmove> algorithm.reverse will work? |
22:31:27 | FromDiscord | <mratsim> what's experimental is first class var and first class openarrays (aka view types) |
22:31:38 | FromDiscord | <mratsim> reverse requires an openarray |
22:31:39 | FromDiscord | <ElegantBeef> Yea i thought you meant a view |
22:31:50 | * | Jesin joined #nim |
22:31:52 | FromDiscord | <mratsim> you neet to pass a compare function to OrderedTable.sort |
22:31:53 | disruptek | i think frosty is a good showcase example. |
22:31:56 | FromDiscord | <mratsim> or convert to seq |
22:32:07 | FromDiscord | <sealmove> and there is no way to index it and get a tuple? 😐 |
22:32:09 | disruptek | maybe zevv has something meaty. |
22:32:27 | FromDiscord | <ElegantBeef> What do you want seal? |
22:32:43 | disruptek | but this ref thing... it's pretty gnarly. |
22:33:25 | FromDiscord | <sealmove> nothing, I probably need an array of tuple instead of an ordered table |
22:33:38 | FromDiscord | <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:39 | FromDiscord | <bark> is casting to byte address the best way to do pointer arithmetic 🤔 |
22:46:35 | FromDiscord | <ElegantBeef> Why are you wanting to do pointer arithmetic? |
22:47:20 | FromDiscord | <bark> for now just learning, eventually mayhaps a custom seq type optimized for looking up the last value |
22:47:37 | FromDiscord | <bark> or some other datatypes fine tuned for certain operations |
22:47:56 | FromDiscord | <bark> looking up the last value shouldn't be too bad anyways 🤔 with nim's seq |
22:47:57 | FromDiscord | <ElegantBeef> well we've got `ptr UncheckedArray[T]`, which means you can just offset the access manually |
22:48:37 | FromDiscord | <ElegantBeef> But i suppose casting to a `int` then offsetting then casting back to a `ptr T` might work 😄 |
22:49:05 | FromDiscord | <bark> I'm doing that except I'm casting to byte address |
22:49:10 | FromDiscord | <bark> it works okay I suppose |
22:49:41 | FromDiscord | <bark> well ByteAdress = int in the end anyways |
22:51:42 | FromDiscord | <bark> wait what if I cast a memory range into an unchecked array |
22:51:53 | FromDiscord | <bark> it's essentially just doing the pointer arithmetic I'd be doing |
22:52:35 | FromDiscord | <ElegantBeef> a `ptr UncheckedArray[T]` is the nim equivalent of a pointer to the first element of an array |
22:53:16 | FromDiscord | <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:40 | FromDiscord | <ElegantBeef> So you probably should be using an unchecked array |
22:54:05 | FromDiscord | <bark> isn't it the same as doing a few casts and doing start + index sizeof(T) |
22:54:13 | FromDiscord | <bark> + of course checking for overflow |
22:54:30 | FromDiscord | <bark> I don't see what I'd gain |
22:54:47 | FromDiscord | <ElegantBeef> Well you get easy use of `[]` 😛 |
22:54:54 | FromDiscord | <bark> I can define `[]` |
22:55:01 | FromDiscord | <ElegantBeef> `easy use` |
22:55:05 | FromDiscord | <ElegantBeef> I'm a numpty so disregard me |
22:55:18 | FromDiscord | <bark> well maybe it saves a bit of dev time |
22:55:36 | FromDiscord | <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:12 | FromDiscord | <ElegantBeef> This is where i say most of the time `ptr` isnt idiomatic 😛 |
22:57:34 | FromDiscord | <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:37 | FromDiscord | <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:45 | FromDiscord | <ElegantBeef> Fuck that was quick |
22:57:47 | FromDiscord | <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:48 | FromDiscord | <ElegantBeef> Good job 😄 |
22:58:26 | FromDiscord | <bark> if it's just a matter of running nimble test I can test on linux |
22:58:54 | FromDiscord | <ElegantBeef> Eh it's pure nim, it works on mac and windows it probably works "everywhere" 😄 |
22:59:11 | FromDiscord | <ElegantBeef> I'll be testing it anyway on linux as i implement it |
22:59:25 | FromDiscord | <ElegantBeef> Thanks guzba |
22:59:28 | FromDiscord | <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:35 | FromDiscord | <guzba> it seems windows are ok on mac but idk about all possible impls |
22:59:44 | FromDiscord | <ElegantBeef> just use the `/` operator |
22:59:46 | FromDiscord | <guzba> and using unix on windows is its own opposite thing? nim seems to handle |
22:59:52 | FromDiscord | <guzba> i do, but i more mean |
22:59:56 | FromDiscord | <guzba> if i create a tar on windows with / |
23:00:08 | FromDiscord | <guzba> then someone tries to extract using some other tool, will it blow up on windows path separators? |
23:00:24 | FromDiscord | <ElegantBeef> Windows uses `\` and `/` so possibly, but idk |
23:00:26 | FromDiscord | <bark> afaik it's a nim operator that outputs "\\" on windows |
23:00:33 | FromDiscord | <bark> or isn't there a os.dirSep or something |
23:00:48 | FromDiscord | <ElegantBeef> `/` is just string `&` using `os.dirSep` |
23:01:00 | FromDiscord | <guzba> anyway, its probably fine and if not ill find out when an issue is opened |
23:01:01 | FromDiscord | <bark> https://media.discordapp.net/attachments/371759389889003532/790715476702920744/unknown.png |
23:01:09 | FromDiscord | <guzba> then ill have a case to verify against |
23:01:11 | FromDiscord | <bark> wait windows uses |
23:01:14 | FromDiscord | <bark> both? |
23:01:18 | FromDiscord | <ElegantBeef> It accepts both |
23:01:19 | FromDiscord | <guzba> windows is flexible |
23:01:25 | FromDiscord | <ElegantBeef> `\` is the preferred |
23:04:36 | FromDiscord | <sealmove> is there a way to get inner type of an Option? |
23:05:18 | FromDiscord | <sealmove> for example if you have a var of type `Option[Something]`, how do you get `Something`? |
23:06:09 | FromDiscord | <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:40 | FromDiscord | <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:19 | FromDiscord | <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:56 | guestWebNodeChat | Is it acceptable to ask dumb questions here? Having an issue with proc references... |
23:21:03 | FromDiscord | <ElegantBeef> Yep |
23:21:08 | FromDiscord | <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:29 | guestWebNodeChat | I 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:59 | guestWebNodeChat | The pragmas(?) or whatever you call the {.noSideEffect.} things seem to be different so it's not working? |
23:23:23 | FromDiscord | <ElegantBeef> Yea those are pragmas, what's the code? |
23:23:51 | guestWebNodeChat | Error: 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:12 | guestWebNodeChat | Does the full type with pragmas need to be specified as a reference to a proc? |
23:26:13 | mipri | the playground's down? |
23:26:16 | FromDiscord | <ElegantBeef> Yep |
23:26:17 | guestWebNodeChat | Not sure how to treat a proc as a variable other than calling it directly by name |
23:26:35 | disruptek | let p = myproc |
23:26:54 | mipri | if 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:29 | mipri | let procs = @[foo1, foo2, foo3]; ... for p in procs. Nothing to it. There's no magic. |
23:27:32 | guestWebNodeChat | By variable I meant seq of them, sorry |
23:27:40 | mipri | but yes the pragmas make them incompatible types. |
23:27:45 | mipri | can make them. |
23:27:47 | disruptek | specify locks: 0 |
23:27:55 | mipri | since pragmas do things like completely change how a function needs to be called. |
23:28:40 | guestWebNodeChat | Some of them use .map(x => ...) with sugar, so I guess that changes the type |
23:30:13 | mipri | you've just discovered that it does. sugar gets pretty magical. |
23:30:30 | guestWebNodeChat | It kind of seems like the colored function problem |
23:31:43 | mipri | it'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:39 | mipri | probably 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:19 | mipri | you 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:36 | guestWebNodeChat | Is 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:11 | mipri | I doubt that there's an option like that. |
23:35:34 | FromDiscord | <ElegantBeef> Seems like something that would bite you in the ass, so something that wouldnt be allowed |
23:35:37 | guestWebNodeChat | I 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:19 | mipri | just use proc() instead of sugar for a use like this. |
23:36:44 | guestWebNodeChat | Meaning don't use the FP syntax and call it without sugar? |
23:37:01 | mipri | yes, just use proc() instead of sugar. |
23:40:51 | FromDiscord | <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:23 | FromDiscord | <ElegantBeef> They're just basic code substitution take the args and throw them around in the template body |
23:43:05 | FromDiscord | <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:27 | FromDiscord | <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:40 | FromDiscord | <ajusa> (edit) "value" => "type" |
23:44:24 | FromDiscord | <ElegantBeef> Ah yea, that's a requirement for if you return in the body, to satisfy nim's compiler |
23:44:58 | guestWebNodeChat | Ok thanks all |
23:45:03 | * | guestWebNodeChat left #nim (#nim) |
23:46:01 | FromDiscord | <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:26 | FromDiscord | <ajusa> (edit) "a seq?" => "an array?" |
23:47:05 | mipri | no, that's not possible. |
23:47:51 | mipri | you could do it with someMacro: [1, 2, anythingHere, 3, 4] |
23:48:08 | mipri | but there's nothing a template could possibly return in that case that would work. |
23:48:36 | mipri | you'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:03 | FromDiscord | <ajusa> That |
23:49:13 | FromDiscord | <ajusa> That's intelligent, I'll try that. Thanks! |
23:52:28 | jken | Is there an iterator like pairs, but for N number of items in a chunk? |
23:53:00 | FromDiscord | <ElegantBeef> you can do `toOpenArray(start, end)` |
23:53:20 | mipri | https://nim-lang.org/docs/sequtils.html#distribute%2Cseq%5BT%5D%2CPositive |
23:53:45 | jken | nice! |
23:54:00 | FromDiscord | <ElegantBeef> Or what you actually want from mipri 😄 |
23:56:38 | FromDiscord | <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:58 | mipri | put the & at the end of the previous line |
23:58:16 | FromDiscord | <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) |