<< 01-12-2020 >>

00:08:05*D_ quit (Ping timeout: 256 seconds)
00:09:44FromDiscord<tinygiant> sent a code paste, see https://play.nim-lang.org/#ix=2G5X
00:11:18FromDiscord<ElegantBeef> myType.isSome
00:12:01FromDiscord<ElegantBeef> or `isNone`
00:15:34FromDiscord<tinygiant> That was working for the type, but it wouldn't allow me to assign values to the type components.
00:16:01FromDiscord<ElegantBeef> What do you mean?
00:16:02FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=2G5k
00:16:24FromDiscord<ElegantBeef> If you want actual nil behaviour make the MyType ` ref object`
00:16:35FromDiscord<tinygiant> Give me a second to find my computer.
00:16:45FromDiscord<ElegantBeef> There is actual reference type objects in Nim, if you want them
00:18:39FromDiscord<Quibono> Is there a nim graphing library that supports like live updates?
00:18:53FromDiscord<ElegantBeef> https://nimble.directory/search?query=graph
00:20:20FromDiscord<tinygiant> sent a code paste, see https://play.nim-lang.org/#ix=2G5Z
00:20:36FromDiscord<ElegantBeef> result.get.token
00:21:11FromDiscord<ElegantBeef> Options require `get`ing and should only be done inside a `if a.isSome`
00:21:41FromDiscord<Quibono> Lol beef that answers a question, not necessarily my question
00:21:59FromDiscord<ElegantBeef> I mean there are a lot of graph libraries and i can only point you to there as i've never used them
00:22:01FromDiscord<ElegantBeef> So i did 😄
00:22:16FromDiscord<tinygiant> Yup, I got the basics on options, but all my googling couldn't find an example of using options with custom types. That's exactly the answerI needed to resolve part of my insanity with the current project. Thanks! Now to do some more experimenting.
00:22:58FromDiscord<ElegantBeef> I know some arent actual plotting or graph libraries
00:23:05FromDiscord<Quibono> lol
00:23:40FromDiscord<ElegantBeef> Nmiline i assume would be live updating
00:25:36FromDiscord<Quibono> Yeah, ideally it'd work with Fidget since that seems to be the gui option de jour
00:30:28FromDiscord<ElegantBeef> Well fidget hasnt really been used as a dependancy anywhere that i know of so yea have fun making it ;P
00:31:01FromDiscord<Quibono> Lol dear lord, I don't know the first thing about making a graphing library
00:31:19FromDiscord<ElegantBeef> The first step to learning anything is not knowing anything
00:39:04FromDiscord<tinygiant> sent a code paste, see https://paste.rs/RTE
00:40:50FromDiscord<ElegantBeef> well yea you need to make the result `some(Auth()))`
00:42:18FromDiscord<tinygiant> That's hilariously awful. I tried `result = some(Auth)` and variations, but never with the `()`. Thanks for the pointer, again.
00:42:22FromDiscord<ElegantBeef> https://github.com/beef331/nimscripter/blob/master/src/nimscripter.nim#L182
00:42:31FromDiscord<ElegantBeef> That's how i do it for nimscripter
00:42:47FromDiscord<ElegantBeef> If the script fails to load i dont set the output as it defaults to an none
00:56:49*lritter quit (Quit: Leaving)
01:00:34FromDiscord<tinygiant> Awesome. Thanks for the example. It's it possible to send an optional argument of this type, such as `proc someProc(auth: Option[Auth] = none(Auth))` or something like that?
01:04:05FromDiscord<ElegantBeef> Does that not work?
01:08:44FromDiscord<tinygiant> Sorry, wasn't in front of my computer, just random throughts flying through my cranium while I'm doing homework with the kids. I'll give a shot. Sorry, shouldn't have asked until I tried.
01:12:52FromDiscord<Zachary Carter> @shashlick quick question whenever you have a chance - if I am producing two wrappers using `nimFile` is there a way to have one import the file the other generates?
01:13:04FromDiscord<Zachary Carter> or is there some way to add a list of imports to a generated wrapper
01:13:06FromDiscord<Zachary Carter> ?
01:13:50ForumUpdaterBotNew thread by Elcritch: When to use IncompleteStruct pragma?, see https://forum.nim-lang.org/t/7180
01:21:53*bunbunbunbunny joined #nim
01:22:00bunbunbunbunnyhi there
01:22:48bunbunbunbunnyi'm pretty new to nim and trying to use lldb to debug my program... when i br at a specific spot in my code successfully the variable stack doesn't reflect the nim code and i'm seeing a bunch of nim obfuscated vars
01:23:16bunbunbunbunnyi'm using the --debugger:native flag when i compile with nimble c ..is there something i'm missing?
01:23:24*Tanger joined #nim
01:25:40FromDiscord<Zachary Carter> I don't think `nimble c` will work with `--debugger:native`
01:25:42FromDiscord<Zachary Carter> `nim c` will
01:25:51FromDiscord<Zachary Carter> I could be wrong though
01:26:19bunbunbunbunnyoh ok
01:27:14FromDiscord<Zachary Carter> you could throw it in a `nim.cfg` in the same dir as the `nimble` file
01:27:20bunbunbunbunnynah it's the same
01:27:50bunbunbunbunnyit works but i just get the obfuscated variables from nim and can't see vars from the stack frame i'm in
01:28:19bunbunbunbunnybut when i use 'l' it can see the code block i'm in..
01:28:20FromDiscord<Zachary Carter> well you're going to get mangled variable names
01:29:00bunbunbunbunnyyeah that's ok... but i can't even see my variable that i've done a simple assignment on `var something = "dog"`
01:29:19*lum quit (Quit: Lum: Bye!)
01:29:35*lum joined #nim
01:30:33FromDiscord<ElegantBeef> I dont do much proper debugging but dont you need `--linedir:on` aswell?
01:31:04bunbunbunbunnyaccording to the dcumentation --debugger:native is an alias for that and another thing set
01:31:08FromDiscord<Zachary Carter> it is
01:32:18FromDiscord<ProfessorEevee> Is there an example of Nim async? I can't seem to find anything that I can understand...
01:32:33FromDiscord<Zachary Carter> it's working fine for me bunbunbunbunny
01:32:42FromDiscord<Zachary Carter> https://media.discordapp.net/attachments/371759389889003532/783143503710388244/Screen_Shot_2020-11-30_at_8.32.22_PM.png
01:32:55bunbunbunbunnyfor context i'm debugging something in a test.nim file
01:33:07bunbunbunbunnyso i'm guessing that the test "" macro is obscuring a lot of stuff
01:33:23bunbunbunbunnyi'll try it and get back to u
01:33:25FromDiscord<Zachary Carter> okay
01:34:58bunbunbunbunnynop[e... this is what i see: https://pastebin.com/2aSeHMSW
01:35:21bunbunbunbunnystill running it from test1.nim
01:36:05*guelosk[m] quit (Ping timeout: 240 seconds)
01:36:37bunbunbunbunnyzackary can you press v
01:36:43bunbunbunbunnyand see if you get your variables in the stack frame?
01:36:46bunbunbunbunnyor do you see what i see
01:38:29FromDiscord<Zachary Carter> you might want to read https://nim-lang.org/blog/2017/10/02/documenting-profiling-and-debugging-nim-code.html#using-gdb-lldb
01:39:01FromDiscord<Zachary Carter> in my example, the variable was a global so I needed to use `ta v` to view them
01:39:14FromDiscord<Zachary Carter> I don't know what your code looks like so I can't really reproduce your example
01:39:37bunbunbunbunnyok thanks
01:39:48FromDiscord<Zachary Carter> no problem
01:40:08FromDiscord<Zachary Carter> have you done asynchronous programming in any other languages @ProfessorEevee?
01:40:16FromDiscord<ProfessorEevee> Python, yeah
01:43:00FromDiscord<Zachary Carter> well you can look at the nim in action repo - it has some example code here - https://github.com/dom96/nim-in-action-code/tree/master/Chapter3/ChatApp
01:43:13FromDiscord<Zachary Carter> I'm not sure how up to date it is - I don't really use async in Nim
01:43:19FromDiscord<Zachary Carter> it's never been very stable
01:43:54FromDiscord<Zachary Carter> I think if you poke around github you'll find a lot of example code
01:45:57FromDiscord<ProfessorEevee> ah I'm so confused
01:46:53FromDiscord<shashlick> @Zachary Carter since both are being generated, the second could simply generator could simply import the first generator
01:48:24*guelosk[m] joined #nim
01:48:36*jrhawley[m] quit (Ping timeout: 246 seconds)
01:48:48*jrhawley[m] joined #nim
01:50:03*abm quit (Read error: Connection reset by peer)
01:52:41FromDiscord<ProfessorEevee> What on Earth is a "generic method"
01:59:39FromDiscord<Zachary Carter> google parametric polymorphism
02:00:27FromDiscord<Zachary Carter> well that worked when I wasn't generating standalone files with `nimFile`
02:00:44FromDiscord<Zachary Carter> but now it doesn't
02:01:02FromDiscord<Zachary Carter> I'll try to figure out a workaround
02:02:42FromGitter<bung87> how to make a common used type that part of a module so that type private properties visible to that module ,I can thought use a sub type ,wonder if theres another way
02:06:03FromDiscord<notchris> If I have a method like `sdl2.getDisplayDPI() `.. can I get the pixel ratio from that?
02:08:49FromGitter<bung87> same thing right?
02:18:38*apahl quit (Ping timeout: 264 seconds)
02:20:07*apahl joined #nim
02:22:07FromDiscord<notchris> so sdl2 has a proc `getLogicalSize(renderer: RendererPtr; w, h: var cint)`
02:22:21FromDiscord<notchris> in the clib, it takes a pointer for w,h
02:22:34FromDiscord<notchris> but in the nim version, it takes two cint vars?
02:22:44FromDiscord<notchris> I tried it out, but it wasn't setting the vars, like it would a pointer
02:22:47FromDiscord<notchris> am i missing something?
02:26:13FromDiscord<nikki> it should set the vars
02:26:20FromDiscord<ElegantBeef> a `var cint` is just a fancy ptr
02:26:35FromDiscord<nikki> `var w, h: cint; getLogicalSize(renderer, w, h)`
02:26:41FromDiscord<nikki> after that `w, h` should have the result
02:26:54FromDiscord<nikki> it's possible the SDL call itself is not setting it for whatever reasn tho
02:27:14FromDiscord<nikki> but yeah i usually use `var` for such things except when possibility for `nil` is actually useful
02:29:21FromDiscord<ProfessorEevee> I figured out why I was so confused with Nim async
02:29:28FromDiscord<ProfessorEevee> VSCode giving me fake errors :(
02:29:53*stefantalpalaru quit (Ping timeout: 272 seconds)
02:30:43FromGitter<bung87> dont relys on that compile and see errors
02:31:00FromDiscord<ProfessorEevee> Yep, I keep learning that over and over again lol
02:31:25FromDiscord<ProfessorEevee> Hopefully eventually there's JetBrains compatibility. I really love their IDEs
02:31:52FromGitter<bung87> many times my program works nim ide tools reporting errors
02:32:30FromDiscord<notchris> thank you @nikki 🙂
02:32:58FromDiscord<notchris> sadly i dont think its setting it correctly, i always get back 0, 0
02:33:08FromGitter<bung87> there're two spot compiler inject code check only for nimsuggest
02:34:16FromDiscord<nikki> @notchris the remark on https://wiki.libsdl.org/SDL_RenderGetLogicalSize seems relevant
02:34:26FromDiscord<nikki> (in general the SDL docs are pretty helpful actually)
02:34:51FromDiscord<notchris> Ooo
02:35:03FromDiscord<notchris> _is silly_
02:49:25*D_ joined #nim
03:00:16*stefantalpalaru joined #nim
03:05:11*stefantalpalaru quit (Changing host)
03:05:11*stefantalpalaru joined #nim
03:16:16*bunbunbunbunny quit (Ping timeout: 260 seconds)
03:16:34*vicfred quit (Quit: Leaving)
03:18:21*rockcavera quit (Remote host closed the connection)
03:18:22*bunbunbunbunny joined #nim
03:19:17*bunbunbunbunny quit (Client Quit)
03:28:52FromDiscord<Quibono> So Ajusa, you need the first int of any size?
03:29:01FromDiscord<Quibono> So like 900 is a valid input?
03:29:04FromDiscord<ajusa> yeah
03:29:22FromDiscord<ajusa> like `hello 900 world` should return `900`
03:29:46FromDiscord<Quibono> I mean we can definitely make a function that does that, IDK if one does it out of the box
03:29:55FromDiscord<ajusa> and `hello900 world` should do the same, can't assume whitespace is surrounding the number.
03:30:24FromDiscord<ajusa> Yeah the regex solution I posted works, but it feels like a lot of code so I was wondering if this was baked into the stdlib and I missed it somehow
03:31:04FromDiscord<ajusa> (edit) "works," => "works (`test.find(re"\d+").get.match.parseInt`),"
03:33:00leorize[m]1have you tried strscans.scanf?
03:38:13FromDiscord<Quibono> Heh is this a bug? https://play.nim-lang.org/#ix=2G6O
03:38:46FromDiscord<ElegantBeef> no
03:38:55FromDiscord<ElegantBeef> Characters converted to ints are not the symbols
03:39:22FromDiscord<Quibono> What are they?
03:39:29FromDiscord<ElegantBeef> Ascii characters
03:39:33FromDiscord<ajusa> I just tried strscans.scanf but didn't see an option to skip non-digit characters at the start of a string, just whitespace. I could define a custom proc but that would be more complicated
03:39:34FromDiscord<ElegantBeef> https://www.asciitable.com/
03:39:43FromDiscord<Quibono> So 5 is the 53rd ascii char?
03:39:53FromDiscord<Quibono> lol
03:39:53FromDiscord<ElegantBeef> yes
03:40:06leorize[m]1@ajusa the scan expression should be `$*$i` for your case
03:40:08FromDiscord<ElegantBeef> You change to my code is not the way to do it 😄
03:40:51FromDiscord<Quibono> Lol I'm trying to steal from better coders.
03:41:14FromDiscord<ElegantBeef> You never even set found 😄
03:41:36FromDiscord<Quibono> lol
03:41:40FromDiscord<Rika> You assume we’re better
03:41:57FromDiscord<ElegantBeef> also the "else: continue"
03:43:03FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#ix=2G6P
03:43:20FromDiscord<ajusa> (edit) "https://play.nim-lang.org/#ix=2G6P" => "https://play.nim-lang.org/#ix=2G6Q"
03:47:01FromDiscord<Quibono> https://play.nim-lang.org/#ix=2G6R
03:47:08FromDiscord<Quibono> Okay, it does it, it just returns as a string
03:47:35FromGitter<gogolxdong> `nim c -d:ssl --cpu:arm64 --os:linux -d:release convert.nim` cross compile for arm64 errors `cannot execute binary file: Exec format error`
03:48:09FromGitter<gogolxdong> just hello world.
03:48:43FromDiscord<ElegantBeef> I know this should be obvious but you are attempting to run it on a arm64 cpu right?
03:49:18leorize[m]1@gogolxdong have you set up a cross C compiler?
03:50:16leorize[m]1@ajusa hmm, seems like a bug then. In the meantime for lightweight parsing you can probably mix `parseutils.skipUntil` and `parseutils.parseInt` to get the desired result
03:51:50leorize[m]1so use skipUntil to get the index where the number would start, then call parseInt with that index as the `start` parameter
03:52:44FromDiscord<Quibono> https://play.nim-lang.org/#ix=2G6T Okay this is the cleanest answer I have for a custom function do do what @ajusa wants
03:52:54leorize[m]1alternatively pegs or regex works with less lines :p (but probably not as fast)
03:52:58FromDiscord<ElegantBeef> How is that better than mine?
03:53:27FromGitter<gogolxdong> you mean change cc to cross c compiler before compile when cross compile?
03:53:53FromDiscord<ajusa> looks pretty good to me! currently trying out the parseutils stuff too
03:54:06leorize[m]1@gogolxdong if you're on *nix the `file` command can be used to determine the executable architecture
03:54:07FromDiscord<Quibono> It's not?
03:54:09FromDiscord<ElegantBeef> quibono using a case for an if statement 😄
03:54:26FromDiscord<Quibono> lol, well I almost need like a conjoined case
03:54:39FromDiscord<ElegantBeef> I mean you're using it as an if statement
03:55:02FromDiscord<ElegantBeef> It's `if c != number and found`
03:55:13FromDiscord<ElegantBeef> but you already have the original if so you just need found
03:55:15FromDiscord<ElegantBeef> Like what i did
03:55:28leorize[m]1@gogolxdong, yea, in nim.cfg there's also an example on how to configure the compiler to be used for a given architecture
03:55:31FromDiscord<ElegantBeef> It's code golf to the extreme 😄
03:55:34FromGitter<gogolxdong> is there any example?
03:55:58FromDiscord<Quibono> Can you use a case statement along with another logic expression on the same line lol
03:56:02FromDiscord<ElegantBeef> No
03:56:06FromDiscord<ElegantBeef> My point is it's just what this does https://play.nim-lang.org/#ix=2G6U
03:56:31FromDiscord<ElegantBeef> Yes i realized the bool was redundant
03:56:59FromGitter<gogolxdong> What are need when cross compile for arm64?
03:57:04FromDiscord<Quibono> Lol well I'm just happy my newb ass figured out a way to do it
03:57:12FromDiscord<ElegantBeef> Didnt you just copy my impl?
03:57:14FromDiscord<eggy> Hello everyone. I am new to Nim . I tried it when it was still called Nimrod. Is there a way to use TCC on windows for Nim instead of gcc?
03:57:35FromDiscord<ElegantBeef> You can change the compiler in the `nim.cfg`
03:57:46leorize[m]1@eggy assuming that you have tcc in PATH, pass --cc:tcc to the compiler
03:58:00leorize[m]1alternatively change the default in nim.cff
03:58:09leorize[m]1cfg*
03:58:57FromDiscord<eggy> Thanks @ElegantBeef @leorize[Matrix]1
03:59:29leorize[m]1@gogolxdong this should helps: https://nim-lang.org/docs/nimc.html#crossminuscompilation
04:03:40FromDiscord<ajusa> https://play.nim-lang.org/#ix=2G70 is the parseutils version I came up with, I think I'll just stick with regex lol
04:04:07FromDiscord<ElegantBeef> Leorize thanks for mentioning `scanf` i'm now interested i static analyising the `pattern` from `scanf` to make something that creates the required variables for the capture 😄
04:04:44FromGitter<gogolxdong> @leorize yes, it's helpful.Thanks!
04:05:40leorize[m]1ElegantBeef just make sure whatever you create can beat npeg :p
04:05:49FromDiscord<ajusa> is scanf actually broken though? there was a github issue related to it a few months ago, but I didn't see any open issues with it being mentioned
04:06:02*supakeen quit (Quit: WeeChat 2.9)
04:06:23FromDiscord<ElegantBeef> I mean it's not to beat npeg, more just to remove that whole `var a: T` then `str.scanf(pattern, a)`
04:06:36*supakeen joined #nim
04:06:46FromDiscord<ElegantBeef> i'd just be like `whenScanf(str, pattern, a):`
04:06:55FromDiscord<ElegantBeef> (edit) "i'd" => "it'd"
04:07:25FromDiscord<ElegantBeef> Basically just extracting the type of the variable identifiers from the pattern
04:08:18FromDiscord<ElegantBeef> I very much dont really like repetitive code, i do imagine it's possible to extract the types, but i could be wrong
04:10:16FromDiscord<ElegantBeef> Like if you look at the pattern you should be able to see in this demo the identifiers are `int, int, int, s, float` `scanf(input, "$i-$i-$i $w$s$f", year, month, day, identifier, myfloat):`
04:15:56*Jjp137_ quit (Quit: Leaving)
04:16:04*Jjp137_ joined #nim
04:16:06FromDiscord<eggy> @ElegantBeef which nim.cfg to put tcc reference in? There are a few in the Windows installation in different Nim directories. Is there a specific line or command? Thanks in advance! I couldn't find it on the Nim site or via a search.
04:16:31FromDiscord<ElegantBeef> I dont know on windows, leorize is probably more useful in this case
04:18:29FromDiscord<eggy> Thanks anyway!
04:20:02leorize[m]1@eggy config/nim.cfg is the file
04:23:20*rockcavera joined #nim
04:24:10FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G75
04:25:34FromDiscord<ProfessorEevee> I know why, but I don't know what the Nim alternative to Python's `asyncio.gather()` is
04:32:43FromDiscord<ElegantBeef> Hey leorize the example works 😄 https://media.discordapp.net/attachments/371759389889003532/783188808786378812/unknown.png
04:34:24FromDiscord<ElegantBeef> Silly code is silly https://play.nim-lang.org/#ix=2G77
04:36:02FromDiscord<ElegantBeef> Just like that he ran away 😛
04:37:03leorize[m]1@ProfessorEevee you can put them all in a seq then use `asyncfutures.all()`
04:37:28FromGitter<gogolxdong> Is it should be `--cpu:aarch64 --os:linux --cc:gnu-gcc` when cross compiler is aarch64-linux-gnu-gcc
04:39:55leorize[m]1`--cc:gnu-cc` should be `--aarch64.linux.gcc.exe:aarch64-linux-gnu-gcc` and `--aarch64.linux.gcc.linkerexe:aarch64-linux-gnu-gcc`
04:41:34leorize[m]1@ElegantBeef have you considered reusing scanf's scan string parser? :p
04:42:14FromDiscord<ElegantBeef> I mean i should just for 1:1 parity 😛
04:42:48FromDiscord<ElegantBeef> I was just doing it for fun, although i guess it could possibly be PR'd into the stdlib if it actually worked properly
04:43:53FromDiscord<eggy> @leorize Thanks! I changed gcc to tcc, but I receive errors on compiling even hallo.nim in the examples directory. I think it must be a TCC issue, because I used finish.exe to install the Nim server msys and it works. I'll try again tomorrow. I only want to use TCC for minimalism on my system. I use Raylib the c library with TCC just fine. This is a separate TCC standalone install. I will test tomorrow to find the error. Thanks!
04:46:04*mbomba joined #nim
04:46:16*mbomba quit (Client Quit)
04:46:47*mbomba joined #nim
04:49:00FromGitter<gogolxdong> why gnu is stripped in option key?
04:53:45*narimiran joined #nim
04:58:17FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G79
05:02:17ForumUpdaterBotNew thread by Jiyinyiyong: Error: unhandled exception: index 1 not in 0 .. 0 [IndexDefect], see https://forum.nim-lang.org/t/7181
05:02:25*thomasross quit (Ping timeout: 240 seconds)
05:03:44*a_chou joined #nim
05:15:57*a_chou quit (Remote host closed the connection)
05:17:16FromDiscord<ProfessorEevee> ah I fixed my issue
05:17:29FromDiscord<ProfessorEevee> I had to use `newSeq[Future[void]]()`
05:17:57FromDiscord<ProfessorEevee> Now my only issue is creating 700~ objects concurrently
05:18:05*waleee-cl quit (Quit: Connection closed for inactivity)
05:23:07FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G7d
05:24:04FromDiscord<tinygiant> <https://nim-lang.org/docs/sequtils.html#repeat%2CT%2CNatural> might do it?
05:25:34FromDiscord<ProfessorEevee> Ah yep. That's exactly what I was looking for. Thank you
05:25:46FromDiscord<ProfessorEevee> Weird how I missed that lol
05:28:16*D_ quit (Ping timeout: 240 seconds)
06:09:11*D_ joined #nim
06:56:49*habamax joined #nim
07:02:00narimiranZevv: where are you?
07:07:42*mbomba quit (Quit: WeeChat 3.0)
07:22:46Zevvat home, like the rest of the world
07:26:42narimiranZevv: smartass, go get your first advent star!
07:27:07Zevvdude I got taht
07:27:12Zevvbut I'm not joining the race this time
07:27:18ZevvI used to do this on my commute
07:27:39Zevvbut it really doesn't fit my morning schedule now, with the kids still lingering etc
07:28:46*Zevv quit (Quit: Lost terminal)
07:29:05*Zevv joined #nim
07:29:13*Zevv quit (Client Quit)
07:29:37*Zevv joined #nim
07:29:45*Zevv quit (Client Quit)
07:30:33*Zevv joined #nim
07:30:40Zevvsigh what's this shit with my irc client
07:31:00Zevvanyway, I just conceived the absolute apex of my programming career
07:31:03Zevvthree nested loops
07:31:04Zevvhooray
07:32:14*narimiran quit (Ping timeout: 260 seconds)
07:34:10*narimiran joined #nim
07:34:31narimiranZevv: dude, spoilers!
07:34:35narimiranwhat if somebody doesn't know that loops should be used?
07:35:04narimiran(yeah yeah, i heard of functional programming)
07:56:22Zevvok you do it with FP
07:59:24FromDiscord<Vindaar> kinda want to join AoC after all. Probably because I really don't have time until the evening, haha
07:59:55*PMunch joined #nim
07:59:57*crem quit (Quit: WeeChat 2.8)
08:02:48narimiran@Vindaar today's one is very easy. you can do it even if you don't have time :P
08:14:22*dddddd quit (Ping timeout: 246 seconds)
08:18:48FromDiscord<Vindaar> ok, you're right. Done. Naive solution though 😛 https://github.com/Vindaar/AdventOfCode2020
08:19:38narimiranhe claims he has no time, and then he.......... writes some tests?!?!
08:21:31FromDiscord<Vindaar> hahaha
08:21:47FromDiscord<Vindaar> I'm a professional procrastinator aka PhD student, ok?
08:23:33FromDiscord<Vindaar> also feels wrong not to write the unit tests they give us, huh 😉
08:23:53FromDiscord<PizzaFox> what's the proc/pragma/flag?? for reading a file at compile time
08:24:16FromDiscord<Vindaar> where's your solution miran?
08:24:29FromDiscord<Vindaar> (it's not in your repo yet)
08:24:29FromDiscord<PizzaFox> i think you can get fast fast using `sums` for pairwise summation for part 1
08:25:21FromDiscord<Vindaar> `staticRead`
08:25:24FromDiscord<PizzaFox> thx
08:25:35FromDiscord<PizzaFox> (edit) "i think you can get fast fast using `sums` for pairwise summation for part 1 ... " added "(unless i am vastly misunderstanding the docs here, this is possible)"
08:25:41Zevvhttps://github.com/zevv/aoc2020/blob/master/01/main.nim I wrote a test
08:27:03FromDiscord<Vindaar> Zevv, I'd say you wrote 3 "test"s
08:27:25Zevvwell, look at me
08:27:31ZevvI'd *so* hire me
08:32:41FromDiscord<ProfessorEevee> lol did AoC go down as soon as I was going to submit my answer
08:36:40FromDiscord<PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2G7U
08:41:32narimiran@Vindaar i haven't pushed it to my repo yet. i usually do that in the evening (after i maybe optimize a bit)
08:41:50*lckmidnight joined #nim
08:41:52narimirancurrently i have one optimization that cuts the time ~4x
08:41:59FromDiscord<PizzaFox> (edit) sent a code paste, see https://play.nim-lang.org/#ix=2G7V
08:42:19FromDiscord<Vindaar> Ah, right. You're trying to make it go brrrr always indeed (:
08:42:57narimiranZevv: oh, `lines`! nice, i always forget that exists!
08:43:37*lckmidnight quit (Remote host closed the connection)
08:43:55narimiranmuch better than my `readFile` + `splitLines`
08:44:13ZevvI'd *so* not hire you
08:44:40FromDiscord<Vindaar> that's just mean Zevv! You have way more years of programming experience than Miran and me!
08:44:55Zevvthat's why I would not hire you
08:45:04narimiranboth of you iterate whole input for every number!? what is this, an amateur hour?
08:45:04Zevvall these punks
08:45:15narimiranwhat if you had 1010 in your input?
08:45:16Zevvcan you read?
08:45:26Zevvoh I can optimize so much
08:45:34ZevvI can probably make this run in 1% of the time I use now
08:45:45narimiranthat is not the optimization i was referring earlier
08:45:53supakeenaoc fights?
08:45:58Zevvthere are so many optimizations possible
08:46:07Zevvbut they do not matter * at all *
08:46:11supakeenchristmas really is the most peaceful time of year, except for aoc submissions
08:46:24Zevvit's such a waste of time, effort, code and electrons
08:47:00FromDiscord<Vindaar> electrons
08:47:11FromDiscord<Vindaar> I see what you did there, looks at electron
08:47:24narimiransupakeen: yep
08:47:47FromDiscord<Vindaar> imo the AoCs are fun where the naive brute force solution doesn't work, cause it makes it run way too slow 🙂
08:47:48FromDiscord<Idefau> my aoc solution is just bruteforcing
08:47:50FromDiscord<Idefau> but it works
08:48:16Zevvvindaar: xactly, and that's not until day 8 or so
08:48:23Zevvthese are fun
08:48:38Zevvand the ones a loathe are all the maze hunting games with tons of arbritrary rules and expections
08:48:47Zevvthat happen to describe the original implementation the author made
08:49:48narimiranyeah, don't like those with wall of text
08:50:01FromDiscord<Vindaar> yep those can be annoying
08:50:05FromDiscord<Idefau> yeah
08:50:44FromDiscord<PizzaFox> how should i convert an array of a bunch of stringified ints, back into ints, all at compile time?
08:51:10PMunchA {.compileTime.} proc
08:51:18FromDiscord<PizzaFox> true?
08:51:43FromDiscord<ElegantBeef> or a `static` block
08:51:46FromDiscord<Idefau> !eval echo true == true
08:51:49NimBottrue
08:51:51FromDiscord<PizzaFox> thought compiletime got removed
08:51:53FromDiscord<Idefau> yeah true
08:52:06FromDiscord<ElegantBeef> I'm not currently code golfing the AOC by attempting to use closure iterators
08:52:32narimiran!eval echo "life" == "life"
08:52:34NimBottrue
08:52:40narimiranla la, la la la
08:52:43PMunchNa na nanana
08:52:43Zevvdude, that's deep
08:52:51narimiran:D :D
08:52:55supakeenAll together noew.
08:53:07FromDiscord<Idefau> !eval echo "work" > "success"
08:53:10NimBottrue
08:53:10FromDiscord<ElegantBeef> So closure operators dont store their state, so to continue iterating you need to supply the last position?
08:53:13FromDiscord<Idefau> deep....
08:53:26FromDiscord<ElegantBeef> iterators
08:53:33narimiran...space...
08:54:29PMunch!eval type Life = distinct void; proc `==`(a, b: Life): string = "na na nanana"; echo Life() == Life()
08:54:31NimBotCompile failed: /usercode/in.nim(1, 37) Error: invalid type: 'void' in this context: 'proc (a: Life, b: Life): string' for proc
08:54:45PMunchAh, damn it :P
08:57:42FromDiscord<Idefau> !eval type Nim = distinct void; proc foo(loveFor: Nim) = discard
08:57:44NimBotCompile failed: /usercode/in.nim(1, 35) Error: invalid type: 'void' in this context: 'proc (loveFor: Nim)' for proc
08:57:52FromDiscord<Idefau> deep...
09:00:40narimiranPMunch: better solve that second part than trying to create lyrics :)
09:02:28PMunchThere, happy?
09:02:31*Tanger quit (Quit: Leaving)
09:02:41narimiranPMunch: very :)
09:02:59PMunchAaaw "Because of an outage during the day 1 puzzle unlock, day 1 is worth no points."
09:03:31supakeenlel
09:04:26narimiransee you all tomorrow :P
09:05:19FromDiscord<Idefau> i hope its not a wall of text
09:05:49FromDiscord<Idefau> too early for that anyway
09:06:50PMunchHmm, now the question becomes, how can we over-engineer this
09:07:19FromDiscord<ElegantBeef> I'm already doing it
09:07:28PMunchI mean my part2 takes 0.495s on -d:release and --gc:arc
09:07:29FromDiscord<ElegantBeef> Using closure iterators to make it so you can solve it with a single proc 😄
09:07:44FromDiscord<ElegantBeef> my part 2 is borked
09:07:46PMunchProcs?
09:07:56PMunchhttp://ix.io/2G80 <- I just put everything in main :P
09:08:00FromDiscord<ElegantBeef> lol
09:08:19FromDiscord<Idefau> jesus
09:08:36narimiran0.5 ms on my computer
09:08:49PMunch0.5 ms?
09:08:55FromDiscord<Idefau> 0.004 B)
09:10:30narimiranyes, 0.5 ms
09:10:38narimiranthat's what `perf` reports for 50 runs
09:10:55narimiranthat's for both solutions
09:13:24narimiranbut running manually it is 11ms
09:15:09FromDiscord<kodkuce> what is point of registring on advent of code, cant i just do those puzles myself, you reg only for competition right?
09:15:29FromDiscord<ElegantBeef> Yea
09:15:34narimiranwithout registering you won't see the second part of a puzzle
09:15:47narimiranand you won't know if your solution is correct
09:16:07FromDiscord<ElegantBeef> `~.021s` with my closure method
09:16:15FromDiscord<ElegantBeef> and it works for `n` number of steps
09:16:21FromDiscord<ElegantBeef> Worth over engineering 😄
09:16:43FromDiscord<ElegantBeef> If you want to see https://media.discordapp.net/attachments/371759389889003532/783260276862222376/SPOILER_unknown.png
09:17:29PMunchDamn 0.5ms I'm curious how you did that narimiran. But I kinda want to try my hand at over-engineering this myself before I get any input
09:17:39PMunchOh wait, did you just do it all during compile-time?
09:18:01narimiranPMunch: nope :) but maybe perf is wrong tool to measure this?
09:18:17FromDiscord<kodkuce> so do i have to make a repo?
09:18:29FromDiscord<kodkuce> how does AoC test my code
09:18:58FromDiscord<kodkuce> oh it dosent i submit answer
09:19:06PMunchYup
09:19:10PMunchIt's a pretty neat system actually
09:19:43PMunchEveryone gets the same task, but with different inputs, and it just checks that you arrive at the correct output and assume that you did it by computer
09:19:56PMunchAllows you to write it in absolutely any language (even your own)
09:19:59FromDiscord<ElegantBeef> It's sorta how CS should do code 😄
09:20:07FromDiscord<ElegantBeef> CS education
09:20:08PMunchEh, not really
09:20:27PMunchYou can easily have a program that seems to do the right thing, but does something horribly wrong
09:20:39narimiranPMunch: here's the output of perf: http://ix.io/2G85
09:20:42PMunchI've seen that a couple times in my year of correcting CS hand-ins :P
09:21:04PMunchnarimiran, and how do you run it?
09:21:05FromDiscord<ElegantBeef> That's why i said sorta
09:21:19PMunchWait ./nim/? Are you doing these in multiple languages?
09:21:46FromDiscord<ProfessorEevee> How do you check how long it takes your code to finish running?
09:21:58FromDiscord<ElegantBeef> `time binary` on nix
09:22:05narimiranPMunch: `perf stat -r 50 --table -o outfile.txt nim/day01`
09:22:17narimiranPMunch: i'm not doing it in multiple languages. yet. :)
09:22:32FromDiscord<ProfessorEevee> Uhh
09:23:09FromDiscord<ProfessorEevee> I'm on Windows, so I con't think I have access to that
09:23:51FromDiscord<ElegantBeef> You can time inside the code, but the OS timing method is easier to do 😄
09:23:58FromDiscord<ElegantBeef> Dont know the windows way
09:24:01FromDiscord<ProfessorEevee> Ah rip
09:24:10FromDiscord<kodkuce> i reinstalled os, have fresh vscode what nim plugin is best atm?
09:24:17FromDiscord<ElegantBeef> I use the alt
09:24:25FromDiscord<ElegantBeef> They dont differ internally
09:24:44FromDiscord<ElegantBeef> The syntax highlighting was the only difference between nim-alt and the normal nim
09:25:01FromDiscord<kodkuce> there is lsp one too
09:25:15FromDiscord<ElegantBeef> You might be able to do timeit professor
09:25:18FromDiscord<ElegantBeef> Oh
09:25:26FromDiscord<ElegantBeef> Gotta try the lsp one now
09:25:47FromDiscord<ProfessorEevee> What's timeit?
09:25:59FromDiscord<ElegantBeef> Possibly a windows command
09:26:17FromDiscord<ProfessorEevee> ah nope
09:26:25PMunchThe goal is for the LSP one to become the best ne
09:27:22PMunchOh, there are just 200 numbers?
09:28:21FromDiscord<kodkuce> lsp is the way
09:29:13FromDiscord<ElegantBeef> Yea the LSP makes me happy as it properly highlights stuff
09:29:13PMunchThis is the way
09:30:25FromDiscord<ElegantBeef> `Object.field.toFloat` doesnt highlight `tofloat`
09:30:34FromDiscord<ElegantBeef> Feels bad
09:30:55FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G88
09:31:19PMunchWait, LSP shouldn't highlight anything..
09:31:27*hnOsmium0001 quit (Quit: Connection closed for inactivity)
09:31:43*Q-Master quit (Quit: Ушел)
09:31:56FromDiscord<ElegantBeef> Well it highlights, which i thought it was doing through LSP
09:32:00FromDiscord<kodkuce> https://media.discordapp.net/attachments/371759389889003532/783264118756212746/2020-12-01_103147.png
09:32:24FromDiscord<ElegantBeef> What's your code evee?
09:32:26FromDiscord<ElegantBeef> (edit) "evee?" => "eevee?"
09:33:44FromDiscord<ProfessorEevee> ||https://hastebin.com/zobisiwoti.nim||
09:34:24FromDiscord<ElegantBeef> Interesting solution
09:34:37FromDiscord<ProfessorEevee> I'm kind of proud of it, honestly
09:34:40FromDiscord<ElegantBeef> You dont save any computation doing that way though
09:34:56FromDiscord<ProfessorEevee> Well, to be fair it's been like a week since I've gotten into Nim
09:35:25PMunchWait, is that valid Nim code?
09:35:27FromDiscord<ElegantBeef> I'm just pointing out the `2020 - x - y in numbers` is going to be the same as a `for z in numbers`
09:35:56*NimBot joined #nim
09:36:04PMunchOooh, it's (2020 - x) in numbers :P
09:36:54PMunchHow about sorting the numbers first and then binary searching your way to the solution?
09:37:16narimiranPMunch: that is probably much much faster than my simple optimization
09:37:27FromDiscord<Idefau> i saw a solution that sorted the input first
09:37:27PMunchWait narimiran, was that timing for part1 or part2?
09:37:35narimiranPMunch: both
09:37:36FromDiscord<Idefau> might try that
09:37:44PMunchBoth? in 0.5ms?
09:37:46FromDiscord<ProfessorEevee> Yeah I have no clue, the people over at Python are using combinations to solve it
09:37:54narimirani search for both in one pass
09:38:06FromDiscord<ProfessorEevee> get every possible combination of the numbers
09:38:13FromDiscord<ProfessorEevee> and see if they add to 2020 then multiply
09:38:34PMunchnarimiran, huh
09:38:39PMunchDid you post your code?
09:38:49narimiranPMunch: not yet
09:39:10narimiranwell, it is on reddit, if you want to search for it
09:39:35narimiranbut usually i don't publish my code till the afternoon
09:40:23narimiranPMunch: running it manually, it is around 7ms
09:42:42PMunchHmm, the binary search solution would only work for part1 though..
09:43:52FromDiscord<PizzaFox> how does one properly benchmark this when it takes sub millisecond to execute
09:44:18narimirancreates on input with 200,000 lines? :P
09:44:20narimiran*an
09:44:21Zevvrun it a million times
09:44:21FromDiscord<ElegantBeef> you can use the time modules in Nim
09:44:35FromDiscord<PizzaFox> surely monotimes is better suited than times
09:44:41Zevvmumble mumble optimization mumble evil mumble
09:44:44FromDiscord<ElegantBeef> who said use times?
09:44:51ZevvcpuTime() is the way to go
09:44:59FromDiscord<PizzaFox> > time modules↵i was 1 character off
09:46:37FromDiscord<ElegantBeef> I mean either one should work they're both ns accuracy iirc
09:46:53FromDiscord<PizzaFox> isnt cputime exported by 2 modules for some reason
09:47:06FromDiscord<ElegantBeef> It's in `times`
09:47:14FromDiscord<PizzaFox> is it in os or something
09:47:22FromDiscord<PizzaFox> i swear there was some cpu method that was in 2 modules
09:47:24FromDiscord<PizzaFox> and did the exact same thing
09:48:35FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G8f
09:49:06FromDiscord<ElegantBeef> Damn everyone has a faster impl than me
09:49:12FromDiscord<ElegantBeef> But i like my 1 solution fits all 😄
09:49:14voltistIs there a standard library proc to find the most common item in a seq?
09:49:16FromDiscord<Rika> Hello what is up
09:50:31FromDiscord<ElegantBeef> If it's not in sequtils or algorithm probably not
09:51:06FromDiscord<ProfessorEevee> You can probably copy the list, remove duplicates and use `count`
09:51:27FromDiscord<ProfessorEevee> then get highest value from that
09:52:01FromDiscord<PizzaFox> surely iterating once and adding some numbers in a frequency table is the most straightforward way
09:52:26PMunchnarimiran, and what number are you looking at?
09:52:40voltistYeah I've implemented something but its pretty slow
09:52:41FromDiscord<ElegantBeef> Just clear the list and then you're certain the most common elements are there 😄
09:52:48voltistIt should do until I actually tun into a problem
09:52:52voltistrun*
09:52:55PMunchCountTable?
09:52:59narimiranPMunch: either first or last line
09:53:18PMunchAh, tha final results line
09:53:32PMunchHmm 0.8ms
09:53:47voltistPMunch: Oo! Yes!
09:54:32PMunchWhat CPU do you have narimiran?
09:54:44PMunchJust trying to guess at a comparison of numbers :P
09:54:53narimiranryzen 7 3700x
09:55:00narimiran3.6 Ghz
09:56:32PMunchAh, so you do have a slightly higher single-core rating than I do: https://www.cpubenchmark.net/compare/AMD-Ryzen-7-3700X-vs-Intel-i7-4770K/3485vs1919
09:56:56Clonkk[m]Quick question, I'm trying to generate a C header from a simple Nim file. All my the exported type / proc are marked with {.exportc.}. I use `` nim c --header --noMain --noLinking file.nim`` but there is no output
09:57:21Clonkk[m]I was expecting a ``file.h``
09:57:33voltistPMunch: Creating a count table then iterating over it to find the largest value is orders of magnitude faster. Thanks for the tip!
09:57:50PMunchNo problem :)
09:58:25PMunchBy the way, you don't have to iterate the CountTable, it has a largest proc
09:58:39FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G8h
09:58:41FromDiscord<ProfessorEevee> idk what to believe anymore
09:58:57narimiranthis reminded my what AoC tasks i like the most: the ones it takes 5 minutes to solve, and then we spend 55 minutes trying to optimize them
09:59:04PMunchPfft, that's nothing, try to optimise it to negative numbers!
09:59:17PMunchHaha, that's the fun part :P
09:59:37FromDiscord<ProfessorEevee> I don't even know how to optimize mine
09:59:42PMunchHmm, I think my optimisations end up taking more time because of the small input set..
09:59:57voltistPMunch: Similar result but cleaner code, thanks again
10:00:30FromDiscord<ProfessorEevee> What does 0.01 even mean. what kind of time is this
10:00:49PMunchvoltist: Yeah I wasn't sure if it was any faster, but at least it's cleaner :)
10:00:57PMunch0.01 time
10:01:00narimiransmall time
10:01:06PMunchIt is 1/100th time
10:01:47PMunchSorting the table is a net loss :P
10:02:14*Q-Master joined #nim
10:03:35narimirantable? where did table come from?
10:04:18PMunchErr, I meant sorting the seq
10:04:19FromDiscord<ProfessorEevee> Alright, well.. this was fun. Too bad the first day doesn't count, though
10:04:40PMunchI was thinking of Voltist problem :P
10:07:47*apahl quit (Ping timeout: 272 seconds)
10:08:34*apahl joined #nim
10:11:17PMunchEh, this is as far as I bother to go: http://ix.io/2G8p
10:11:29PMunchWould work a lot better on a bigger list though
10:11:32FromDiscord<kodkuce> i did my advent like pro tard with 3 loops
10:11:50PMunchHaha, my initial solution was like that :)
10:11:54FromDiscord<ElegantBeef> It's quicker than my method 😄
10:12:25FromDiscord<ElegantBeef> But mine uselessly works on all versions of this problem, so i guess winning?
10:12:54FromDiscord<ElegantBeef> I keep saying that but i dont know, seems like a weird way to do aoc
10:13:34PMunchOn all versions?
10:13:36FromDiscord<kodkuce> i expect next advent to be like 20 numbers
10:13:44FromDiscord<kodkuce> loops of doom
10:13:55FromDiscord<ElegantBeef> Yea both two versions and any theoretical alterations
10:14:14FromDiscord<ElegantBeef> No matter the depth or the number if it's there it can do it
10:14:38*habamax_ joined #nim
10:15:34FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=2G8q if you didnt look at mine previously
10:16:04PMunchHaha, modified mine to do 4 numbers, slightly less than twice the time of the 3 version, which is pretty good
10:16:14PMunch(There's no solution for that in my set though)
10:17:45FromDiscord<ElegantBeef> Nice, my 3 takes .022 due to actually finding one, my 4 takes 3 seconds
10:17:49PMunchOh right
10:18:00*habamax_ quit (Client Quit)
10:18:13PMunchMy 3 takes 0.0007 something and my 4 takes 0.0012 something
10:18:32FromDiscord<ElegantBeef> Now take your optimizations and marry them with mine 😄
10:18:35PMunchThe four doesn't find a solution though
10:19:12ForumUpdaterBotNew thread by Lihf8515: Nim compiled DLL, using Powerbuild programming language call, parameter return result garbled code., see https://forum.nim-lang.org/t/7183
10:19:38PMunchWell it is basically just sort the seq first, then only loop numbers larger that the outer loop, and break early if the sum gets too large (because they are sorted it can't become smaller this loop anyways).
10:19:44FromDiscord<kodkuce> i dont want to look yours atm its spoiler for me, will check on end to see how could have done stuff beter
10:21:10FromDiscord<ElegantBeef> Well mine is how to do it for N steps, so it's not really "better"
10:21:27FromDiscord<ElegantBeef> It took me like 20 minutes to solve how to do it
10:21:43FromDiscord<ElegantBeef> But i seen the first problem and the second and had to do it in one way or i wouldnt have been satisifed
10:23:40voltistSometimes debugging is pretty
10:23:41voltisthttps://raw.githubusercontent.com/dizzyliam/randomImgs/master/out.png
10:23:50FromDiscord<ElegantBeef> It's always pretty
10:35:15ForumUpdaterBotNew thread by Mratsim: Nimbus -> Ethereum 2 launch is imminent 12PM UTC., see https://forum.nim-lang.org/t/7184
10:37:55*kiwi_83 joined #nim
10:41:28Zoom[m]PMunch: >>You can easily have a program that seems to do the right thing, but does something horribly wrong"
10:41:29Zoom[m]That's why you write a ton of tests and check for all possible inputs. If it still outputs the right thing, then it doesn't matter what's inside. Or, more realistically, your tests are not working.
10:45:39FromDiscord<ProfessorEevee> Man. I'm getting the weirdest errors trying to make an async HTTP client from sockets
10:45:58FromDiscord<ProfessorEevee> sent a code paste, see https://play.nim-lang.org/#ix=2G8v
10:46:50*Vladar joined #nim
10:52:43*jmiven quit (Quit: reboot)
10:53:29*jmiven joined #nim
10:56:38voltistIs there a standard library proc to 'rotate' an array or seq by some amount. As in, increase the index of all items by n and move overflow to the start
10:57:13supakeenvoltist: In the `algorithm` module you have `rotateLeft`, etc.
10:57:24supakeenhttps://nim-lang.org/docs/algorithm.html#rotateLeft
10:57:26voltistOh awesome thanks
11:00:55*crem joined #nim
11:09:08*abm joined #nim
11:11:01voltistSo I just changed a section of code so that it handles a tuple with two fields instead of a array of length two, and it's way faster. Any reason why this would happen?
11:11:57supakeenWithout going into specifics for tuples it might be assumed that they will never change.
11:12:04supakeen(I don't *know* the specifics)
11:23:26kiwi_83[is it better to omit the default value's type in a function arg? I thought making the compiler detect the type would be slower
11:23:52kiwi_83also why cannot a ternary conditional be used without indentation? I wish to do 'proc ... = if blah blah else blah blah'
11:24:55supakeenYou can wrap them in parens.
11:25:00supakeenAnd for the first bit, is it actually slow?
11:27:02kiwi_83oh I'm assuming the inference would take time, although probably negligible
11:27:19supakeen`proc foo(x: int): int = (if x > 2: result = 1 else: result = 2)`
11:27:21kiwi_83thanks, what keywords should i use for this parentheses notation
11:27:23supakeenWorks fine.
11:27:40supakeenAh, I don't think one should worry too much about speed unless it becomes a problem :)
11:28:09kiwi_83fair enough! thanks :D
11:28:43kiwi_83can someone helpme read this? `proc multiReplace(s: string; replacements: varargs[(string, string)]): string {...}` this varargs bit means it can take a dictionary mapping from strings to strings right?
11:29:12supakeenvarargs means it takes multiple of that argument
11:29:25supakeenand they end up in a sequence of that name
11:29:43kiwi_83umm
11:30:22kiwi_83so is it a tuple of strings then?
11:30:27kiwi_83im a bit confused
11:30:40PMunchYeah it's a variable amount of tuples
11:30:47supakeenhttps://play.nim-lang.org/#ix=2G8K
11:30:59supakeenIn that case it'd be a bunch of tuples of strings :)
11:31:48PMunch!eval echo "hello world".multiReplace(("hello", "goodbye"), ("world", "kiwi_83"))
11:31:52NimBotCompile failed: /usercode/in.nim(1, 19) Error: attempting to call undeclared routine: 'multiReplace'
11:32:04PMunch!eval import strutils; echo "hello world".multiReplace(("hello", "goodbye"), ("world", "kiwi_83"))
11:32:09NimBotgoodbye kiwi_83
11:32:12supakeen(needs strutils)
11:32:14supakeenah yea
11:32:45kiwi_83ahh sweet, now I know how to parse that! thanks
11:33:05*schmaydo joined #nim
11:33:19supakeenIt's `varargs[T]` and the `T` or type in this case is a `(string, string)` or a 2-tuple of `string` :)
11:33:31schmaydowhy do case statement macros need the macro to be called match? shouldn't it be called `case` instead? it says here https://nim-lang.org/docs/manual_experimental.html#case-statement-macros
11:34:13kiwi_83oh wait! PMunch is that the UFCS in action?
11:34:31kiwi_83you are calling multiReplace on a string directly instead of passing as the first arg!
11:34:43kiwi_83UFCS = uniform function call syntax iirc
11:34:45FromDiscord<lqdev> that's method call syntax, yes
11:35:01FromDiscord<lqdev> more popularly known as UFCS
11:35:08supakeenpopularly :o
11:35:17supakeenwhat's the popular name for command syntax then
11:35:34FromDiscord<lqdev> there is none
11:35:53FromDiscord<lqdev> it's just "command call syntax" and afaict it's kinda nim-specific
11:35:59supakeenIt is.
11:36:11supakeenSo, function call syntax, command call syntax, uniform function call syntax.
11:37:10PMunchkiwi_83, indeed :)
11:37:30schmaydoi think `case` would make more sense for case statement macros, but if `match` is being used then it should both be supported
11:38:01PMunchI tend to use that style when the procedure sounds like a verb
11:39:05PMunchWell, I tend to use it quite a lot. Means I can write out a statement as I think, instead of having to jump back and forth to put brackets and arguments.
11:41:12kiwi_83 oh yes that does sound convenient
11:45:42kiwi_83what does 'ordinal type expected' error mean
11:45:57FromDiscord<lqdev> that an ordinal type was expected.
11:46:48kiwi_83um looks like I gave "A" (a string?) but 'A' a char was expected
11:46:58kiwi_83didn't know there was a distinction between both types of quotes
11:47:12narimirannim is not python
11:47:21kiwi_83ninp
11:48:59kiwi_83how do I raise this error? https://nim-lang.org/docs/system.html#ValueError
11:49:12schmaydowhat is 1 + 1
11:49:14*schmaydo quit (Remote host closed the connection)
11:49:24kiwi_83I tried `raise ValueError('blah blah')` but that doesnt work
11:49:29FromDiscord<haxscramper> `raise newException(ValueError, "Message")`
11:49:37kiwi_83ooof thanks
11:51:35narimiran!eval proc whatIsLove: string = "baby don't hurt me"; echo whatIsLove()
11:51:38NimBotCompile failed: /usercode/in.nim(1, 27) Error: expression '"baby don\'t hurt me"' is of type 'string' and has to be used (or discarded)
11:52:16kiwi_83i like how the assignment for variables AND functions is the = symbol
11:52:48narimiranbad bot, that works in the playground
11:53:21kiwi_83!eval echo 42
11:53:25NimBot42
11:53:34FromDiscord<Imperatorn> What IRC-client(s) do you use?
12:01:32kiwi_83anyone nkow if there's a zeal docset for nim? can't seem to find anything
12:02:48FromDiscord<flywind> https://forum.nim-lang.org/t/5050#33933
12:02:49PMunch@Imperatorn, I use HexChat
12:03:24supakeenHuh, how do I assert that a proc raises a certain exception in my test suite? :)
12:03:28PMunchnarimiran, wait, it does?
12:06:01*supakeen quit (Quit: WeeChat 2.9)
12:06:35*supakeen joined #nim
12:08:42kiwi_83thanks flywind
12:11:15*matthias_ joined #nim
12:13:09*letto quit (Quit: Konversation terminated!)
12:13:53kiwi_83is there any prerequisite knowledge needed before going through the compiler details in the nim docs?
12:17:51triblyi'm trying to use a template for benchmarking the aoc code, but i'm confused on how to use it properly. any tips? https://p.tribly.de/m-FwfPwz/ (i'm new to nim)
12:20:06FromDiscord<flywind> sent a code paste, see https://play.nim-lang.org/#ix=2G97
12:20:21FromDiscord<ProfessorEevee> I had ended up using the `time` command to see mine
12:21:21FromDiscord<flywind> https://github.com/xflywind/timeit/blob/ba4e90546af33632aea06208bc0f2d33418d2558/src/timeitpkg/main.nim#L146
12:21:42FromDiscord<flywind> You could ref to this
12:21:50FromDiscord<flywind> (edit) removed "to"
12:22:09narimiranPMunch: well, in multiple lines :P
12:22:53narimirangive us braces, this whitespace stuff is shite!!
12:24:37*shad0w_ joined #nim
12:24:47FromDiscord<flywind> you should use this I guess.
12:24:52FromDiscord<flywind> sent a code paste, see https://play.nim-lang.org/#ix=2G9c
12:25:34FromDiscord<flywind> And there is already a great library to benchmark codes. https://github.com/disruptek/criterion
12:32:25matthias_I'm having some trouble getting Prologue and Norm working together. It's a GC issue but I'm out of my depth. Basically, if I have a Prologue handler that calls `db.insert(foo)` I get a compiler error, `type mismatch: got <Prologue, string, proc (ctx: Context): Future[system.void]{.locks: <unknown>.}> but expected proc get(app: Prologue; route: string; handler: HandlerAsync; name = ""; middlewares: openArray[HandlerAsync] = @[]) first
12:32:27matthias_ type mismatch at position: 3` That indicates Norm is not GC safe, and Prologue requires this, but I'm unclear how to proceed (or if I can)
12:34:05matthias_FWIW, I can run `select` statements w/ Norm just fine, only `inserts` so far are giving issues. And it looks more like an issue with ndb/sqlite rather than Norm itself.
12:40:53FromDiscord<flywind> What happened, if you add `{.gcsafe.}` to your async procs.
12:42:15FromDiscord<bloomhead> But then I don't get any output from the proc. Anyway, I'm gonna try criterion, thanks
12:42:59FromDiscord<flywind> you could `echo part1()`
12:44:34kiwi_83is it idiomatic in nim to fully qualify a function call with the package name?
12:44:42FromDiscord<mratsim> no
12:45:01FromDiscord<mratsim> but if your project gets very large with lots of dependencies that makes sense
12:48:18*abm quit (Quit: Leaving)
12:51:29FromDiscord<exelotl> I'm considering that approach in some parts of my GBA library. Like I currently have `irqInit()` (for interrupt requests) and `tteInit()` (for tonc's text engine), but would prefer to write `irq.init()` and `tte.init()`
12:52:01matthias_flywind: It yells at me that my proc is not gcsafe :) It does give me a chain of reasoning though, that ultimately leads me to `'tryWithStmt' is not GC-safe as it performs an indirect call via 'body'`
12:54:06FromDiscord<flywind> Maybe you could open an issue for it. if you could make sure `tryWithStmt` is `gcsafe`, you could use `{.cast(gcsafe).}: insert()`
12:54:50FromDiscord<flywind> Is it a warning instead of error with single thread?
12:55:57matthias_So it seems that it possibly uses a closure, which is seemingly not GC safe. The call signature for it: `proc tryWithStmt(db: DbConn, query: SqlQuery, args: seq[DbValue], body: proc(stmt: Pstmt): bool {.raises: [], tags: [].}): bool =`
12:56:11FromDiscord<flywind> https://github.com/nim-lang/RFCs/issues/142
12:56:12disbot➥ Proposal to remove the `.gcsafe` effect from Nim ; snippet at 12https://play.nim-lang.org/#ix=26qX
12:57:00FromDiscord<flywind> `gcsafe` is really painful in Nim language.
12:57:00FromDiscord<flywind> https://forum.nim-lang.org/search?q=gcsafe
13:02:39matthias_So it seems. Thanks for the assist! Gets me pointed in the right direction.
13:03:36kiwi_83has anyone used a queue processing thingy like celery with nim for web apps?
13:04:00FromDiscord<flywind> @matthias No problem, `Prologue` has it own discord channel. Maybe you could ask there too.
13:11:58kiwi_83just discovered that nim has an advent of code event
13:12:05kiwi_83can I do the day 1 now? looks like day 2 is on :/
13:12:19narimirankiwi_83: you can even do stuff from 2015
13:12:28kiwi_83ohhh lmao nice!
13:13:22FromDiscord<mratsim> But it's still Day1 Dec 1 is day one no?
13:15:51narimiranhttps://adventofcode.com/2020/day/1 this is today's task (until tomorrow at 5 am UTC)
13:17:33*kiwi_83 quit (Ping timeout: 260 seconds)
13:19:44ForumUpdaterBotNew thread by Miran: Nim 1.4.2 is out!, see https://forum.nim-lang.org/t/7185
13:19:54narimiran^^^ nim 1.4.2 is out ^^^
13:21:00shad0w_ooo shiny ?
13:21:51shad0w_updated : P
13:22:50FromDiscord<Yardanico> I'm honestly surprised the forum updater bot has been running without issues for such a long time
13:23:02FromDiscord<Yardanico> And yay to 1.4.2 :)
13:28:00FromGitter<sambeckingham> hola
13:29:15FromDiscord<Yardanico> Konnichiwa
13:29:57FromGitter<sambeckingham> Does anyone know of a CLI framework/library for Nim? Something like Cobra for Golang?
13:31:23FromDiscord<Digitalcraftsman> sent a long message, see http://ix.io/2G9s
13:32:53FromDiscord<Yardanico> @sambeckingham take a look at cligen, there's also docopt and a few others
13:33:30FromDiscord<Yardanico> @Digitalcraftsman you need to import it as "import std/enumerate"
13:34:01FromDiscord<Yardanico> From a certain point in time in the past all new Nim stdlib modules are only available in the std "namespace"
13:34:06FromDiscord<Yardanico> You can use it for older modules too
13:34:36FromDiscord<Yardanico> Like "import std/[strutils, os, enumerate]", you get the idea
13:35:03FromDiscord<Digitalcraftsman> thanks a lot @Yardanico. I stumbled upon a this a while ago but I should remember this for imports in the future
13:35:51FromDiscord<Yardanico> Yeah, it takes some time but it's better to remember to use std for stdlib imports :)
13:51:24FromGitter<bung87> how can a make a type definition file used by all file but keep private properties visible to specific file
13:57:53*hmmm joined #nim
13:58:00hmmmwoah this advent of code stuff is super cute
13:58:45supakeenAlways has been :)
13:59:06supakeenIt's a great way to get to grips with a new language or just have 'fun' discussions about optimizations.
13:59:18Zevvor over-optimizations
13:59:21Zevvbunch of nerds
13:59:45supakeen:D
14:00:21supakeenarme zevv
14:01:23*dddddd joined #nim
14:06:19FromDiscord<mratsim> I remember optimizing prime gneeration for project euler 🙂
14:08:59*lritter joined #nim
14:20:37*shad0w_ quit (Ping timeout: 264 seconds)
14:23:25*shad0w_ joined #nim
14:30:23FromDiscord<Zachary Carter> Doing AOC this year - do I just hardcode the input in my solution?
14:30:30FromDiscord<Zachary Carter> for problem number one I mean?
14:33:01FromDiscord<Idefau> if you want too, or you download the file and read it from there
14:33:19hmmm:O
14:33:21FromDiscord<Idefau> hardcoding the input in your code will become hard in the long term tho, since the input might get really huge
14:33:25hmmmwe have a new nim 142
14:33:29FromDiscord<Idefau> yup
14:33:36FromDiscord<Zachary Carter> okay thanks
14:33:39hmmmhow am I supposed to upgrade from 140
14:33:45FromDiscord<Zachary Carter> do you use choosenim?
14:34:19hmmmiirc I just shoved some files in some folder the first time
14:35:05FromDiscord<Zachary Carter> I guess shove new files in the folder?
14:35:20FromDiscord<Zachary Carter> or delete your old Nim install and use choosenim
14:35:27FromDiscord<Zachary Carter> or install from source
14:35:51hmmmI think I will go with the choosenim route just for change, but idk what to do with the other installation
14:36:03hmmmshould I let choosenim take care of it?
14:36:27FromDiscord<Zachary Carter> choosenim won't as it sets up its own directory structure for storing Nim installations
14:36:30FromDiscord<Zachary Carter> so I would just delete it
14:36:47hmmmsigh I liked 140 :|
14:36:54hmmmbut you can't stop progress
14:37:02hmmmok I'll try it
14:40:20*vicfred joined #nim
14:40:31*Vladar quit (Quit: Leaving)
14:47:15hmmmchoosenim is warning me that the exes are shadowed by 1.4.0 exes
14:47:27hmmmdon't know if I should worry >.>
14:50:04PMunchHave you installed 1.4.0 some other way than choosenim?
14:50:14hmmmyes
14:50:22hmmmby shoving files in a nim folder in C:
14:50:48PMunchThen that's your issue I guess
14:51:03hmmmshould I just delete my precious 1.4.0?
14:51:05PMunchIf you run nim --version it will probably say 1.4.0 instead of 1.5.2
14:51:09PMunch1.4.2*
14:51:31PMunchBecause your path is set up to have your specially installed Nim before the choosenim one
14:51:39hmmmye it still show 1.4.0
14:52:05PMunchJust remove your local copy from the PATH
14:52:19hmmmthis I can do
14:53:17PMunchHmm, choosenim said Already built..
14:53:21hmmmcan I tell choosenim I'd rather have nimble on C: than Userpath?
14:53:36PMunchDid I update it this morning when I was too tired to remember it?
14:54:41hmmmok now nim version shows 1.4.2
14:54:58hmmmI guess we golden except I might need to update something on vscode
14:59:26*kiwi_83 joined #nim
15:00:07kiwi_83what's a cool nim tip
15:00:14kiwi_83s/cool/kool
15:02:09*natrys joined #nim
15:02:51FromDiscord<Rika> Write a macro
15:03:21kiwi_83do you use solarized?
15:04:35*hmmm quit (Quit: brb)
15:09:29*habamax quit (Quit: leaving)
15:12:07kiwi_83what is the equivalent of decorators from python in nim (assuming there is)
15:12:33narimiran!eval echo NimVersion
15:12:37NimBot1.4.0
15:14:39FromDiscord<Rika> Kiwi so what if I use solarized reeeee
15:14:59FromDiscord<Rika> Pragmas are the equivalent by the way
15:15:03kiwi_83it's a nice colorscheme that's all
15:15:07kiwi_83thanks!
15:15:09FromDiscord<Rika> Okay
15:16:22kiwi_83is this the only way to have a memoize pragma? https://github.com/andreaferretti/memo
15:18:12FromDiscord<Rika> Well no it’s the only one in existence though
15:18:37FromDiscord<Rika> You gotta know Nim is fundamentally different to Python
15:18:42FromDiscord<Rika> In many ways
15:18:51FromDiscord<Rika> Including to how decorators/pragmas work
15:19:42PMunchnarimiran, damn it, did my script break?
15:20:06*shad0w_ quit (Remote host closed the connection)
15:22:41PMunchOh wait, it is updating
15:22:55PMunchJust takes a while to build an image on the VPS :P
15:23:36narimiranexcuses, excuses
15:23:46PMunchJust wait and see :)
15:24:21ForumUpdaterBotNew post on r/nim by miran1: Nim 1.4.2 released, see https://nim-lang.org/blog/2020/12/01/version-142-released.html
15:24:36narimiranhuh?
15:24:52FromDiscord<Idefau> with 1.4.2 i can say that i used nim in the timespan of one major version
15:24:57narimiranahaaa, this is for reddit, not forum
15:26:52PMunchHmm, when I query a website with wget I manage to get the content. But with httpclient I get an empty string..
15:30:13PMunchHmm, I get a status 302 Found
15:30:18PMunchDoesn't it follow?
15:52:56*waleee-cl joined #nim
15:53:30FromDiscord<shadow.> https://media.discordapp.net/attachments/371759389889003532/783360132222287902/unknown.png
15:53:36FromDiscord<shadow.> wrong server
15:53:37FromDiscord<shadow.> whoopsies
15:53:40FromDiscord<shadow.> lmfao
15:53:50*hmmmmm joined #nim
15:54:33*vicfred_ joined #nim
15:54:59*vicfred quit (Read error: Connection reset by peer)
15:55:17*vicfred_ quit (Remote host closed the connection)
15:57:14PMunchThis is so weird..
15:57:33PMunchThe get from httpclient returns a different thing than what I can see in wget
15:58:10narimiranPMunch: you were supposed to update the bot, not to find bugs
15:58:30narimiransilly PMunch!
15:58:37PMunchIt is supposed to auto-update
15:58:44PMunchI'm working on something completely different .P
16:02:18ForumUpdaterBotNew thread by Jlindsay: Override decrement on indexed object, see https://forum.nim-lang.org/t/7186
16:09:46*Gustavo6046 joined #nim
16:09:50Gustavo6046Good afternoon!
16:10:09Gustavo6046Is it possible to build a binary that executes in a DOS16 environment? Say, if I use Nim to compile it only to C.
16:10:40Gustavo6046And then use a C compiler that targets DOS, like Watcom C.
16:12:35*abm joined #nim
16:14:39*Vladar joined #nim
16:15:00PMunchShould be possible
16:15:14PMunchAnd you can even tell the Nim compiler what C compiler you want to use
16:16:09Gustavo6046Ah
16:16:11Gustavo6046Ooh!
16:16:13Gustavo6046That is interesting.
16:17:07Gustavo6046Sadly, many C compilers today don't seem to support it themselves. At least not MZ, nor do they come with the DOS API headers (although I'm sure those can be written in Nim too, ironically). Although that does raise a few questions.
16:18:17FromGitter<sealmove> @PMunch Hi, just made an issue at binaryparse. There is an important bug/limitation. I will post an example soon.
16:20:26Clonkk[m]<PMunch "Should be possible"> Do all the module in stdlib support 16-bit OS though ?
16:22:04*vicfred joined #nim
16:24:48Gustavo6046For instance, how do I define the address of the VGA framebuffer in a Nim file? In DOS systems that is usually mapped to address 0xA0000.
16:25:21Gustavo6046In C that would be as simple as, < vga.h > const inline char *vga_framebuffer = 0xA0000;
16:27:12FromDiscord<mratsim> const foo = cast[pointer](0xA0000)
16:27:26*vicfred quit (Quit: Leaving)
16:28:05FromDiscord<mratsim> maybe the compiler will refuse compile-time addresses, so in that case use `let foo = cast[pointer](0xA0000)`
16:30:07*vicfred joined #nim
16:30:22Gustavo6046Ah, okay
16:30:33Gustavo6046I see. Thanks!
16:30:48Gustavo6046Clonkk[m]: I assume that it's as simple as not using those that don't work in a 16-bit environment?
16:34:14FromDiscord<mratsim> but those are not tagged
16:34:38FromDiscord<mratsim> in any case, in embedded you have special requirements anyway so you end up writing a lot of code yourself
16:36:51FromGitter<sealmove> @PMunch, ok I gave an example: https://github.com/PMunch/binaryparse/issues/9
16:36:53disbot➥ Custom encoder does not support extra parameters ; snippet at 12https://play.nim-lang.org/#ix=2GaG
16:37:31Clonkk[m]<Gustavo6046 "Clonkk: I assume that it's as si"> Yes, of course if you odon't use things that do not work in 16-bits you'll be fine. Problem is that you don't know in advance which does work and which don't. So it'll be fun debugging sessions where you don't know if the problem comes from your code or the std/lib.
16:38:08Clonkk[m]Which happens often in embedded with external dependencies anyway 🙂
16:39:24*Sembei quit (Ping timeout: 260 seconds)
16:40:48PMunch@sealmove, hmm
16:41:05FromGitter<bung87> @mratsim Do you know either chronos planed add a `readLineInto` api ?
16:45:31PMunchAh, I see what has happened.. I added the writer much later (hence why it's called binaryparse)
16:45:43*matthias_ quit (Quit: matthias_)
16:46:09*matthias_ joined #nim
16:47:18*hnOsmium0001 joined #nim
16:47:51*habamax joined #nim
16:50:01FromDiscord<reilly> I'm trying to write something asynchronous again, and as always it's headache-inducing. How do I return a `Future[Option[string]]`?
16:51:06FromGitter<bung87> with async pragma you do some(yourStr) or none(string)
16:53:12FromDiscord<reilly> I don't have to do something special for the Future part? `return some(response.body.parseJson()["id"].getStr())` Nimsuggest is complaining: https://hastebin.com/ugilicuwar.txt
16:54:06Gustavo6046Clonkk[m]: true :P
16:56:45FromGitter<bung87> async pragma will transform your code
16:58:29FromDiscord<sealmove> So is there any chance you can fix it easily? Or should I did into the code and make a PR?
16:58:48FromDiscord<sealmove> dig
17:02:14FromDiscord<reilly> Well, here's my proc. Feel free to tell me what I'm doing wrong. https://hastebin.com/okufufuben.nim
17:07:39reversem3currently I'm comping projects on osx , can I use the same compiler for Ubuntu 16 linux ?
17:08:07PMunchDefine compiler
17:08:16PMunchNim compiler, yes. C compiler, quite possibly
17:08:33reversem3yes using the nim compiler
17:08:43PMunchYes it can
17:08:50reversem3awesome thanks
17:09:58reversem3question , I'm writing a program to extract information from two different OS's, using SSH to do it ? Do you know of a better way?
17:10:18reversem3Async and SSH works really well so far
17:14:27PMunchWell if it works really well I'd say stick with it
17:15:05*Vladar quit (Quit: Leaving)
17:23:45*Vladar joined #nim
17:30:22FromDiscord<exelotl> Gustavo6046: do you need volatile access to that address?
17:30:36Gustavo6046I don't think so?
17:36:29ForumUpdaterBotNew thread by Mantielero: C++ wrapper - Any recommendation?, see https://forum.nim-lang.org/t/7187
17:37:50FromDiscord<exelotl> if you wanted to treat it like an array of bytes you might be better off with e.g. cast[ptr UncheckedArray[uint8]](0xA0000)
17:38:30ForumUpdaterBotNew thread by Snej: Where is `memcmp` in std lib? Or `cmp()` for byte sequences?, see https://forum.nim-lang.org/t/7188
17:38:36FromDiscord<exelotl> or if you know the size you could even do cast[ptr array[2048, uint8]](0xA0000)
17:39:09FromDiscord<Rebel> Is it possible to do a nested keepIf within sequtils?
17:39:26FromDiscord<Rebel> or a double list comprehension in Nim
17:43:37FromDiscord<shadow.> lol its funny you mention comprehensions that's what im tryna make rn lmao
17:43:40*Sembei joined #nim
17:44:27FromDiscord<haxscramper> If you don't need to use both variables then sure - just `mapIt(it.mapIt( ... ))`
17:45:01FromDiscord<haxscramper> Or you can try to use `std/sugar.collect` to use nested for loops
17:45:09FromDiscord<Rebel> Shadow are we doing the same thing? lol
17:45:21FromDiscord<Rebel> advent of code?
17:45:32FromDiscord<shadow.> lol i did advent of code earlier today
17:45:40FromDiscord<shadow.> the 2sum one?
17:45:50FromDiscord<shadow.> ive seen people asking about comprehensions but i havent had to use them for it?
17:46:04FromDiscord<shadow.> im just making comprehensions for fun
17:47:12FromDiscord<haxscramper> https://play.nim-lang.org/#ix=2Gb0 - not one-liner, but should work
17:47:52FromDiscord<haxscramper> And for 1d sequence just remove nested `collect`
17:48:52FromDiscord<reilly> Is there some documentation I can read to figure out how to async in Nim? I haven't made any progress.
17:52:48FromDiscord<Rebel> Hot thanks hexscramper
17:52:59FromDiscord<Rebel> Asyncdispatch? The manual? Pretty good resources for async
17:53:03FromDiscord<Rebel> What are you trying to do?
18:02:15FromDiscord<reilly> Code that's giving me problems: https://hastebin.com/okufufuben.nim The problems in question: https://hastebin.com/ubaxelodeq.txt
18:04:12FromDiscord<For Your Health> How do you go about including c source code in your project? I am having a really hard time finding resources to learn about this.
18:05:02FromDiscord<For Your Health> So say I have some wrapper `proc testFunction: cint {.importc, header: "test.h".}`
18:05:19FromDiscord<For Your Health> How do I compile `test.c`
18:14:26FromDiscord<mratsim> {.compiler: "test.c".}
18:14:29FromDiscord<mratsim> (edit) "{.compiler:" => "{.compile:"
18:16:03FromDiscord<mratsim> example: https://github.com/status-im/nim-blscurve/blob/master/blscurve/blst/blst_lowlevel.nim#L25-L26↵ABI: https://github.com/status-im/nim-blscurve/blob/master/blscurve/blst/blst_abi.nim↵header: https://github.com/supranational/blst/blob/aae0c7d70b799ac269ff5edf29d8191dbd357876/bindings/blst.h
18:17:17FromDiscord<mratsim> and the compiled C code includes all other C files so we only need to call that one: https://github.com/supranational/blst/blob/aae0c7d70b799ac269ff5edf29d8191dbd357876/src/server.c
18:18:02FromDiscord<mratsim> you can also use wildcards to compile all C files in a directory: https://github.com/numforge/agent-smith/blob/master/third_party/ale_build.nim#L67-L74
18:19:15FromDiscord<mratsim> @For Your Health ^
18:20:07*Zevv quit (Quit: Lost terminal)
18:21:03*Zevv joined #nim
18:21:14FromDiscord<For Your Health> Awesome, that seems to work. I will look into all of those links. Thank you for the information!
18:22:02*Zevv quit (Client Quit)
18:22:05*Q-Master quit (Quit: Ушел)
18:23:04*Zevv joined #nim
18:27:08*matthias_ quit (Quit: matthias_)
18:29:49*letto joined #nim
18:34:23FromDiscord<rutenl> hello this is my first time here, does Nim have a find function that accepts a lambda as argument? Similar to seq.filter but it only returns the first item that matches the condition. I couldn't find such a function in the sequtils documentation
18:38:32FromDiscord<rutenl> I've made a proc myself to achieve it for now, but I'd rather use built in stuff
18:38:34Zoom[m]While everyone's busy with AOC, I'm casually writng some RosettaCode: https://github.com/ZoomRmc/rosettacode_nim/blob/main/src/file_size_distribution.nim
18:38:49Zoom[m]Could anyone take a glance?
18:40:09FromDiscord<mratsim> look in algorithms
18:40:19Zoom[m]I'm a bit concerned about sharing a bool between threads with a ptr, but I don't know an easier way to communicate between the main thread and a progress-bar thread
18:40:32hmmmmmzoomie I find your code style more airy than most of the rosetta nim code
18:40:52hmmmmmI mean I get that nim can be very concise but calling variables like "v" and "r" doesn't help a lot lol
18:40:55Zoom[m]What do you mean 'airy'?
18:41:04hmmmmmI mean readable
18:42:10Zoom[m]It's supposed to be educational => easily readable and self-documenting, reasonably so
18:42:20Zoom[m]Thanks
18:42:46hmmmmmalso why the first class guys have syntax highlighting and nim doesnt :|
18:43:00hmmmmmI am mildly enraged at this state of things
18:43:26*letto quit (Quit: Konversation terminated!)
18:45:26*habamax left #nim (#nim)
18:49:06*hmmmmm quit (Quit: brb)
19:01:01*letto joined #nim
19:05:36*Kaivo quit (Ping timeout: 240 seconds)
19:06:27planetis[m]Is it a good idea to store an nim set as an integer? Kinda weird that other json serialization libs dont implement this.
19:08:23*Kaivo joined #nim
19:09:50planetis[m]I dont know whats the point of BiggestInt and BiggestFloat, but I think you just want to use int and float
19:11:15planetis[m]also module strformat makes all the format stuff from strutils obsolete
19:11:40planetis[m]well no, it uses them under the hood but its more convenient
19:12:39*thomasross joined #nim
19:15:30Zoom[m]That's for me, right? (Besides your first message)
19:16:26Zoom[m]Doesn't seem to me using strformat could result in significantly simpler code in this case
19:17:26planetis[m]Yep, dont know, thought that you would like it
19:17:48Zoom[m]planetis: What I want to use is int64 and uint for indexing/counting, but it seems Nim stdlib doesn't support my wishes there
19:18:24leorize[m]1in Nim we would prefer Natural over uint
19:18:41leorize[m]1just because Natural is actually bound-checked
19:18:44Zoom[m]I'm not sure including some DSL in an educational piece of code is such a great idea, when it's not the point of attention
19:19:07Zoom[m]Ah, but it's 2 times smaller! :D
19:19:29*hmmm joined #nim
19:20:01planetis[m]What that would you write the high(int) for me?
19:20:27hmmmhey when you join irc it says latest version 1.4.0
19:20:31hmmmthat can't be true!
19:20:37planetis[m]...never used nimbot before lets see
19:20:48leorize[m]1because dom haven't update it
19:20:54hmmm:>
19:20:56Zoom[m]!eval high(Natural)
19:20:59NimBotCompile failed: /usercode/in.nim(1, 5) Error: expression 'high(Natural)' is of type 'Natural' and has to be used (or discarded)
19:21:00Zoom[m]nope
19:21:02planetis[m]!eval echo high(int64)
19:21:05NimBot9223372036854775807
19:21:36Zoom[m]!eval echo high(Natural)
19:21:39NimBot9223372036854775807
19:21:54Zoom[m]hmmm...
19:22:28Zoom[m]That's how good I am at reading the specs :(
19:22:29leorize[m]1Natural is defined as `range[0..high(int)]`
19:22:56Zoom[m]!eval echo high(uint64)
19:22:59NimBot18446744073709551615
19:23:02leorize[m]1* Natural is defined as `range[0..high(int)]`
19:23:03Zoom[m]Wait, I know that
19:24:50*Jesin quit (Quit: Leaving)
19:25:11Zoom[m]So uint and the unsigned gang aren't ordinal
19:25:37Zoom[m]But it promisingly says they will be `in a later version`
19:25:53leorize[m]1yea that's not happening
19:26:29Zoom[m]So you say unsigned aren't bound-checked?
19:26:31Zoom[m]Why is that?
19:26:55leorize[m]1because there are too many use cases for them not being bound-checked
19:27:21leorize[m]1in fact we tried to add bound checking to uint and it broke way too many things
19:27:26Zoom[m]That's a quirk, to say the least.
19:27:48leorize[m]1so currently we only type check the conversions to and from uint
19:28:13Zoom[m]Why not just add a wrappingAdd and such and start using unsigned for Natural?
19:28:47leorize[m]1because there wasn't a need for natural to be uint-big
19:29:42*Jesin joined #nim
19:29:59*tane joined #nim
19:31:44Zoom[m]Yeah, but when it happens, Nim programs will overflow 2 times faster
19:32:09Zoom[m]I mean, crash on IOOB
19:33:24Zoom[m]Again, probably it's all OK from the pov of practicality, just unusual
19:35:55Zoom[m]Why not make indexing with bare int a compile-time error?
19:39:26leorize[m]1because it may not be an error :)
19:39:43leorize[m]1when you're prototyping being able to express simple things matters a lot
19:39:56leorize[m]1there's also a compile-time array bound checker that's in development
19:40:11leorize[m]1other things took precedence atm though
19:41:18Zoom[m]For BiggestInt i just expected it to behave like intmax_t
19:42:03Zoom[m]...from stdint.h
19:42:19leorize[m]1it should work like that atm?
19:42:43FromGitter<HJarausch> Is it possible to "limit" the "effect" of a converter to part of a module? Thanks for a hint.
19:42:55Zoom[m]I hope so, just not sure why me using them drawn some attention.
19:49:14leorize[m]1Zoom: after you set `mainThreadBusy` to false you should `joinThread` to make sure that the worker is stopped before continuing
19:49:37leorize[m]1also please use result directly
19:50:29Zoom[m]leorize: ha, I actually wrote that, I've deleted the join accidentally while cleaning the code
19:50:58leorize[m]1using `result` enables optimizations allowing in-place construction so that no copying has to be done
19:51:30Zoom[m]leorize: "because it may not be an error :)" do you mean indexing with a negative number to aim some memory region outside of a collection?
19:51:37*jmiven quit (Quit: bye)
19:51:47*jmiven joined #nim
19:52:14FromDiscord<alehander42> Araq narimiran guys sorry for the ping
19:52:14leorize[m]1Zoom: I mean smt like: `seq.add 1; seq[0]`
19:52:59FromDiscord<alehander42> just asking if the nil pr needs more work before initial merging
19:53:06FromDiscord<alehander42> to know if i should plan some time for it
19:56:36Zoom[m]leorize: I don't get it. It's doable with Natural or uint :)
19:56:45FromDiscord<mratsim> @Zoom if you want to share a bool between threads use a ptr Atomic[bool] https://github.com/mratsim/weave/blob/master/weave/cross_thread_com/scoped_barriers.nim#L44-L57
19:56:56Zoom[m]Thank a lot for inspecting the code, I appreciate it a lot
19:58:45leorize[m]1@mratsim for something this simple do you even need atomics?
19:59:04Zoom[m]mratsim, that's great. Could you please explain/point somewhere so I could understand the possible source of a bug? Two threads, one "owns" the var, the other just looks at it
19:59:05leorize[m]1it doesn't matter if one or two cycles were wasted before the value updates
20:00:01leorize[m]1I don't know if the cost of atomic reads in a loop is worth it
20:03:14*hmmm quit (Ping timeout: 272 seconds)
20:03:44FromDiscord<Quibono> So ref objects are just like... objects you want to subclass but won't instantiate?
20:05:15FromDiscord<Recruit_main707> ref object is a managed pointer to an object
20:05:33FromDiscord<Quibono> When would you use it?
20:06:25FromDiscord<Recruit_main707> well, when you want your object, or int, or whatever type, to be heap allocated
20:07:18FromDiscord<shadow.> @Quibono like if you were making linked list nodes probably
20:07:43leorize[m]1when you need reference semantics
20:07:58leorize[m]1objects are value types
20:08:00leorize[m]1meaning that they copies
20:08:21leorize[m]1refs are references, so you can, uh, refer to them if that makes sense :p
20:09:22Zoom[m]leorize: could you please confirm my usage of a pointer is ok? I'm not sure my reasoning is correct.
20:09:48leorize[m]1yes that's fine
20:10:05leorize[m]1I would recommend using var-blocks so that they look more nim-ish
20:10:18Zoom[m]Thanks
20:10:28Zoom[m]More pascalishm :D
20:10:41FromGitter<deech> Is there a way to statically get the current `block` name inside the block?
20:10:59leorize[m]1yes and merge your type blocks while you're at it
20:11:02FromDiscord<Quibono> Second maybe silly question, I'm writing an API and I'm a little bit stuck on what's the best way to organize it. Should GET and POST be procs that other more specific procs reference, should endpoints be objects in an enum... should there just be one API proc that uses the args to figure out what type of connection it is?
20:11:13leorize[m]1@deech no, unfortunately
20:11:42kiwi_83would metaprogramming help there?
20:12:06leorize[m]1yes, it should be trivial
20:12:08FromGitter<deech> leorize[m]1: thanks!
20:14:52FromDiscord<Quibono> Like basically, what's the best way to format/think about an API for a website
20:17:21kiwi_83i've seen people use swagger for designing rest apis
20:20:16*Jesin quit (Quit: Leaving)
20:23:12leorize[m]1Zoom: `incStatsTempl` looks like it can be a func named `addFile`
20:24:18Zoom[m]It's remnants of a bigger version where I wanted it to be inlined. Should I add inline pragma, btw?
20:25:11*Jesin joined #nim
20:27:21*NimBot joined #nim
20:27:42leorize[m]1you're writing it for rosetta code, don't over complicates unless necessary :p
20:28:51Zoom[m]And if I weren't?
20:29:43leorize[m]1btw `quit` have a variant that takes a string, very useful for replacing the `echo-quit` pattern
20:31:00Zoom[m]BTW, shouldn't addFile be a proc, not a func? Strict Functions are coming, right?
20:32:09leorize[m]1strict functions doesn't affect var parameters
20:32:19leorize[m]1it only concerns refs
20:34:17Zoom[m]Hm, technically it's not a function then
20:35:56*leorize[m]1 sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/syxxxeuwrinMtMuBAUnXvMRq/message.txt >
20:36:04leorize[m]1just in case you prefer this style more
20:37:22Zoom[m]I'm doing it wherever I can. Have I missed it somewhere?
20:38:10leorize[m]1Zoom: well if you don't use var parameters it will the a function the way you expects :p
20:38:38Zoom[m]I'll leave it a proc then :P
20:39:26leorize[m]1in the main code
20:40:27FromDiscord<mratsim> @zoom the owner is the one who allocates and free the bool. but 2 can write as long as you ensure that the lifetime of that bool is sufficient.
20:40:39FromDiscord<mratsim> i;e. the owner must be the last user
20:41:53Zoom[m]I think I understand that. This is the case of `unsafe` code where I promise to not mutate the var from the other thread. I wish there was an immutable ptr type for that
20:42:24leorize[m]1strict funcs is exactly that :)
20:42:42leorize[m]1but then you have the print :p
20:42:58leorize[m]1well guess you gotta wait until we actually have immutable pointers
20:45:45Zoom[m]¯\_(ツ)_/¯ @leorize:envs.net: I scanned the code for ifs and almost al of them are used in this way already.
20:46:15leorize[m]1I guess you haven't pushed it to your github
20:50:34Zoom[m]Done. I didn't expect such a thorough audit, that's very kind of you
20:52:38*narimiran quit (Ping timeout: 272 seconds)
20:52:55Zoom[m]That's a more tight feedback loop than checking codewars solutions for sure. :D
20:53:12leorize[m]1np, the code you're putting out will be representing idiomatic Nim afterall :)
20:53:33leorize[m]1so line 48 there's still a same-line if
20:54:23leorize[m]1so is line 97 and 115
20:55:08leorize[m]1line 54 all of them are Natural so should just be grouped
20:55:27Zoom[m]Ah, so you meant I should split the line, ok
20:56:38leorize[m]192-94 should potentially be put into a try-finally or a defer block for exception safety reasons
20:58:28Zoom[m]I'm not sure I like that dangling assignment
20:58:57leorize[m]1and line 4, 60, 89, 90, 109, 112, 123 can use some spaces
20:59:10leorize[m]1Zoom: if you don't like it you can keep it as-is
20:59:43Zoom[m]I'll keep it in my extended version :P
21:00:10leorize[m]1instead of `contains` you can use the `in` operator
21:00:43leorize[m]1the `%` operator from strutils can be used in place of format, but I think format looks fine here
21:01:30Zoom[m]<leorize[m]1 "92-94 should potentially be put "> Huh, so you use exclusive ranges mentally, alrighty
21:02:08leorize[m]1I use inclusive range actually
21:02:20planetis[m]Anyone knows about casting nim builtin sets to ints?
21:02:37reversem3is it possible to connect to two separate connections using async ? I'm using ssh for the connection protocol
21:02:53leorize[m]1since if you put them in a defer block you need all of them or else that \r will be printed before the progress update finishes
21:03:32leorize[m]1planetis: not recommended, the sets can span over more than 8 bytes
21:05:02leorize[m]1nixfreak: I'm not sure what you're trying to do
21:05:46reversem3connect to multiple ssh sessions to extract OS stats
21:05:54reversem3using async
21:07:23Zoom[m]leorize: I'm still completely ignorant on error handling in Nim, gonna read the docs on that. And on testing facilities next
21:08:51planetis[m]Leorize thanks will research this further
21:10:12leorize[m]1nixfreak: sure? I don't know if we have any async ssh libraries though
21:13:39Zoom[m]Ok, so what's left is to change all the vars, funcs and methods to snake case and we're all set~!
21:19:16*mbomba joined #nim
21:20:12leorize[m]1if you do that I'll ban you :p
21:20:54*kiwi_83 quit (Quit: Connection closed)
21:23:23Zoom[m]¯\_(ツ)_/¯ You haven't ban PMunch yet. Don't know if he used snake case for rosetta, though
21:23:42PMunchWhat?! I haven't used snake case for ages!
21:23:54PMunchWell, apart from whenever I'm 1:1 copying code from C..
21:26:17Zoom[m]It's probably just me watching your streams in 360p then 😛
21:27:53Zoom[m]BTW, we should crowdsource Andreas a gift and order him a proper mike for his future talks.
21:30:14reversem3no I found a ssh library using async called ssh2
21:31:13*reversem3 sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/ZhQjGCqmBjBIYNTmoNiWmLKF/message.txt >
21:31:58PMunchZoom[m], ah my notifishower code does indeed have quite a bit of snake_case in it
21:32:12PMunchSimply because a lot of it is copied from xlunch and various C samples
21:32:32PMunchOne perk of Nim, with the right wrappers you can pretty much copy C code directly into your Nim code and it will be valid
21:33:23Zoom[m]Are you blushing right now?
21:33:35PMunchAnd by the way, if you didn't know Zoom[m] Nim is case-, and style-insensitive
21:33:39PMunchBlushing?
21:33:50*Q-Master joined #nim
21:34:11Zoom[m]I know, I'm just teasing in good spirits
21:34:29*Q-Master quit (Client Quit)
21:36:07PMunchI assumed you did, just wanted to be sure :)
21:36:32PMunchIt's one of the more uncommon features of Nim
21:37:55reversem3!help
21:42:22reversem3what does defer do ?
21:42:50*letto quit (Quit: Konversation terminated!)
21:43:38*letto joined #nim
21:47:28FromDiscord<UNIcodeX> reversem3: wraps the code in the block which follows, in a `try` block, with the code immediately following the `defer` as the `finally`
21:48:03reversem3Ok , is that in the manual somewhere ?
21:48:14reversem3I tried looking for it
21:49:11FromDiscord<UNIcodeX> https://nim-lang.org/docs/manual.html#exception-handling-defer-statement
21:49:34FromDiscord<UNIcodeX> or... just the manual page and `[CTRL][F]` and search for "defer"
21:50:29reversem3yep that was my problem I used the search box instead
21:50:30reversem3thanks
21:51:11FromDiscord<UNIcodeX> np
22:02:10reversem3so If I'm connecting to ssh using async and I call this proc
22:02:13*reversem3 sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/GEiXWCqVQypHKBqaxZcFZyzZ/message.txt >
22:04:52reversem3and then end it with waitFor, if I duplicate that proc with another and change the names. The only connection is the first one ?
22:06:04reversem3is it even possible to call on two seperate connections using asysnc?
22:08:07Zoom[m]waiting blocks
22:11:40reversem3So put the function in a block?
22:20:10*Vladar quit (Quit: Leaving)
22:28:13*abm quit (Quit: Leaving)
22:33:54*natrys quit (Quit: natrys)
22:42:27PMunchUhm... http://ix.io/2Gcu
22:46:13*tane quit (Quit: Leaving)
22:47:47*apahl quit (Ping timeout: 272 seconds)
22:48:15*apahl joined #nim
22:59:41*Gustavo6046 quit (Quit: WeeChat 2.9)
23:00:31*Gustavo6046 joined #nim
23:09:43PMunchUgh, why doesn't this work.. http://ix.io/2GcE
23:13:10*abm joined #nim
23:22:29FromDiscord<fwsgonzo> are there any plans to move towards borrow checking on the long term?
23:25:53PMunchDon't think so, why?
23:56:02FromDiscord<JSGRANT> @fwsgonzo Afaik no; But Nim's move semantics & deconstructors should be a good-enough solution "in this space" imo then ceeding a bunch of the structure of the language in trying to accommondate this.
23:58:53*PMunch quit (Quit: leaving)