<< 03-08-2020 >>

00:00:09disruptekvarriount: i thought about it and i think you could do that builder pattern with a global, maybe.
00:01:34disrupteki can't quite figure it out, though.
00:02:42disrupteki was trying to make a twice: that's similar to once: but executes only the second time through. but i'm failing, so i guess it's not what i thought it was.
00:04:05*SenasOzys quit (Ping timeout: 240 seconds)
00:07:38FromDiscord<Varriount> disruptek: A "twice"?
00:25:25*krux02_ quit (Remote host closed the connection)
00:31:26disruptekit's similar to once:
00:33:35*aenesidemus_ quit (Read error: Connection reset by peer)
00:42:37*Vladar quit (Remote host closed the connection)
00:59:41*Tlongir joined #nim
01:11:48*apahl quit (Ping timeout: 244 seconds)
01:13:57*apahl joined #nim
01:18:24*maier joined #nim
01:23:38*maier quit (Ping timeout: 264 seconds)
01:28:52*Tongir joined #nim
01:30:52*NimBot joined #nim
01:31:24*Tlongir quit (Ping timeout: 256 seconds)
02:00:04*audiofile quit (Quit: Default Quit Message)
02:28:14*vicfred_ joined #nim
02:28:53*voltist6 joined #nim
02:30:49*vicfred quit (Ping timeout: 264 seconds)
02:30:49*voltist quit (Ping timeout: 264 seconds)
02:30:50*voltist6 is now known as voltist
02:58:57*muffindrake quit (Ping timeout: 260 seconds)
02:59:26FromDiscord<tomck> Is there any way to import a module with parameters?
02:59:30FromDiscord<tomck> I have some code which uses a Table
02:59:39FromDiscord<tomck> but for testing purposes, it's convenient to use an OrderedTable instead
02:59:55FromDiscord<tomck> for the actual implementation, though, it works better without ordering
03:00:15FromDiscord<tomck> So can i declare a type to use 'by default', and allow the test code to change that?
03:00:25FromDiscord<tomck> what's the 'nim way' to accomplish this?
03:01:10*muffindrake joined #nim
03:02:06leorize@tomck a type alias would be a good bet
03:02:18FromDiscord<tomck> yes, can i alter that on import though?
03:02:36leorizeah, then you can't
03:02:51FromDiscord<tomck> sent a code paste, see https://play.nim-lang.org/#ix=2t0Y
03:03:09FromDiscord<tomck> sent a code paste, see https://play.nim-lang.org/#ix=2t0Z
03:03:20FromDiscord<tomck> (edit) 'https://play.nim-lang.org/#ix=2t0Z' => 'https://play.nim-lang.org/#ix=2t10'
03:03:25leorizewhat are you trying to do, though?
03:03:34leorizeand no, we don't support that
03:04:14FromDiscord<tomck> i have some code which uses a TAble
03:04:22FromDiscord<tomck> but for testing, it's better to use an OrderedTable
03:04:35FromDiscord<tomck> since then i get deterministic output given the same input
03:04:47FromDiscord<tomck> (whereas with a Table it's not defined what order you loop over the keys)
03:05:01FromDiscord<tomck> but i don't want to make my implementation use an OrderedTable just so that it's convenient to test
03:05:33leorizeI would advice against that sort of testing
03:05:45FromDiscord<tomck> what do you mean
03:05:59leorizesince with that you're basically testing if your implementation work correctly when you use OrderedTable
03:06:08FromDiscord<tomck> i'm fine with that
03:06:18leorizeif you want to use Table in practice, you should test with Table instead
03:06:30FromDiscord<tomck> yes, but it makes it basically impossible to test that
03:06:42leorizewhat exactly are you testing?
03:06:46FromDiscord<tomck> b/c the output it produces is ordered
03:07:02FromDiscord<tomck> i mean, it shouldn't matter, but a JS code generator for some IR i have
03:07:12FromDiscord<tomck> So i have some IR, and i want to generate javascript
03:07:40FromDiscord<tomck> It spits out function declarations + other code
03:07:58FromDiscord<tomck> with a Table, the order of these function declarations is undefined - which is fine in practice
03:09:45leorizeyes?
03:09:57FromGitter<wltsmrz> I'm trying to achieve something like this: https://play.nim-lang.org/#ix=2t11
03:10:05FromDiscord<tomck> that's it
03:10:11FromGitter<wltsmrz> Except that I don't want to err on compile if thing() isn't actually used
03:10:22FromGitter<wltsmrz> Is there a convenient way to replace the function body with {.fatal.} ?
03:10:47FromDiscord<tomck> the order is undefined which is fine in practice, but for when i want to test, it's pretty much impossible to verify without re-parsing the javascript & doing some really complex assertions
03:11:11FromDiscord<tomck> the javascript it produces runs the same though, regardless of function order
03:11:16FromDiscord<tomck> it's just a different string
03:12:12leorizeso basically you wanted to verify that the IR produces the same JS everytime?
03:13:59leorize@wltsmrz looks like you found an overflow within the compiler with that snippet, please report :)
03:16:21FromGitter<wltsmrz> I'm not sure.. in my particular case, the function is imported from C and then I'd get a fatal error regardless of whether it's used (pretty sure). This may be normal behavior
03:17:39leorizehttps://play.nim-lang.org/#ix=2t13
03:17:46*cyraxjoe quit (Quit: I'm out!)
03:17:49leorizeit's not a normal behavior :)
03:19:20*maier joined #nim
03:20:41*cyraxjoe joined #nim
03:24:19*maier quit (Ping timeout: 246 seconds)
03:26:56*sagax quit (Excess Flood)
03:27:49*hecanjog quit (Ping timeout: 264 seconds)
03:28:16*hecanjog joined #nim
03:28:24FromDiscord<tomck> leorize: yes, but when actually running i don't care about trivial things like order of the functions
03:34:06*vicfred_ quit (Quit: Leaving)
03:58:27*oprypin quit (Ping timeout: 260 seconds)
03:59:04*oprypin joined #nim
04:06:01*supakeen quit (Quit: WeeChat 2.8)
04:06:41*supakeen joined #nim
04:06:58*lritter joined #nim
04:07:47FromDiscord<Zachary Carter> tomck: you could use a define when compiling your tests and check that in the module
04:09:41FromDiscord<Zachary Carter> but uh - I agree with leorize - it'd be better to test with the actual data structure you plan on using in a non-test path and figure out how to adapt your test case
04:10:11FromDiscord<Zachary Carter> I can't imagine it being that difficult - couldn't you just sort the entries in the table before performing your checks?
04:11:59shashlick@Rika - https://github.com/zedeus/nimagemagick/pull/1
04:12:00disbotUpgrade to latest nimterop
04:15:31FromDiscord<tomck> @Zachary Carter no, the sorting is all within the implementation, it just accepts some IR and spits out a string
04:15:36FromDiscord<tomck> How does a define work?
04:15:51FromDiscord<Zachary Carter> `nim c -d:yourDefineHere test.c`
04:16:42FromDiscord<Zachary Carter> sent a code paste, see https://play.nim-lang.org/#ix=2t1a
04:17:05FromDiscord<Zachary Carter> (edit) 'test.c`' => 'test.nim`'
04:17:48FromDiscord<Zachary Carter> you could also potentially use a template
04:19:36FromDiscord<tomck> cool, i didn't know that - can i define stuff within nim, before importing?
04:20:05leorizeyou can, but it won't work like you'd expect
04:20:08leorizenim is not C :P
04:21:05FromDiscord<Zachary Carter> I'd use templates if you want to do things similar to what you'd use C's preprocessor directives for
04:21:50*narimiran joined #nim
04:22:29FromDiscord<tomck> how do i define stuff within nim? will it work with an include?
04:22:44FromDiscord<tomck> or how can i use templates to do that?
04:22:49leorize{.define: symbolHere.}
04:22:58leorizeuse it as a statement
04:23:12leorizeit's only undeprecated on latest devel
04:24:46FromDiscord<tomck> sent a code paste, see https://play.nim-lang.org/#ix=2t1c
04:25:15*vicfred joined #nim
04:25:16leorizeonly if you import tables before the include
04:25:18leorizebut yes
04:26:55FromDiscord<tomck> brill, thanks
04:28:07leorizeI'm a bit skeptical of the way you do tests
04:28:33leorizebut if it works, it works I guess
04:29:33FromDiscord<tomck> it's in a separate file, built as a separate binary, idc about dodginess when it's so constrained to a single file
04:30:43FromDiscord<tomck> plus the whole orderedtable/table thing might result in some really niche errors that get passed the test, but it's way better than nothing, and the alternative is to introduce a bunch more complexity / maybe even a javascript parser, which is gonna need its own set of tests
04:33:55FromDiscord<tomck> this include thing seems to work, that's cool
04:34:00FromDiscord<tomck> nim's pretty expressive turns out#
04:34:08FromDiscord<Zachary Carter> sent a code paste, see https://paste.rs/D4C
04:34:16FromDiscord<Zachary Carter> err you don't need the dirty
04:34:41FromDiscord<Zachary Carter> (edit) 'https://play.nim-lang.org/#ix=2t1g' => 'https://play.nim-lang.org/#ix=2t1f'
04:35:14FromDiscord<tomck> how does MyTable get into the module i'm testing? i don't understand
04:35:59FromDiscord<Zachary Carter> I was just showing how you could vary the type definition at compile time
04:36:30FromDiscord<Zachary Carter> not solving the import issue - you'd have to import or include that module
04:36:53FromDiscord<Zachary Carter> and if you rely on import the symbol needs to be exported
04:38:57voltistHmm interesting messages from Freenode "voltist6 is not a registered nickname ... You're now known as voltist"
04:39:03voltistI never changed my nick
04:39:28FromDiscord<Zachary Carter> do you have six sessions open in freenode?
04:39:38FromDiscord<Zachary Carter> if someone already has your nick it will just append a number to it I think
04:39:51FromDiscord<Zachary Carter> (edit) 'if someone ... already' => 'if someonelogged in'
04:40:00FromDiscord<Zachary Carter> anyways - back to vulkan stuff
04:40:07voltistHuh, interesting
04:40:19*vicfred quit (Quit: Leaving)
04:40:36voltistI'm logged in 24/7 so must be someone else trying to connect
04:46:45silvernode[m]is there a way to have getAppFilename() to not return the full path and instead only print the name of the file?
04:47:32FromDiscord<Zachary Carter> you can call splitPath on it
04:47:58FromDiscord<Zachary Carter> https://nim-lang.org/docs/os.html#splitPath%2Cstring
04:48:46silvernode[m]<FromDiscord "<Zachary Carter> you can call sp"> I figured I'd have to go that route, thanks for the reply.
04:50:38FromDiscord<Zachary Carter> np
05:02:10leorizeeither way a splitPath() would have to be done, since getAppFilename() get the data from the OS, which is usually a full path
05:16:43*zacts joined #nim
05:20:11*maier joined #nim
05:24:35*sagax joined #nim
05:25:30*maier quit (Ping timeout: 256 seconds)
05:31:12*apahl quit (Ping timeout: 260 seconds)
05:31:35*maier joined #nim
05:32:16*apahl joined #nim
05:32:45voltistIs there a proc to check the system bitdepth for ints?
05:51:20*solitudesf joined #nim
05:52:49FromDiscord<lqdev> @Zachary Carter in your example, the if should be a when because you can't use if with types
05:53:29FromDiscord<Zachary Carter> in which example?
05:54:07FromDiscord<lqdev> the one with createTableImpl above
05:54:12FromDiscord<Zachary Carter> well it works and compiles
05:54:20FromDiscord<Zachary Carter> I'm not defining any type in the template
05:54:20FromDiscord<lqdev> oh?
05:54:31FromDiscord<lqdev> that's kind of weird
05:54:47FromDiscord<lqdev> the template expands to an if statement no?
05:54:50FromDiscord<Zachary Carter> but yes you could do that to when
05:55:11FromDiscord<Zachary Carter> (edit) 'to when' => 'too with `when`'
05:55:48FromDiscord<Zachary Carter> oh yeah - you're right sorry
05:56:08FromDiscord<Zachary Carter> and does expand to a conditional
05:56:15FromDiscord<Zachary Carter> I'm sleepy
05:56:36FromDiscord<Zachary Carter> but I don't think it matters - I don't think that person is going to use a template 🙂
05:57:03FromDiscord<lqdev> sure thing, just pointing out a thing i noticed :)
05:58:08FromDiscord<Zachary Carter> yeah - thanks for doing that just in case I confused anyone else haha
06:26:56*zacts quit (Ping timeout: 246 seconds)
06:30:12*PMunch joined #nim
06:49:05*Vladar joined #nim
06:49:18*Vladar quit (Client Quit)
06:50:03*Vladar joined #nim
07:01:04*endragor joined #nim
07:05:48PrestigePMunch: welcome back
07:06:15PrestigeBtw the day you left, I added the hot config reloading into nimdow
07:18:24PMunchOh cool
07:18:34PMunchGuess I'll have to daily drive it then as I promised :)
07:18:42PMunchAnd thanks for the welcome :)
07:21:25FromGitter<alehander92> wow PMunch is alive
07:21:26PrestigeThere are some issues with programs I don't really use, been working on solving those problems
07:21:36PMunchalehander92, hooray!
07:22:14Zevvhee the munch is back!
07:22:20FromGitter<alehander92> did you go to russia or somethjing
07:22:32FromGitter<alehander92> did you fight a war
07:22:46FromDiscord<Rika> 😮 pmunch is back
07:24:18PMunchHaha, no I just went on vacation
07:24:35PMunchBut in tents and log cabins in the mountains, so not a whole lot of internet :P
07:29:05PMunchHuh, I've got a badge on GitHub saying I've contributed code to the "Arctic code vault" neat!
07:29:35PMunchOh nice, Nim is in the vault :)
07:31:38FromGitter<alehander92> many of your own repos
07:31:41FromGitter<alehander92> might be there as well
07:31:42FromGitter<alehander92> iirc
07:32:25PMunchI tried to figure out, but couldn't find a way to see all repos I've contributed to in the vault..
07:33:28PMunchAh "[...] we took a snapshot of all active public repositories on GitHub to archive in the vault." so probably quite a few of my projects then :P
07:43:34PrestigePMunch: there's a new key binding you'll want to set in the config, for hot reloading. It's all documented in the wiki
07:55:28PMunchGreat, I'll look into it :)
07:56:14FromDiscord<Varriount> PMunch: Just think, all your best and worst code, conserved in the Arctic
07:56:52FromDiscord<Varriount> What will future readers think?
07:58:27PMunchDoes the vault contain git blame information?
08:00:04PMunchWe joke that cobolt and fortran are ancient technologies that some poor person has to maintain somewhere. Imagine being the unlucky fellow who in thousands of years finds the vault and is tasked by his job to maintain some old node infrastructure :P
08:01:04FromDiscord<Varriount> Imagine, back then people had to tell computers what to do using _written text_!
08:02:01FromDiscord<Rika> now, we just think
08:03:15FromDiscord<lqdev> 🤔
08:05:01FromDiscord<Varriount> Nah, at some point computers will just anticipate what we want.
08:05:27FromDiscord<Varriount> Think Asimov's "I, Robot"
08:05:46FromDiscord<Varriount> Specifically, the last couple of stories.
08:07:59voltistAny ways to optimize compiled nim beyond -d:release, -d:danger, using clang or LTO?
08:08:00*sagax quit (Remote host closed the connection)
08:08:23FromDiscord<Rika> still too slow after those? or just curious?
08:08:31Yardanicovoltist: clang with lto and pgo
08:08:44Yardanicoalso -d:release is not needed if you already have -d:danger
08:08:46Yardanico(on 1.2+)
08:09:07voltistlto and pgo with clang actually make it slower :/
08:09:09PMunchPossibly --gc:arc as well
08:09:17Yardanicovoltist: are you sure you did PGO correctly?
08:09:38Yardanicoalso try just PGO without LTO
08:09:50voltistI used `--cc:clang --passC:"-flto -fprofile-instr-generate" --passL:"-flto -fprofile-instr-generate"`
08:09:56Yardanicoyes, that's the first step
08:10:01Yardanicoand then you need to run it on your data
08:10:04Yardanicoit'll generate profiling data
08:10:09Yardanicoand then you compile it again with that profile data
08:10:18Yardanicohttps://forum.nim-lang.org/t/6295
08:10:56Yardanicothe first PGO build is slow because it's made for collecting profiling data
08:11:10Yardanicobut when you use that data to make a final PGO build, it can result in much better performance
08:11:34YardanicoNim compiler with just PGO (without LTO since PGO + LTO for some reason breaks it) gets around 15-25% perf boost
08:11:37alehander92guys again
08:11:41alehander92https://blog.repl.it/langjam
08:11:53alehander92does anyone want to join ( i need to find a second mate :D )
08:11:59YardanicoI'm not interested in creating a new language :P
08:12:01Yardaniconim is good enough
08:12:45alehander92i mostly like the fun of designing something extreme
08:12:54alehander92it can be a dsl
08:12:59alehander92or something way out there
08:13:18PMunchOoh, maybe I should submit stacklang v2
08:13:21alehander92(but yeah disclaimer : conflict of interest :D )
08:13:44alehander92PMunch the problem is they require a team of two
08:13:56alehander92i also wanted to just do something in several days but ugh
08:14:08voltistYardanico: Wow massive performance boost even without merging multiple runs
08:14:12Yardanico:P
08:14:13voltistThanks for pointing that out
08:14:18PMunchI'm sure I could find someone crazy enough to co-sign my entry :P
08:14:18Yardanicohow much roughly?
08:15:02voltistAbout 40%
08:15:10Yardaniconice
08:15:13voltistFrom one test
08:15:17Yardanicoand people ask "why nim compiles to C?" :P
08:15:27Yardanicoyeah, if you have a lot of different datasets, it's better to run the program on them all
08:15:36Yardanicorun all of your tests, run the actual workload, etc
08:15:51Yardanicoand based on this profiling data the compiler will actually know which functions are used the most
08:15:55Yardanicowithout making assumptions
08:16:00Yardanicoso it could inline/etc
08:16:05PMunchHuh, how have I never heard of this before :S
08:16:32voltistThat sounds like magic and I love it
08:17:28YardanicoI didn't try to do PGO with GCC since it's a bit harder
08:17:37Yardanicoe.g. it outputs the profiling data in the folder with C files for some reason
08:17:40Yardaniconot in the folder with the binary
08:17:55Yardanicobut yeah, even Nim compiler gets 15-25% perf boost as I said
08:18:01Yardanicodepending on the program it can be much more
08:20:07PMunchCould we ship a script to build that version?
08:20:13YardanicoPMunch: I have one, but it's very hackish
08:20:27Yardaniconeed to ask leorize :P
08:20:37Yardanicomaybe we could even get nightlies with PGO lol
08:20:52PMunchHmm, I mean the Nim compiler is already really fast. But it would be interesting, especially for things like inim, to have an even faster version.
08:20:56Yardanicohttps://github.com/Yardanico/nim-snippets/blob/master/compile_nim_pgo.sh I basically use arraymancer, npeg + npeg (orc), compiler + compiler (arc) to get the profiling data
08:20:57voltistWhat do you mean version? Like a helper for LTO and PGO?
08:21:12Yardanicovoltist: no, we have binary releases of nim
08:21:15Yardanicoe.g. on nightlies, etc
08:21:20Yardanicoand we could compile them with PGO
08:21:31voltistOh right
08:21:38YardanicoI also added arc to the profiling so the ARC routines are also optimized
08:21:47Yardanicolike DFA/destructor injection/etc
08:22:00PMunchI tend to build with choosenim, it would be interesting if the script for building a PGO version was included so that you could build that version for yourself
08:22:23Yardaniconim c --compileOnly -d:danger tests/tests_cpu.nim with normal nim takes for me ~3.1 seconds
08:22:26Yardanicothat's from arraymancer repo
08:22:31voltistI feel compelled to build myself a little helper/manager script to manage profile data and wrap commands now
08:23:04Yardanicowell you can actually specify output filename for .profraw data
08:23:31Yardanicowith LLVM_PROFILE_FILE env variable
08:23:51PMunchHmm, I guess I could build a PGO version that is based on my repos
08:24:01PMunchSo I would have a Nim compiler optimised for my code :P
08:24:06voltistYeah but then merging and stuff
08:24:11voltistPMunch: :)
08:24:29voltistOpulent
08:24:37PMunchHaha :P
08:24:59Yardanicoand now nim compiler with PGO, and same arraymancer command takes ~2.86s
08:25:04Yardanicoit depends on the project really
08:25:12Yardanicobut it is surely faster
08:25:18Yardanicofor free
08:25:34voltistHow does one generate data for libraries like arraymancer?
08:25:40PMunchWould be interesting to throw it a bunch of macro-heavy projects and see if you can get some improvements there
08:25:49Yardanicovoltist: nonon, I didn't generate it for arraymancer
08:25:57YardanicoI used arraymancer for profiling data for the compiler
08:26:04Yardanicojust compile all the tests
08:26:09PMunchvoltist: https://github.com/Yardanico/nim-snippets/blob/master/compile_nim_pgo.sh#L14-L17
08:26:13YardanicoPMunch: well maybe I should add nimly in the mix
08:26:17Yardanicoit's really VM heavy
08:26:28PMunchYou need a test file that uses the library to generate the profiling information
08:26:36PMunchThat would be cool
08:26:52PMunchI guess the more stuff you add the less the speedup would be for a certain project
08:26:56Yardanicomaybe I should just write a small Nim tool instead of this script :)
08:26:59*Vladar quit (Ping timeout: 256 seconds)
08:27:06YardanicoPMunch: well IDK, maybe not
08:27:14YardanicoI guess most of libraries have the same hot paths in the compiler
08:27:23Yardanicounless generic/concept/macro heavy
08:27:26PMunchUnless the compiler does some really silly assumptions
08:27:33PMunchHmm, I guess that's true
08:27:46PMunchMaybe try to run it on the important packages list
08:27:48voltistSo if I run the profiler on my code which uses arraymancer, then it should optimize its procs as well as long as I use them?
08:27:57Yardanicovoltist: yes
08:28:02voltistCoolio
08:28:03Yardanicobut you already did, no?
08:28:22Yardanicoall nim libraries are compiled statically in the binary
08:28:22voltistYep
08:28:25Yardanicoso PGO will optimize everything
08:28:32voltistRight got it
08:28:32Yardaniconot limited to your code
08:28:36Yardanicobut also other libs or even stdlib
08:29:23YardanicoPGO is actually a very powerful thing
08:29:28YardanicoGoogle Chrome uses it since 2016
08:29:29PMunchvoltist, basically the compiler will do a bunch of assumptions about what parts you use the most and thus inline them or do other tricks with them. What this does is take those assumptions and replace them with actual measurements so that the compiler knows, based on your project, what the things to optimise for should be.
08:29:48Yardanicoyeah, if you're developing one big project, it can help a lot
08:29:52Yardanicohttps://blog.chromium.org/2016/10/making-chrome-on-windows-faster-with-pgo.html
08:29:56voltistPMunch: That makes sense yeah
08:30:10Yardanicoit's just that nim compiler is relatively small so we can easily compile it with PGO
08:30:14voltistI was not expecting it to be a windows thing as well?
08:30:17Yardanicocompiling chrome(ium) with PGO will take hours and hours
08:30:22Yardanicovoltist: it's not limited to any architecture/OS
08:30:28Yardanicohttps://en.wikipedia.org/wiki/Profile-guided_optimization
08:30:35PMunchHours and hours?
08:30:46PMunchDoes it have functions with millions of arguments or something? :P
08:30:59Yardanicoit has millions of LOC
08:31:13Yardanico"There is support for building Firefox using PGO.[7] Even though PGO is effective, it has not been widely adopted by software projects, due to its tedious dual-compilation model."
08:31:16voltistJust a different process for compiling with pgo on windows as opposed to GNU/Linux I presume?
08:31:20Yardanicono, why?
08:31:30Yardanicowell, if you use VCC the arguments will be different, sure
08:31:44*Vladar joined #nim
08:31:44Yardanicobuth gcc/clang/vcc all support LTO/PGO
08:31:49Yardanicohttps://docs.microsoft.com/en-us/cpp/build/profile-guided-optimizations?view=vs-2019
08:32:03PMunchYardanico, I was just joking. My millions of arguments procedure is the only time I've seen the Nim compiler spend more than a couple minutes on compiling anything :P
08:32:12voltistCool
08:33:13Yardaniconim compiler itself is pretty small compared to others so doing a PGO build is easier
08:33:24Yardanicoalso of course I showed the --compileOnly, but in reality I profile without it
08:33:32Yardanicoso the C backend also gets optimized
08:35:24Yardanicobut really I should probably try to investigate why PGO + LTO breaks nim compiler
08:35:29Yardanicowith clang
08:37:24Yardanicoalso CPython can be compiled with PGO (because it really makes much more difference for interpreted languages)
08:40:03Yardanicooh hmm LTO + PGO seems to be working now, maybe it was a clang bug
08:40:06Yardanicobut for some reason it's slower :P
08:45:26voltistWow, quality star identification in a 3500x2500 image in 0.35 seconds!
08:45:30FromDiscord<kodkuce> how to write from 10..1
08:45:36voltistPGO is my new favorite thing
08:45:41FromDiscord<kodkuce> ```↵for n in 10..0:↵ echo n ↵```
08:45:45FromDiscord<kodkuce> does not work
08:45:46PMunch"for i in countdown(10, 1)"
08:45:56FromDiscord<kodkuce> ok
08:46:16PMunchI guess you can omit the parenthesis as well
08:46:18FromDiscord<flywind> Can I boot nim temp with command `koch temp js test.nim`?
08:46:32PMunchOr do something like "for i in 10.countdown 0"
08:46:59Yardanico@flywind yes you can do that
08:47:01Yardanicokoch temp is smart
08:47:13Yardanicoif you specify "js", it'll compile full compiler without -d:leanCompiler flag
08:47:36Yardanicohttps://github.com/nim-lang/Nim/blob/devel/koch.nim#L484
08:47:44FromDiscord<flywind> Thanks, But I got:
08:47:46FromDiscord<flywind> D:\qqpcmgr\desktop\Nim\compiler\docgen.nim(170, 23) Error: type mismatch: got <AbsoluteDir> but expected 'AbsoluteDir = distinct string'↵FAILURE
08:47:48PMunchYardanico, I created an issue for the leading zero in exponents thing in the tests repo you mentioned: https://github.com/iarna/toml-spec-tests/issues/4
08:47:49disbotspec-float-5 is explicitly forbidden in the spec
08:48:01YardanicoPMunch: wdym?
08:48:20Yardanicoit is supported I think
08:48:23PMunchNope
08:48:27Yardanico@flywind that usually comes when it's using the wrong stdlib
08:48:33YardanicoI don't know the solution to this, sorry
08:48:38Yardanicomaybe you can specify the other stdlib path
08:48:40YardanicoPMunch: hm
08:48:43PMunchExponents are to be parsed as integers in TOML, and integers can't have leading zeros
08:48:55PMunchSo it shouldn't be allowed
08:49:05Yardanico"Leading zeroes in exponent parts of floats are permitted."
08:49:08Yardanicohttps://github.com/toml-lang/toml/blob/master/CHANGELOG.md#100-rc1--2020-04-01
08:49:26PMunchOoh
08:49:34PMunchWait, I checked the latest version as well
08:49:54Yardanico"An exponent part is an E (upper or lower case) followed by an integer part (which follows the same rules as decimal integer values but may include leading zeros)."
08:49:56Yardanicomaybe not the last one?
08:50:02Yardanicohttps://github.com/toml-lang/toml/blob/master/toml.md#float
08:50:09PMunchAah, they added "but may include leading zeros"
08:50:38Yardanicoyeah, we also need to fix multiline parser in parsetoml
08:50:46Yardanicoit fails on some tests because of incorrect assumptions
08:51:19PMunchTBH the entire parser infrastructure there is a bit brittle..
08:51:22Yardanicoyeah
08:51:45Yardanicobasically this fails for the parsetoml
08:51:47Yardanicostr = ''''That,' she said, 'is still pointless.''''
08:52:04Yardanicospec-string-literal-multiline-4.toml
08:52:07PMunchIt was nice when it was written, but tagging on all the changes to the TOML spec meant that it got quite messy..
08:52:19Yardanicothat string should result in
08:52:22Yardanico'That,' she said, 'is still pointless.'
08:52:22PMunchOh really?
08:52:26Yardanicoyes it does
08:52:46Yardanicobecause parsetoml just assumes that if there are 3 delimiters - it's the end of the string
08:52:54Yardanicoand in this string there are four '''' at the end
08:52:55PMunchOooh
08:53:08PMunchHmm
08:53:24PMunchThat might be a hard one to fix actually
08:53:30Yardanicohere https://github.com/NimParsers/parsetoml/blob/master/src/parsetoml.nim#L387
08:53:38YardanicoI almost fixed it last time, but it was quite hacky :)
08:54:30Yardanicooh I gues I didn't really save it
08:54:35*nikita` joined #nim
08:54:53Yardanicobasically I used the assumption that we can have at most 5 delimiters at the end of the string
08:54:55PMunchIt's really annoying that there isn't a comprehensive testsuite for TOML..
08:54:56Yardanicosince with 6 it would be invalid
08:55:03YardanicoPMunch: that repo is a pretty good one
08:55:21YardanicoI actually added them straight to the repo in https://github.com/Yardanico/parsetoml/tree/add-tests
08:55:29Yardanicohttps://github.com/Yardanico/parsetoml/blob/add-tests/tests/runner.nim
08:55:51PMunchThey should probably be added as a sub-module
08:55:53Yardanicoyeah
08:55:57Yardanicoor just optional
08:56:00Yardanicocloned when needed to test
08:56:06Yardanicothe array-inline-nested and table-inline-nested fail because of recursion by the way
08:56:09PMunchThat is of course another option
08:56:18Yardanicoit'
08:56:25PMunchJust do the git pull in the runner.nim code
08:56:28Yardanicoit's basically [[[[[[[[[[[[[[[[[[[[[[[[[.......]]]]]]]]]]]]]]]]]]]]]]]]]
08:56:33Yardanicoan empty array like that
08:56:39Yardanicobut it's not a big deal since no one would actually write it like that
08:57:05PMunchBecause of recursion? Does it break the stack?
08:57:44YardanicoPMunch: well yes
08:57:48YardanicoError: call depth limit reached in a debug build (2000 function calls). You can change it with -d:nimCallDepthLimit=<int> but really try to avoid deep recursions instead.
08:58:05YardanicoparseValue -> parseArray -> parseValue -> parseArray
08:58:19Yardanicoit works with call depth limit of 10000
08:58:34Yardanicoor actually even with 3000
08:58:38Yardanicobut it's not a big deal really
08:58:59Yardanicoand it doesn't seem to fail with -d:danger
08:59:03Yardanicomaybe the C compiler does TCO and stuff
09:00:30PMunchThe Nim compiler in debug mode sets a hard limit. I think with -d:danger it will just run and let the stack overflow and cause some kind of SEGFAULT or something
09:00:42Yardanicowell there's no segfault
09:00:47Yardanicoit actually passes
09:00:55Yardanicoone thing I didn't add to tests is validation :)
09:00:55PMunchWell because 3000 isn't enough to break the stack
09:01:00Yardanicononono
09:01:04YardanicoI didn't set a depth limit this time
09:01:18PMunchYeah, but -d:danger removes the depth limit entirely I think
09:01:24PMunchIt's only there for debug builds
09:01:27PMunchI think
09:01:32Yardanicowell, anyway, it actually works with -d:danger
09:01:39PMunch-d:release should also work fine
09:01:39Yardanicoe.g. I can echo the parsed node
09:01:47PMunchYeah, that's to be expected
09:02:03Yardanicowe should probably convert all the .yaml in that test suite to .json for easier parsing
09:02:06Yardanicoto validate
09:02:12PMunchBut if you had one that was sufficiently nested (or if you reduce your stack to be really small) it would actually break
09:02:26PMunchHmm, probably
09:03:09PMunchWhy are some of them JSON by the way?
09:03:14PMunchAnd some YAML?
09:03:24Yardanicono, all of them are yaml and toml
09:03:27Yardanicotoml for parsing and yaml for validation
09:03:34PMunchYeah
09:03:39YardanicoI just said that it would be easier to convert yaml to json than to use NimYAML
09:03:45PMunchBut there are a couple in there that are JSON for validation
09:03:53Yardanicooh I see yes
09:03:58PMunchE.g. this one: https://github.com/iarna/toml-spec-tests/blob/latest/values/spec-date-local-1.json
09:04:04Yardanicoyeah, a bit weird
09:04:16PMunchMight be copied over from the burnt sushi one
09:04:35PMunchI guess we could just run it and copy the JSON output for all the tests that pass
09:04:40PMunchAnd then just manually recreate the rest
09:04:54Yardanicothere are tools to convert yaml to jsonm
09:05:17Yardaniconimyaml can do it :)
09:05:23Yardanicoi think
09:05:30Yardanicoyeah, https://nimyaml.org/yaml.tojson.html
09:05:31PMunchYeah but the JSON format used by BurntSushi and this one is a special structure
09:05:58PMunchYou see they have a "type" and a "value" field in an object
09:06:09PMunchTo distinguish e.g. a date from a string
09:06:15PMunchBecause TOML has more types than jSON
09:06:49PMunchI wish TOML had those nice railway diagrams that JSON does
09:07:59PMunchI created a flow diagram for a part of the spec, it's not a pretty thing :P
09:11:10PMunchhttps://uploads.peterme.net/tomlvalues.png
09:11:38PMunchThis is basically anything that's not a string or an array/object
09:13:01Yardanicojust make a npeg parser for toml :P
09:13:06Yardanicoit can make graphs too
09:13:35PMunchI know, such a cool feature!
09:13:39*ehmry joined #nim
09:13:53*Tlanger joined #nim
09:16:25*Tongir quit (Ping timeout: 264 seconds)
09:19:01Zevvstop that
09:19:12Zevvdon't go toml
09:19:18PMunchHuh?
09:19:49Zevvit's a pain to parse with npeg, really
09:19:50PMunchI'm not using TOML for anything at the moment, but we should have a parser for it in Nim
09:20:06Zevvoh wait toml
09:20:15FromDiscord<lqdev> Zevv: why?
09:20:22Zevvnah I'm confusing with something else
09:20:30Zevvthis might be doable, except the indenting still is kind of tricky
09:21:05FromDiscord<lqdev> i don't think toml is indentation sensitive
09:21:33ZevvI might give it a go then, while waiting on the crawlingly slow progress of disrupteks CPS mess
09:21:35PMunchIt isn't
09:21:42FromDiscord<lqdev> really tho anything with indentation is difficult to parse with PEGs overall
09:21:45PMunchHaha :P
09:22:02Zevvsomeone find me a test suite of toml docuemnts?
09:22:16FromDiscord<lqdev> though *maybe* if npeg had support for custom matchers...
09:22:16PMunchhttps://github.com/iarna/toml-spec-tests
09:22:21Zevvthat was too easy :)
09:22:49PMunchThere's also this: https://github.com/BurntSushi/toml-test
09:23:03PMunchBut it's a bit older
09:23:08Zevvso, parsing toml into JSonNodes, does that make sense?
09:23:16Zevvor does it need its own AST
09:23:38PMunchWell, if you look at the BurntSushi repo you can see how they parse in into Json nodes
09:24:13PMunchEssentially TOML has a couple more types, actually only dates I think, so it requires objects to specify whether it's a string or a date
09:24:33PMunchAnd it uses these objects for anything
09:26:54*Vladar quit (Ping timeout: 256 seconds)
09:27:13Zevvlqdev: npg *has* support for custom matchers
09:30:02alehander92hmm
09:33:36PMunchHmm, nimpretty should really support wrapping doc-comments
09:33:47*Vladar joined #nim
09:37:07FromDiscord<lqdev> Zevv: like, matching using a custom proc?
09:37:18FromDiscord<lqdev> show me the part in docs
09:39:02Zevv"Note: The Nim code block is running within the NPeg parser context and in theory could access to its internal state - this could be used to create custom validator/matcher functions that can inspect the subject string, do lookahead or lookback, and adjust the subject index to consume input. At the time of writing, NPeg lacks a formal API or interface for this though, and I am not sure yet what this should look
09:39:08Zevvlike - If you are interested in doing this, contact me so we can discuss the details." :)
09:40:11FromDiscord<lqdev> it has support but no API :)
09:40:32Zevvwell, and I don't support it
09:40:38Zevvunsupported support
09:40:41FromDiscord<lqdev> not like i need it, i was just curious
09:41:28FromDiscord<lqdev> i don't use for bigger projects as i find that it's harder to wrap my head around than recursive descent + AST building
09:41:52FromDiscord<lqdev> s/use/use it/
09:42:09Zevvneither do I
09:42:33ZevvI use it mostly for quick protoing stuff
09:42:39FromDiscord<lqdev> same
09:42:49Zevvactually, it kind of sucks
09:42:51Zevvbut don't tell anyone
09:42:56Zevvthe drawings make up for it
09:43:22FromDiscord<lqdev> i know it sucks :(
09:43:48FromDiscord<lqdev> its main drawback is that AST building is hard
09:44:49Zevvtrue.
10:33:19*sagax joined #nim
10:38:40FromDiscord<Zachary Carter> @mratsim - I'm playing around with weave and the background service feature - wondering, is there any way to wait for multiple `Pending`s?
10:41:41FromDiscord<mratsim> You loop on multiple until one isReady()
10:42:02FromDiscord<mratsim> it's not async so there is actually no special pooling to ask from the OS
10:42:38FromDiscord<Zachary Carter> gotcha thanks
10:50:29*arecacea1 quit (Remote host closed the connection)
10:50:53*arecacea1 joined #nim
10:52:39FromDiscord<hugogranstrom> I'm wrapping a C library that gives me the option to allocate the C-object either on the stack or heap (with the hint that stack-allocated objects are faster). As I'm wrapping it in a Nim object it could potentially be passed around between procs and it feels like I don't want it allocated on a random stack then. Should I go for the heap allocation instead?
10:54:06*maier quit (Ping timeout: 256 seconds)
10:56:10*rockcavera joined #nim
11:10:03*maier joined #nim
11:11:09FromDiscord<Recruit_main707> there should be no issue i think, although if the object is bigger than `sizeof(float) * 3` nim will optimize it and pass it by reference, you can avoid it by adding the `{.bycopy.}` pragma to it (maybe its relevant for your case)
11:15:36FromDiscord<hugogranstrom> @Recruit_main707 Right! I forgot to mention that the library returns a pointer to the stack-allocated C-object so just the pointer would be copied then with the `{.bycopy.}`? But the underlying data isn't copied, that's the troubling part (if it is an issue, that is)
11:16:15FromDiscord<mratsim> not an issue
11:16:37FromDiscord<mratsim> if the library expect this opaque pointer just use it
11:17:05FromDiscord<hugogranstrom> So even though it is allocated on the stack in a proc it doesn't disappear when we exit it (and returns the pointer)?
11:19:14*Vladar quit (Remote host closed the connection)
11:21:07FromDiscord<mratsim> it disappears when the proc that allocated it exists
11:21:11FromDiscord<mratsim> exits*
11:21:19FromDiscord<mratsim> but it's available in any child proc
11:22:57FromDiscord<mratsim> sent a code paste, see https://play.nim-lang.org/#ix=2t3u
11:23:59FromDiscord<mratsim> compile with --passC:-fsanitize=address and --passL:-fsanitize=address to have memory tracking and ensure you don't do buffer overflow
11:24:14FromDiscord<mratsim> but even without, wrong use will trigger stack smashing protection
11:24:16FromDiscord<hugogranstrom> It sounds a bit troublesome then as I do things like ```proc `+`(a, b: WrapperType): WrapperType = ↵allocate_stack(c_var) ↵perform_c_stuff(c_var, a.data, b.data)↵result = wrap(c_var)```
11:24:34*Vladar joined #nim
11:25:14FromDiscord<mratsim> that won't work, `+` needs to be a template in that case or the WrapperType needs to be on the heap
11:27:03FromDiscord<hugogranstrom> OK, then I better use the heap allocated version it seems like 🙂 I can't force the user to use templates instead of procs after all
11:27:50FromDiscord<mratsim> For libraries that combine multiple functions at once, they will be interested in stack alloc
11:28:29FromDiscord<mratsim> I expect that the differenc ein performance will be significant, like from 2x ~ 3x minimum but it can go well into the 10x ranges
11:28:47FromDiscord<hugogranstrom> Let's say the user specifies a proc like: ```proc f(x: WrapperType): WrapperType =↵x ^ 2```
11:29:58FromDiscord<hugogranstrom> No matter how I implement `^` it will be stack allocated in `f` but we can't return it to the outside?
11:30:02FromDiscord<mratsim> The alternative is to write a memory pool
11:30:25FromDiscord<mratsim> yes, because at the end of the function the previous stack will be restored
11:30:35FromDiscord<hugogranstrom> Ouch that's a pretty hefty performance drop :/
11:30:42FromDiscord<mratsim> or an object pool if your types are always the same size
11:31:42FromDiscord<mratsim> benchmark it, you'll know, but I suppoe doing multiple additions is expected, so you will have memory overhead
11:31:49FromDiscord<hugogranstrom> A memory pool for my Nim-type or for the C-type I get a pointer to?
11:31:50FromDiscord<mratsim> this is similar to strutils and intermediate allocation
11:32:50FromDiscord<hugogranstrom> Hmm... Perhaps forcing the user to use templates instead of proc's isn't such a bad idea after all 😅
11:33:13FromDiscord<mratsim> if an object pool is enough and there is only ever a single owner of a memory location (i.e. you don't alias) you can use this as a base: https://github.com/mratsim/weave/blob/master/weave/memory/persistacks.nim
11:33:19FromDiscord<mratsim> this is a very simple object pool
11:33:41FromDiscord<mratsim> you just need to have a `=destroy` = recycle
11:33:55FromDiscord<hugogranstrom> I'm afraid I have zero control over how the C library handles this sadly :/
11:34:07FromDiscord<hugogranstrom> I just get a pointer
11:34:22FromDiscord<mratsim> I xpect the lib as an object pool inside
11:34:27FromDiscord<mratsim> but benchmark.
11:34:43FromDiscord<mratsim> do 100000 sums in a loop on stack or on heap and look what happens
11:35:04FromDiscord<mratsim> and highlight those limitations in your README
11:35:50FromDiscord<hugogranstrom> I hope so. Yes I will do some benchmarking 😄
11:36:34FromDiscord<mratsim> Note that whatever you learn there will be super useful for: parser/json parsing/csv parsing (we need to allocate temporary a lot for working on strings or converting them to numbers), autograd and intermediate tensor, functional programming (lots of intermediate transformation if not optimized from the start, i.e. sequtils or strutils)
11:37:22FromDiscord<hugogranstrom> Oh yeah that's for sure, learning is a thrill 🙂
11:38:03FromDiscord<hugogranstrom> Allocation is both a blessing and a limitation really depending on what you do
11:38:06FromDiscord<hugogranstrom> Thank you very much Mamy! 🙂
11:44:49*krux02 joined #nim
12:06:01*supakeen quit (Quit: WeeChat 2.8)
12:06:33*supakeen joined #nim
12:23:02*dulsi_ joined #nim
12:25:34*dulsi quit (Ping timeout: 260 seconds)
12:28:03*NimBot joined #nim
12:33:44PMunchPrestige, is that a pipe or a cane in your GitHub avatar?
12:39:25YardanicoPMunch: PMunch
12:39:25Yardanico'
12:39:28Yardanicosorry
12:39:30Yardanicodidn't mean to do that
12:40:52PMunchHaha :P
12:41:34FromGitter<sealmove> how to do shift-reduce with npeg?
12:43:03Yardanicowhat's that? :D
12:51:25PMunchHmm, that's annoying: https://play.nim-lang.org/#ix=2t40
12:52:15Yardanicowhat exactly?
12:52:16PMunch`first` and `second` here are indistinguishable, even though Nim users would read `first` as a type declaration kind of thing, while `second` looks like a list of assignments..
12:52:48Yardanicowell, for me they're the same :P
12:53:36PMunchEssentially I want to support something like this: https://play.nim-lang.org/#ix=2t41
12:54:04PMunchIn a DSL, but now I have no good way of distinguishing a category from an assignment with a type declaration
12:55:30PMunchApart from checking the key in every category with only a single assignment and try to determine if the key is a type
13:00:45FromDiscord<kodkuce> 1 question about async, if i write a proc that just for loops tough list and gives result back, and i want to use it in some async function do i have to declare it too async or its pointless cuz there is no real blocking ?
13:01:01Yardanicoit's pointless
13:01:11Yardanicothere is blocking of course, but it would be not noticeable in 99% of cases
13:01:23Yardanicoany CPU-bound work is blocking
13:01:37PMunchEh, it depends
13:02:01Yardanicowell, depends on how much load there is, yes
13:02:10Yardanicobut even the tiniest CPU work *is* technically blocking
13:02:14PMunchIf you have a lot of iterations and you want to e.g. listen for user input "at the same time" then implementing it as an async might give you what you want
13:02:17FromDiscord<kodkuce> ye right if i have list of 1m and shitty cpu
13:02:33FromDiscord<kodkuce> but i have list of 1000max and just check 1 field
13:02:37PMunchBut in that case you're better off doing the work on a separate thread
13:02:38Yardanicoit's okay
13:02:44Yardanicoyeah
13:03:15PMunchYeah it would still block, so the throughput would be the same, but latency could be worse.
13:04:37PMunchSay you want to loop through a million entries, if the user wants to quit after 1000 and it ran in a blocking way then you're screwed. But if it was async and checked every time it got control whether or not it was supposed to carry on then you would be able to take user input to quit the async procedure "while" running
13:04:44FromDiscord<kodkuce> sent a code paste, see https://play.nim-lang.org/#ix=2t46
13:05:00Yardanicowhy would you want it to be a future?
13:05:02Yardanicoit doesn't have to be
13:05:11PMunchNotice the "at the same time" and "while" in quotes, it's interleaved, but it would appear to happen at the same time for the user
13:05:15Yardanicoit won't matter for you as we said :)
13:05:51PMunchAh, you need to await something to hand control back to the loop
13:06:12PMunchI'm not sure if async in Nim supports just yielding without awaiting anything..
13:06:30PMunchIt definitely should IMO, but I'm not sure if it actually does
13:06:51Yardanico@kodkuce something like https://play.nim-lang.org/#ix=2t47 should work
13:06:56Yardanicoasync macro can implicitly add Future type
13:07:00Yardanicoor I mixed that up, hm
13:07:11Yardanicotry https://play.nim-lang.org/#ix=2t48
13:07:26Yardanicobut really, you don't have to make it async
13:09:13FromDiscord<kodkuce> ok
13:09:17FromDiscord<kodkuce> (edit) 'ok ... ' => 'okty'
13:11:39PMunchOr alternatively keep a data structure that is easier to index than looping through a list
13:11:45PMunchMaybe even just a bitset?
13:12:34Yardanicobtw, I noticed that https://github.com/nim-lang/Nim/blob/master/lib/pure/colors.nim uses binary search over an array for matching color name -> color
13:12:41Yardanicois that more efficient than a table (or a string table even)?
13:13:04Yardanicoah nvm it's just legacy I think
13:13:10Yardanicothat binary search code is there since 11 years ago
13:13:32PMunchPotentially faster
13:13:44Yardanicowhat if you make the table at compile-time?
13:13:46PMunchOr well, it still has to do string compares. So probably not
13:14:13PMunchYeah, a compile-time generated table would probably be faster
13:14:31PMunchFaster yet would be a trie I think
13:15:17PMunchhttps://nim-lang.org/docs/critbits.html
13:16:16Yardanicowow
13:16:36Yardanicoalthough there doesn't seem to be a way to make one at compile-time efficiently?
13:16:41Yardanicoyou just gotta do static: incl. a lot of stuff?
13:17:07FromDiscord<kodkuce> ye my data structure is atm horor but its my first time at wrting this matchmaking thingy so just want to finish it, next game will have better for sure 🙂
13:20:00PMunchIt likely won't matter much unless you're doing a whole lot of colour name lookups..
13:20:13YardanicoI just was curious :)
13:20:21PMunchBut a way to compile-time make a string trie data structure would be cool
13:21:06Yardanicoso a trie would be faster instead of a table?
13:21:11Yardanicofor e.g. string -> string lookup
13:21:19Yardanicoif mappings are known at compile-time
13:21:39PMunchI wrote a compile-time huffman coding of sprites for the Arduboy, that was pretty cool
13:21:50PMunchIt could be faster
13:22:41PMunchBasically the benefit of a trie is that you scan the string character by character and simply choose branches of the data structure until you hit a leaf. It could terminate early, and be quite cache efficient
13:23:16PMunchBut calculating a hash and directly going to a place in memory is also super fast, so it would probably only matter for very high volume lookups
13:23:27PMunchBut the trie approach requires less memory
13:23:42Yardanicooh I get the trie thing
13:23:44PMunchBecause you only store the data and structure required, there are no empty buckets
13:23:47Yardanicoit's like some hand-written parsers
13:23:52Yardanicowhich check char-by-char for keywords
13:23:55PMunchYeah, pretty much
13:24:11Yardanicothe crafting interpreters book used that approach for C implementation of the parser :)
13:25:16PMunchSay you have pasta, pasterami, tomato, and pizza in a trie. The first would be check if it's a p or a t, then if it is an i or the sequence ast, and then a check for erami or a to determine what it is
13:25:43Yardanicoyeah, seems pretty clear :)
13:25:50YardanicoI guess the algorithm itself to do that is harder, but I get the idea
13:26:07Yardanicoseems to be this paper
13:26:07Yardanicohttps://www.imperialviolet.org/binary/critbit.pdf
13:26:28PMunchEh, it's not that hard
13:46:08*vicfred joined #nim
13:54:20skrylar[m]i seem to recall araq was in to critbits
13:54:30FromDiscord<kodkuce> https://play.nim-lang.org/#ix=2t4o , can somone explain me about what locks does it complain ?
13:59:17*lritter quit (Quit: Leaving)
14:07:07Yardanicoit doesn't complain about locks
14:07:23Yardanicohttps://play.nim-lang.org/#ix=2t4C fixed version
14:07:27Yardanicoyou're passing proc itself to these procedures
14:07:36*Trustable joined #nim
14:07:37Yardanicobut you should call them, they return Future and you pass that to asyncCheck or waitFor
14:07:59Yardanicothe error tells you that it got a proc as an argument
14:08:02Yardanicobut it expected a Future
14:10:45*MightyJoe joined #nim
14:11:00FromDiscord<kodkuce> oh
14:11:02FromDiscord<kodkuce> ye sorry
14:11:37*cyraxjoe quit (Ping timeout: 264 seconds)
14:14:34*def- quit (Ping timeout: 265 seconds)
14:14:37*def-- joined #nim
14:15:01*def-- is now known as def-
14:19:27*SenasOzys joined #nim
14:21:38*screens is now known as screens_
14:24:58FromDiscord<Clyybber> sup
14:25:03FromDiscord<Clyybber> PMunch: You're back!
14:32:56*ForumUpdaterBot quit (Remote host closed the connection)
14:33:03*ForumUpdaterBot joined #nim
14:33:25Yardanicohttps://forum.nim-lang.org/t/6637
14:38:45FromDiscord<Zachary Carter> @mratsim - I might be doing something incorrect but I'm running into some errors using devel and weave
14:38:59FromDiscord<Zachary Carter> I can throw up some example code if you want to see
14:42:26FromDiscord<Clyybber> @Zachary Carter are you using weave with vulkan?
14:42:41*aenesidemus joined #nim
14:47:24FromDiscord<Zachary Carter> going to try
14:47:40FromDiscord<Zachary Carter> but I might just end up writing my own, simpler, job system if I can't get weave working
14:53:18FromDiscord<Clyybber> are you going to go the framegraph route?
14:57:22FromDiscord<Zachary Carter> that's the plan
14:57:41FromDiscord<Clyybber> nice!
15:07:01FromDiscord<kodkuce> hmm var players: seq[Player] = repeat( Player(empty:true), 5 ) , it does not create a new player for each slot it just copy ref of same so when i change 1 i change all 😦
15:07:13Yardanicoyes as I said before
15:07:22Yardanicoso just use two more lines of code
15:07:24Yardanicoit's not such a big deal :)
15:07:42FromDiscord<kodkuce> me crys inside xD
15:09:06ForumUpdaterBotNew thread by Wearetherock: Syntax for copy instance of object and update some attribute, see https://forum.nim-lang.org/t/6638
15:13:40*audiofile joined #nim
15:19:22*maier quit (Ping timeout: 246 seconds)
15:20:44*audiofile quit (Quit: Default Quit Message)
15:38:20*waleee-cl joined #nim
15:46:05*audiofile joined #nim
15:49:06*oriba joined #nim
15:52:09*oriba quit (Client Quit)
15:55:57Yardanicostreaming some random stuff because I don't have any ideas for projects :P
15:55:58Yardanico~ystream
15:55:58disbotystream: 11Stream at https://twitch.tv/yardanico, voice chat either on Mumble (mumble://uberalles.mumbl.io/) or in Discord (https://discord.com/invite/ezDFDw2) -- Yardanico
15:56:34livcdYardanico: why not continue on your sciter wrapper? :P
15:56:38Yardaniconot now :P
15:57:00livcdIf you want I could sponsor you a license
15:57:15supakeenI should continue my urwid port.
15:57:16Yardanicowell the license is not really needed for most stuff :)
15:57:31supakeenOne of these days I shall find the time!
15:57:44livcdBut you would have access to sources. Maybe it would make life easier
16:04:52FromDiscord<UnnoTed> i'm hoping that the Sciter wrapper continues too as i lack enough knowledge in C/C++ to write a wrapper, i'm currently using Go with Sciter but the binary is getting huge (45mb)
16:05:38FromDiscord<Rika> you've tried all you can to make the binary smaller?
16:09:03livcdRika: you would sacrifice startup time if you would have tried it all :X
16:09:32FromDiscord<Rika> yeah, well,
16:09:33FromDiscord<Rika> yeah
16:09:38FromDiscord<Rika> got nothing to say
16:10:49livcd:D
16:11:48FromDiscord<Rika> maybe the sciter wrapper can be made via nimterop
16:11:53Yardanicoit's not about that
16:11:57Yardanicoit's already made with nimterop
16:12:00Yardanicoit's about making a high-level wrapper
16:12:06Yardanicothe low-level wrapper is already useable
16:13:30livcdInteresting. Did you just run nimterop for the lowlevel wrapper?
16:13:37Yardanicono, there's more work of course
16:13:43YardanicoI copied a lot of stuff from the old sciter wrapper
16:13:46Yardanicobut also modernized that stuff a bit
16:17:02FromDiscord<Rika> yardanico: ah, i see, i didnt know, sorry
16:17:47shashlickRika - did you get to see the imagemagick wrapper
16:19:50FromDiscord<Rika> yes
16:19:51FromDiscord<Rika> uh
16:20:05FromDiscord<Rika> it doesnt work and i do not kknow why
16:20:25FromDiscord<Rika> i'm currently doing something else right now so ill tell you what i get in a bit
16:20:42shashlickokay let me know
16:22:54PrestigePMunch: it's a cane
16:42:18*krux02 quit (Remote host closed the connection)
17:05:25FromDiscord<Zachary Carter> is there any way to have the compiler inform you when a sink parameter, that is used afterwards, results in a copy?
17:06:09Yardanicoit does that by default
17:06:13Yardanicoperformance hint
17:10:51FromDiscord<Zachary Carter> hmm okay - let me test
17:12:11FromDiscord<Zachary Carter> Yardanico: is there some flag I need to enable to get performance hints?
17:12:18FromDiscord<Zachary Carter> because it's not working for me
17:12:19Yardanicono, it should be enabled by default
17:12:22Yardanicoat least in devel
17:12:55FromDiscord<Zachary Carter> weird
17:13:53FromDiscord<Recruit_main707> nim always disagrees with gcc on pointer size even when its the mingw installation it downloads (and works)
17:14:09Yardanicowell that means the nim assumes you use a different arch
17:14:12Yardanicotry --cpu:i386 explicitly
17:14:16Yardanicoor --cpu:amd64
17:14:24FromDiscord<Recruit_main707> sorry. when i run finish.exe
17:15:42FromDiscord<Zachary Carter> oh I think I know why it's not complaining
17:15:51FromDiscord<Zachary Carter> because I'm doing `sink var T`
17:15:55FromDiscord<Zachary Carter> which doesn't make sense...
17:15:57Yardanicolol
17:16:16FromDiscord<Zachary Carter> the compiler should tell me I'm stupid
17:16:33FromDiscord<Zachary Carter> `compiler: Araq says you stupid!`
17:16:45FromDiscord<Zachary Carter> hope that didn't ping him lol
17:16:46*maier joined #nim
17:17:02Yardanicoit will :P
17:17:04FromDiscord<Recruit_main707> probably did
17:21:42*maier quit (Ping timeout: 256 seconds)
17:28:25FromDiscord<Recruit_main707> lmao i just slapped my own mingw installation into the dist folder and it worked fine
17:39:16Zevvwell well well
17:49:46disruptekspeak to me, nimions.
17:51:44FromDiscord<Clyybber> @Zachary Carter Yard: I don't think so
17:51:48FromDiscord<Clyybber> I think Araq disabled it
17:51:52FromDiscord<Clyybber> lemme check
17:52:19FromDiscord<Clyybber> yeah you have to have hint:performance:on
17:53:23disruptekPMunch: wb, are you okay?
17:54:26FromDiscord<Zachary Carter> wb PMunch!
17:56:17*endragor_ joined #nim
17:58:46*endragor quit (Ping timeout: 260 seconds)
18:00:54*dzamo joined #nim
18:02:24*dzamo quit (Client Quit)
18:07:21disruptekThere have been 348 failed login attempts since your last successful login. 🤦
18:07:26disruptekWHAT IS MY PASSWORD?
18:08:17FromDiscord<Clyybber> ~password is bentleyisagoodboy
18:08:18disbotpassword: 11bentleyisagoodboy
18:08:33disruptekThere have been 349 failed login attempts since your last successful login.
18:09:02FromDiscord<Rika> are you sure this isnt you in the future trying to log in
18:09:21disruptekwhy would the future me want to talk to you?
18:09:30FromDiscord<Clyybber> gatem
18:10:30FromDiscord<Rika> lmao
18:12:09disruptekthat came out wrong. what i meant was,
18:12:15disrupteki don't want to talk to you in the future.
18:12:55disrupteki spoke to you in the past. it wasn't that great.
18:13:28leorizeYardanico: eh, PGO is overrated
18:13:32FromDiscord<Rika> lol
18:13:34Yardanicoleorize: why?
18:14:02leorizebecause you end up optimizing for your test cases instead of real world usage
18:14:07Yardanicoyes
18:14:14Yardanicobut your usage can be "real world usage"
18:14:20leorizeautopgo is better in this aspect
18:14:35leorizeit's a form of lightweight instrumentation
18:14:52leorizeso you can use it in conjunction with your real world workload
18:15:10Yardanicocan't find a single article about autopgo lol
18:15:19leorizeautopdo <- I think that's what it's called
18:15:26leorizeit's google tech that clear linux uses
18:15:31Yardanicostill :D
18:15:33FromDiscord<Rika> unfortunate name
18:15:38FromDiscord<Rika> very unfortunate name
18:15:44Yardanicobut anyway I think that PGO is still good
18:15:49Yardanicoit can be helpful in a lot of cases
18:16:02leorizeI think PGO distracts users from the real fix
18:16:14*dzamo joined #nim
18:16:32leorizethe point of instrumentation is that you know where to micro-optimize to gain better perf overall
18:17:18leorizeyou can see firefox as a prime example of how pgo can only ever help you score high in benchmarks
18:19:21*kungtotte quit (Read error: Connection reset by peer)
18:19:36*kungtotte joined #nim
18:19:40leorizePGO is not bad, don't get me wrong, but it's crucial to remember that it's a tool to help you optimize your written code, not a "free performance" optimization as many tries to use it as
18:20:35leorizeah, the tech is called autofdo
18:20:49leorizegoogle seems to have dropped it
18:21:35*dzamo left #nim ("Good Bye")
18:25:00*dulsi_ is now known as dulsi
18:25:13shashlick@Rika - made another update based on feedback from zedeus
18:25:49FromDiscord<Rika> okay ill look
18:26:02FromDiscord<Rika> when i can... still doing something
18:26:17disrupteki don't believe it.
18:28:42Yardanicoi wrote something cursed
18:30:14Yardanicohttps://play.nim-lang.org/#ix=2t6a
18:36:32*sschwarzer joined #nim
18:37:20sschwarzerI just created my first macro: https://play.nim-lang.org/#ix=2t6i . Any feedback? Suggestions for improvements?
18:39:04disrupteksschwarzer: i got a macro i want written that i couldn't impl myself. maybe you can give it a shot?
18:39:13Yardanicolol
18:39:19FromDiscord<Rika> 👀
18:39:23sschwarzerdisruptek: *lol*
18:39:31disruptekdafuq is so funny about that?
18:39:53sschwarzerdisruptek: I thought you were joking.
18:40:17sschwarzerI mean I _could_ try it if it's not super-difficult.
18:40:21Yardanicohe is joking
18:40:24disrupteki want a twice: block. the first time it is encountered, it is ignored. the second time, the twice: block is run. simple.
18:40:34sschwarzerBut hey, if you say you couldn't implement it ... :-D
18:40:58disrupteki thought it was as simple as `block: once: break; body`. i was wrong.
18:41:00sschwarzerYardanico: probably it's something unsolvable ;)
18:41:25disruptekit should be solvable.
18:44:00disrupteki spend a lot of time writing nim, but that doesn't mean i'm any good at it. look at rika, for example.
18:44:07sschwarzerdisruptek: Can you explain this a bit more, maybe with an example? (would make sense in the Nim playground)
18:44:11FromDiscord<Rika> exactly
18:44:56FromDiscord<Recruit_main707> lel
18:44:56sschwarzerdisruptek: Sounds like it needs some state during the _runtime_ of the macro (if I understood the task correctly).
18:45:05sschwarzeri. e. a flag
18:45:35sschwarzerI mean "runtime of the macro" = "time when the compiled code generated by the macro runs"
18:46:07Zevvdisruptek: tell me
18:46:15Zevvwhat is new
18:46:41disrupteksschwarzer: https://play.nim-lang.org/#ix=2t6k
18:46:55disruptekZevv: i'm writing an issue to track a new rewrite impl.
18:47:20Zevvthe old one is beyond salvaging?
18:47:21disruptekreally tired of dealing with this impl that shouldn't even exist.
18:47:22Zevva total loss?
18:47:25disruptekno, but.
18:47:27Zevvfair enough
18:48:02leorizedisruptek: https://play.nim-lang.org/#ix=2t6m
18:48:37disruptekwhy can it not be impl with once?
18:49:04disruptekplease pr it to fusion. fusion loves untested novel code.
18:49:18sschwarzerdisruptek: So in the first iteration you want to execute the `once` block and in the second iteration the `twice` block?
18:50:23disruptekyeah.
18:51:28sschwarzerZevv: Would it be possible to store the `count` in your template in some closure instead of making it global?
18:51:44sschwarzerSo you could have different once/twice uses
18:51:54disruptekyou already do.
18:52:00sschwarzere. g. in different procs
18:52:05disruptekthe global is hygenic; it's gensym'd.
18:52:18Zevvsschwarzer: talking about which code?
18:52:26disrupteka closure would evaporate.
18:52:27sschwarzerdisruptek: oh, I see, it's in each inlining of the template
18:52:42disruptekZevv: he's confusing you for leorize.
18:52:49Zevvah I often have that
18:53:12sschwarzerdisruptek, Zevv: yes, I did confuse you/them
18:53:14Zevvwe're both bright and charismatic
18:53:18Zevvso no wonder
18:53:26sschwarzerZevv: That's awesome ;)
18:53:30Zevvyes, we are
18:53:30leorizedisruptek: once doesn't work because it would run everytime after `twice`
18:53:51sschwarzerZevv: By the way, I really like your Nim t-shirt you posted. :-D
18:54:01disrupteki don't get it.
18:54:06Zevvsschwarzer: thanks :)
18:54:44sschwarzerI really like Monty Python and have the movie on DVD. :)
18:54:55leorizedisruptek: https://play.nim-lang.org/#ix=2t6p
18:54:58Zevvso at least *someone* gets it
18:55:46*krux02 joined #nim
18:56:00leorizefor the exact semantics that you want a counter is the simplest implementation
18:56:34disruptekactually, this works fine.
18:56:42sschwarzerleorize: wouldn't a bool suffice?
18:56:44disruptekhttps://play.nim-lang.org/#ix=2t6q
18:57:05sschwarzerleorize: like "already executed" vs. "not yet executed"?
18:57:12*nikita` quit (Quit: leaving)
18:59:50FromDiscord<brainproxy> in my `proc foo*(a: cstring): cstring {.exportc.} =` after building the cstring I intend to return I'd like to allocate memory not managed by Nim's gc, copy/put the cstring in there and return the pointer. In other words, I want caller to be responsible for freeing the memory
18:59:58disruptekbbiab, i'm getting tired of eating rotten milk with a fork.
19:00:25FromDiscord<brainproxy> > eating rotten milk with a fork↵sounds awful
19:00:48leorizedepends on how you built the cstring
19:01:04leorizeif you build it from scratch using `alloc` and friends then it's unmanaged
19:01:21leorizehowever the string cannot be freed by C's free() since Nim has it's own allocator
19:02:09FromDiscord<brainproxy> right, so the cstring came from an intermediate step of passing `$a` to some other proc then `.cstring`'ing its return
19:02:37FromDiscord<brainproxy> basically I want to effectively return a cstring that Nim won't collect
19:03:05leorizeyou will need to allocate your own storage for the cstring in that case
19:03:15FromDiscord<brainproxy> right, I'm asking how to do that, I have no idea
19:03:26FromDiscord<brainproxy> I found this: https://www.mail-archive.com/[email protected]/msg18309.html
19:03:31leorizehow do you want the cstring to be freed?
19:03:47leorizehmm, I never knew that we have a mailing list
19:04:02FromDiscord<brainproxy> foo will be part of a library compiled to `.a` and then statically linked by other C
19:04:12FromDiscord<brainproxy> so C caller should free
19:04:43leorizethen you will need to allocate the storage via malloc
19:05:11FromDiscord<brainproxy> example? (I'm a Nim novice, no experience with C / C++)
19:06:03FromDiscord<brainproxy> can that be done in the body of `foo` or are you saying that C caller will have to allocate with malloc and tell foo about that memory?
19:06:21leorizeit depends on how you would want to design your api
19:06:43leorizethough taking a cstring without a length is bad practice
19:07:17FromDiscord<brainproxy> I'm just working with what I've been dealt
19:07:23FromDiscord<brainproxy> it's a wrapper
19:07:37*sschwarzer quit (Quit: leaving)
19:07:45leorizewhat are you wrapping?
19:08:03*nikita` joined #nim
19:08:08FromDiscord<brainproxy> another C library
19:08:40leorizetypically you'd want to take the buffer size of the cstring so that you don't accidentally end up in buffer overflow
19:09:20leorizedo you need to use any of Nim's strutils?
19:11:15leorizeif you don't then it's as easy as just allocating a new buffer and copy the cstring over
19:11:24leorizethen you can pass it to any C library that you'd like
19:11:42Yardanicobut the caller should free it
19:13:23Yardanicohttps://github.com/nim-lang/Nim/issues/15154 found this while working on nimpylib lol
19:13:25disbotInternal compiler error when providing 'nil' for a proc argument in a generic procedure with two arguments ; snippet at 12https://play.nim-lang.org/#ix=2t6C
19:16:36FromDiscord<brainproxy> sent a code paste, see https://play.nim-lang.org/#ix=2t6F
19:16:39FromDiscord<brainproxy> I tried that, seems to work
19:17:11*maier joined #nim
19:21:48leorizeah no, that's not how :P
19:21:59*pulux joined #nim
19:22:11*maier quit (Ping timeout: 240 seconds)
19:22:19leorizeI need some more information on what this api of yours do
19:23:50leorizeC have strdup/strndup for string duplication if you need that
19:25:16FromDiscord<brainproxy> foo takes a cstring, converts to a nim string, calls another nim proc used to calculate a hash which is returned as a string; foo then converts to cstring and returns it↵↵the twist being, as above, I want to allocate memory size of the cstring to be returned and return that pointer, so that Nim's gc won't collect it and the caller is responsible for freeing it
19:25:35FromDiscord<brainproxy> (edit) 'that' => 'a'
19:25:39Yardanicojust malloc the result value then
19:25:41FromDiscord<brainproxy> (edit) 'foo takes a cstring, converts to a nim string, calls another nim proc used to calculate a hash which is returned as a string; foo then converts to cstring and returns it↵↵the twist being, as above, I want to allocate memory size of the cstring to be returned and return a pointer, so that Nim's gc won't collect it and the ... caller' => 'foo takes a cstring, converts to a nim string, calls another nim proc used to calculate
19:25:42FromDiscord<Ricky Spanish> seeing unquoted $ symbols as part of the syntax triggers me for some reason, makes me want to use nim more to overcome my fear
19:25:52Yardanico?
19:25:55Yardanicowdym
19:26:11FromDiscord<brainproxy> > just malloc the result value then↵I don't know how to do that, I was attempting with `create` above, what is the right way?
19:26:37FromDiscord<lqdev> nope
19:26:51Yardanicoeasiest way is
19:27:09leorizethe fear of bash xd
19:27:11FromDiscord<lqdev> you need to do `cast[cstring](alloc0(myStr.len))`
19:27:14Yardanicono
19:27:20Yardanicoit might not work
19:27:28FromDiscord<lqdev> why?
19:27:29Yardanicoit'll only work if you compile with -d:useMalloc
19:27:37leorizethey need to use malloc
19:27:38Yardanicobecause malloc has some metadata on it's own
19:27:39FromDiscord<lqdev> oh right
19:27:42Yardanico@brainproxy import system/ansi_c
19:27:46Yardanicoand then use c_malloc
19:27:49FromDiscord<lqdev> because nim has a different allocator
19:27:57leorizeYardanico: I'm not sure if that's public API
19:28:03Yardanicoit can be used as one :P
19:28:07FromDiscord<brainproxy> https://nim-lang.org/docs/ansi_c.html↵404
19:28:10Yardanicojust copy the procs from here https://github.com/nim-lang/Nim/blob/devel/lib/system/ansi_c.nim#L142
19:28:53leorizedon't push people into using private API, or you will spend time wondering why does changing private APIs suddenly make things not work
19:29:02Yardanicoleorize: I didn't push lol
19:29:12Yardanicoit just seemed as an easier way instead of duplicating stuff :P
19:29:36leorizewe might want to spin that off into a module just for cinterop :P
19:29:43leorizeor we can add more things to cstrutils
19:29:45Yardanicofwiw that c_malloc is there for 11 years
19:29:47leorizenot sure which is better
19:29:57Yardanicoalthough it was in lib/ansi_c
19:30:22Yardanicoyeah, I think it would be better to add a new module for some C interop procedures
19:30:26FromDiscord<lqdev> cstrutils is a thing?
19:30:27Yardanicoalso import/export cstrutils there :P
19:30:28Yardanicoyes
19:30:35FromDiscord<lqdev> docs?
19:30:36Yardanicoit's quite smol
19:30:36Yardanicohttps://nim-lang.org/docs/cstrutils.html
19:30:46leorizecstrutils is pretty basic
19:31:10FromDiscord<lqdev> interesting
19:31:15YardanicoI mean a lot of strutils procs can be ported to cstrutils easily
19:31:18Yardanicojust 1:1 really
19:31:40leorizethere just isn't a need for those tbh
19:31:49FromDiscord<brainproxy> `let str = c_malloc(c_strlen(hash))`↵like that?
19:31:59FromDiscord<lqdev> damn there are way too many stdlib modules that aren't documented in https://nim-lang.org/docs/lib.html
19:32:04FromDiscord<lqdev> @brainproxy yes
19:32:08Yardanicocstrutils is in that file
19:32:09Yardanico@lqdev
19:32:11Yardanicohttps://nim-lang.org/docs/lib.html#pure-libraries-string-handling
19:32:14Yardanicoliterally first entry here
19:32:22FromDiscord<lqdev> oh didn't notice
19:32:23YardanicoI don't think there are many undocumented stdlib modules
19:32:28FromDiscord<lqdev> but my statement still applies
19:32:30Yardanico"punycode Implements a representation of Unicode with the limited ASCII character subset."
19:32:32leorizeit's just hard to actually find them
19:32:34FromDiscord<brainproxy> okay, sorry for such simple questions, but then how do I copy the string into what I allocated?
19:32:36FromDiscord<lqdev> there are *some* less important ones
19:32:40Yardanicowhich ones?
19:33:00Yardanicothere was some work done on adding more stdlib modules to the lib index
19:33:01FromDiscord<brainproxy> `str[] = hash` doesn't seem to work
19:33:03leorize@brainproxy you will want to have `foo` take a length as well
19:33:11*Prestige quit (Quit: Prestige)
19:33:19FromDiscord<lqdev> @brainproxy `copyMem(destStr[0].addr, srcStr[0].addr, srcStr.len)`
19:33:32leorizeit's dangerous to do strlen() on a cstring without knowing whether it's NUL-terminated
19:34:29FromDiscord<brainproxy> sounds like good advice, I'll have to ask other team members if that's going to be feasible
19:35:00leorizemake sure they sanitize their inputs so that no NUL can sneak in and truncate the string
19:35:50*Prestige joined #nim
19:36:50leorizeand it's kinda weird that you'd return a hash as a string...
19:37:56FromDiscord<brainproxy> https://tenor.com/view/confused-ihave-no-idea-what-im-doing-gif-5948461
19:38:11FromDiscord<brainproxy> having trouble getting the copyMem thing to work
19:38:34leorizebut for those it's as easy as `result = cast[cstring](malloc(srcStr.len + 1)); copyMem(result, srcStr.cstring, srcStr.len), result[srcStr.len] = '\0'`
19:38:52leorizeI'll write you a small example
19:40:06*tiorock joined #nim
19:40:06*tiorock quit (Changing host)
19:40:06*tiorock joined #nim
19:40:06*rockcavera quit (Killed (verne.freenode.net (Nickname regained by services)))
19:40:06*tiorock is now known as rockcavera
19:40:26FromDiscord<brainproxy> sent a code paste, see https://play.nim-lang.org/#ix=2t6M
19:42:41disrupteki'd say that rotten milk is an acquired taste, but i think truthfully, it's only something that, like, norwegians enjoy.
19:42:56leorize@brainproxy: https://play.nim-lang.org/#ix=2t6N
19:44:12FromDiscord<brainproxy> do I need to define c_malloc as in example or I can just import system/ansi_c?
19:44:19Yardanicobetter define it
19:44:26Yardanicoansi_c is undocumented internal API :)
19:50:02FromDiscord<brainproxy> okay, working, though I had to `import system/ansi_c`↵↵If I instead define the proc as in the example I get a compiler error
19:50:07Yardanicowhat error?
19:50:11FromDiscord<brainproxy> could just be a typo in the example, not sure
19:50:53FromDiscord<brainproxy> ```↵Undefined symbols for architecture x86_64:↵ "_c_malloc", referenced from:↵```
19:51:03Yardanicoare you sure it was exactly
19:51:04Yardanicoproc c_malloc(size: csize_t): pointer {.importc, header: "<stdlib.h>".}
19:51:05Yardanico?
19:51:11Yardanicoah right
19:51:19Yardanicodo it like
19:51:20Yardanicoproc c_malloc(size: csize_t): pointer {.importc: "malloc", header: "<stdlib.h>".}
19:51:43Yardanicosame as in ansi_c when I linked you the code
19:51:47Yardanicohttps://github.com/nim-lang/Nim/blob/devel/lib/system/ansi_c.nim#L142
19:52:00FromDiscord<brainproxy> works great, thanks so much!
20:03:41FromGitter<iffy> @dom96 do you have a plan for when the next choosenim release will be? Anything I can do to help?
20:04:46FromDiscord<Varriount> @brainproxy Your spirit animal is a floating Shiba Inu?
20:05:53FromDiscord<brainproxy> more like a role model than a spirit animal
20:13:45FromDiscord<kodkuce> i horror coded some stuff and now its starting to pile atop each other, am so close to finish risk is high 🙂
20:19:51FromDiscord<exelotl> I wish I was a floating shiba inu
20:20:00FromDiscord<kodkuce> i survived , huh, i think my matchmaking serwer works now, learn a lot how to not *!$%** code for next time
20:20:13FromDiscord<kodkuce> why floating?
20:20:30FromDiscord<kodkuce> isent int shiba inu better?
20:20:48FromDiscord<exelotl> arbitrary precision shiba inu
20:21:40ZevvPMunch: they call it a spec, but parsing toml from that doc is not trivial
20:30:16FromDiscord<Zachary Carter> is there a way to change the name of the binary produced by nimble install? I tried setting the `out` switch in `config.nims` but it seems to have had no efect
20:30:19FromDiscord<Zachary Carter> (edit) 'efect' => 'effect'
20:31:24FromDiscord<Zachary Carter> oh I see there's an open feature for this - https://github.com/nim-lang/nimble/issues/515
20:31:25disbot[Feature] Allow specifying name for the binary in binary packages
20:31:55FromDiscord<Zachary Carter> (edit) 'feature' => 'issue'
20:35:01*narimiran quit (Ping timeout: 264 seconds)
20:49:55FromDiscord<Recruit_main707> sent a code paste, see https://play.nim-lang.org/#ix=2t7b
20:55:05FromDiscord<Shucks> Isn't working for me either. Mentioned it some time ago ;p
20:56:16FromDiscord<Shucks> adding it to the local project nim.cfg works
20:56:49FromDiscord<Shucks> well, the gccpath line.
21:02:00*noonien joined #nim
21:04:37*endragor_ quit (Remote host closed the connection)
21:05:05*endragor joined #nim
21:09:10*Jesin quit (Quit: Leaving)
21:09:23*endragor quit (Ping timeout: 240 seconds)
21:12:13*solitudesf quit (Ping timeout: 264 seconds)
21:14:20*Tlongir joined #nim
21:15:28*Trustable quit (Remote host closed the connection)
21:15:41*casaca quit (Remote host closed the connection)
21:16:02*Tlanger quit (Ping timeout: 265 seconds)
21:16:05*casaca joined #nim
21:18:03*maier joined #nim
21:19:42*Vladar quit (Quit: Leaving)
21:23:10*maier quit (Ping timeout: 256 seconds)
21:24:21*Jesin joined #nim
21:32:07*Tlongir quit (Ping timeout: 246 seconds)
21:40:55*Tlongir joined #nim
21:52:08*endragor joined #nim
21:53:11FromDiscord<Varriount> Shucks: I'll be honest, the only time I've cross-compiled on Windows was targeting 32-bit windows when running 64-bit
21:53:51FromDiscord<Varriount> And that's usually done by just downloading Mingw targetting 32-bit windows.
21:57:19*endragor quit (Ping timeout: 246 seconds)
21:57:27disruptekZevv: your tests pass, now that i've rewritten them. 😉
22:19:46*endragor joined #nim
22:24:49*endragor quit (Ping timeout: 264 seconds)
22:28:00leorizerust is making my life hard on musl libc...
22:28:54leorizeso much that I might consider migrating my system from musl back to glibc
22:29:51FromDiscord<Zachary Carter> I have an `arc` question... Let's say I have a main driver program that is loading a shared library (also compiled with `arc`)
22:29:56FromDiscord<Varriount> leorize: Rust?
22:30:54FromDiscord<Zachary Carter> sent a code paste, see https://play.nim-lang.org/#ix=2t7O
22:31:05FromDiscord<Zachary Carter> in the body of the function - bar is initialized to some value
22:31:08leorizeyea, I'm on gentoo, and firefox and alacritty need rust
22:31:29leorizelet just say that rust has never been made to properly support a system with musl libc as the main libc
22:32:08FromDiscord<Zachary Carter> how can I make this work with `--gc:arc` or can I? Do I just need to use `cstring ` and `copyMem`?
22:32:46leorize@Zachary even easier: compile both of them with -d:useMalloc
22:32:49leorizenow you can pass memory seamlessly between the two
22:33:30FromDiscord<Varriount> leorize: Do you know where Nim stores the refcount to an object?
22:33:34leorizeyou will have to give up Nim's TSLF allocator, but for most cases this shouldn't negatively impact performance
22:34:05leorize@Varriount look at system/arc.nim
22:34:39FromDiscord<Varriount> leorize: Also, doesn't that assumes that the two pieces (program and shared library) are using the same malloc implementation?
22:34:55FromDiscord<Varriount> (the same version of glibc/etc)
22:35:03FromDiscord<Zachary Carter> hmmm - I may just have to write my own allocators then
22:35:09leorizeboth of them will dynamically link against glibc
22:35:21leorizeor whatever libc that's on the system
22:35:40FromDiscord<Varriount> @Zachary Carter Is malloc not available?
22:35:53FromDiscord<Zachary Carter> no it is - but I'm worried about memory fragmentation
22:36:04leorizeyou can use libnimrtl
22:36:14leorizethat's the alternative way
22:36:24FromDiscord<Zachary Carter> that works with `--gc:arc`?
22:36:33leorizeyes, it will contain the allocator
22:36:43FromDiscord<Zachary Carter> gotcha
22:36:49FromDiscord<Zachary Carter> eh maybe implementating my own allocators won't be the worst thing in the world
22:37:31leorizeyou will most likely create a worse performing allocator
22:37:38FromDiscord<Zachary Carter> well I'll just use malloc
22:37:39FromDiscord<Varriount> http://www.mingw.org/wiki/Interoperability_of_Libraries_Created_by_Different_Compiler_Brands
22:38:18FromDiscord<Varriount> I believe that's also the reason why Python requires C extensions to be compiled using the same version of visual studio.
22:38:51FromDiscord<Zachary Carter> I think I'm just going to wrap malloc so I can do leak detection
22:38:57leorizeseems to not be a problem for this case
22:39:23leorizejust do -d:useMalloc, then sanitizers will just work
22:39:35leorizeas well as valgrind, if you want to go that route
22:39:42FromDiscord<Varriount> Ah, here's what I was looking for: https://devblogs.microsoft.com/oldnewthing/20060915-04/?p=29723
22:39:59FromDiscord<Zachary Carter> I've run into weird issues with asan and plugins
22:40:28FromDiscord<Varriount> I know symbol resolution works differently on Linux though
22:41:19FromDiscord<Zachary Carter> Okay I'm doing something stupid
22:41:28leorizethis pretty much sums up why linux distros exist lol
22:42:06leorizeand yea, on linux we invented this "symbol versioning" thing to "fix" the issue
22:42:14leorizeit's terrible, but at least it works
22:42:45FromDiscord<Varriount> leorize: It's not that, it was something to do with DLLs being able to "see" symbols that other DLLs have loaded.
22:42:52FromDiscord<Varriount> On Linux
22:43:27leorizeit's differences in how symbol binding is done
22:44:30FromDiscord<Varriount> Like, I believe the nimrtl shared library could technically be abandoned on Linux (the implementation would have to change, but its possible, whereas it's impossible on Windows)
22:44:37FromDiscord<Zachary Carter> https://gist.github.com/zacharycarter/f4ce2497eead09afd5704d5ee774d274
22:44:47FromDiscord<Varriount> (edit) '(the' => '(Nim's runtimee'
22:44:59leorizenah, you'd still need nimrtl on linux
22:45:06leorizethe shared state of the allocator matters too
22:45:51leorizemost allocator maintain a graph containing the blocks they acquired from the operating system
22:45:51FromDiscord<Zachary Carter> my app just hangs when I call `unloadLib`
22:46:32FromDiscord<Varriount> Or maybe its that DLLs can access symbols provided by the executable?
22:47:07FromDiscord<Varriount> @Zachary Carter What currently happens when you compile & run everything?
22:47:24leorize@Zachary you need examples that actually compiles, or else it's hard to help :P
22:48:11FromDiscord<Zachary Carter> @Varriount the application just hangs and eats cpu when I unload the shared library
22:48:19FromDiscord<Zachary Carter> I can edit that into a minimal working example
22:49:25FromDiscord<Varriount> @Zachary Carter What OS are you on?
22:49:30FromDiscord<Zachary Carter> macOS
22:51:27*endragor joined #nim
22:57:48FromDiscord<Zachary Carter> leorize @Varriount - should compile now https://gist.github.com/zacharycarter/f4ce2497eead09afd5704d5ee774d274
23:00:04*endragor quit (Ping timeout: 256 seconds)
23:00:16FromDiscord<Zachary Carter> just fixed the shared library extension for linux
23:06:56FromDiscord<Zachary Carter> ahhh
23:07:18*NimBot joined #nim
23:09:42FromDiscord<Zachary Carter> effing mac
23:13:33leorizelooks like you found a test case for our tlsEmulation :p
23:13:46FromDiscord<Zachary Carter> 😄
23:14:26FromDiscord<Zachary Carter> well I should have just put that flag in by default
23:14:44FromDiscord<Zachary Carter> because every time I've had an issue with threading on macOS that's always been 4raq's first suggestion
23:14:53FromDiscord<Zachary Carter> so I should have known better 😛
23:15:24leorizedunno, maybe we should toggle that off for mac :P
23:15:38leorizewhen does mac have native thread var again?
23:16:01*endragor joined #nim
23:16:03FromDiscord<Zachary Carter> I think it already does
23:16:12FromDiscord<Zachary Carter> oh you mean what version
23:16:26*Guest8511 quit (Ping timeout: 256 seconds)
23:16:29FromDiscord<Zachary Carter> XCode 8
23:16:31FromDiscord<Zachary Carter> is when it arrived
23:16:47FromDiscord<Zachary Carter> https://stackoverflow.com/questions/28094794/why-does-apple-clang-disallow-c11-thread-local-when-official-clang-supports/29929949#29929949
23:17:58*dadada joined #nim
23:18:22*dadada is now known as Guest3540
23:18:56*maier joined #nim
23:24:13*maier quit (Ping timeout: 264 seconds)
23:25:31*endragor quit (Ping timeout: 246 seconds)
23:55:57*krux02_ joined #nim
23:58:23*krux02 quit (Ping timeout: 244 seconds)