<< 20-01-2020 >>

00:00:24*pbb joined #nim
00:05:03*Hideki_ quit (Remote host closed the connection)
00:37:05*cyraxjoe quit (Quit: No Ping reply in 180 seconds.)
00:38:24*cyraxjoe joined #nim
00:40:26*Hideki_ joined #nim
00:41:03*opal quit (Ping timeout: 240 seconds)
00:42:09*opal joined #nim
00:52:26*nuxdie quit (Ping timeout: 252 seconds)
00:52:51*nuxdie joined #nim
00:59:39FromDiscord<mfiano> Sigh. I spent all weekend fighting with the compiler. generics don't behave like i expect apparently
01:01:02Yardanicohow do you expect them to behave? :P
01:01:17Yardanicojust remember that type system inis compile-time :)
01:02:16*lritter quit (Quit: Leaving)
01:03:15*Hideki_ quit (Ping timeout: 272 seconds)
01:03:44FromDiscord<mfiano> Well for a start, I'd expect this to fail to compile https://play.nim-lang.org/#ix=27RU
01:09:57Yardanicowell, seems like the resulting type is Vec2[system.float32]
01:10:22Yardanicoseems like it's wrong for me, but you can always specify types explicitly
01:15:00FromDiscord<mfiano> Also I cant for the life of me figure out how to make this more generic and use a seq for storage and be able to create arbitrarily sized vectors
01:16:15nisstyreIs it safe to delete keys from a table while iterating over `pairs` ?
01:16:39Yardanicohttps://forum.nim-lang.org/t/3892
01:16:50Yardanico@mfiano I'll show you some code as an example in a few minutes :)
01:16:54nisstyreok, makes sense
01:17:55FromDiscord<mfiano> Ok 🙂
01:18:05Yardanicowell, I found a pretty old version, but - https://forum.nim-lang.org/t/914#5463
01:18:15Yardanicouses array as the underlying type instead of a seq since it's compiletime
01:18:56Yardanicoor check out https://github.com/stavenko/nim-glm/blob/master/glm/vec.nim
01:20:43FromDiscord<mfiano> https://github.com/numforge/laser/blob/master/benchmarks/loop_iteration/tensor.nim seems to use seq but couldnt make sense out of it to adapt it
01:24:27FromGitter<mratsim> What's a Vec2[T]?
01:25:14FromGitter<mratsim> The tensor can store a Vec2[T]
01:25:41FromGitter<mratsim> Or you have 2 tensors, one for the x and one for the y
01:28:30FromGitter<mratsim> But otherwise isn't what you need just a seq[Vec2[T]]?
01:29:13FromGitter<mratsim> Or tuple[xs, ys: seq[T]]
01:30:48YardanicoI think they just want a generic Vector type :)
01:30:51Yardanicofor different sizes
01:35:44FromDiscord<mfiano> Yeah, and that swizzle macro doesn't work in that thread
01:36:03FromDiscord<mfiano> undeclared field 'xy' using their code
01:41:37FromDiscord<treeform> @mfiano I found that a generic vector is too much to deal with. The errors are ugly... the code is complex. Do we have integer[16bit], integer[32bit], integer[64bit]? No ... it feels too heavy to use generics for a simple thing like vector.
01:42:07FromDiscord<treeform> In games you always use the float32 vector anyways almost 100% of the time.
01:42:50FromDiscord<mfiano> Thanks for your thoughts on the matter. I did read your implementation. I am just frutrated because I've been trying to write trivial code for days now and can't even get more than 10 lines to compile.
01:42:50FromDiscord<treeform> For a space game I was working on i had the flaot32 scene vectors and float64 space vectors ... even then I don't think generics would have helped me.
01:43:31FromDiscord<mfiano> That isn't true. I use half-floats and boolean vectors a lot to be passed as uniforms and to populate various buffers
01:44:05FromDiscord<mfiano> Though I have been a game developer for 20 years, so I've seen a lot of studio magic
01:44:24FromDiscord<treeform> I like magic when it works... I hate magic when it does not.
01:45:58FromDiscord<mfiano> Fair point.
01:46:24FromDiscord<mfiano> I'm just frustrated. Rust didn't even give me this much difficulty with its compiler, and I think that speaks volumes as to how I'm struggling here.
01:49:15nisstyremfiano: Have you ever written Haskell? It took me months to get comfortable and not have huge compiler errors all the time
01:49:28nisstyreit's normal to have a high learning curve for some things
01:49:30nisstyregive it time
01:49:51FromDiscord<mfiano> Yeah I years ago
01:54:08*leorize quit (Quit: WeeChat 2.6)
02:10:28disruptekrayman22201: fair amount of corruption with that patch.
02:18:28rayman22201Yeah. No cycles any more but the closures don't live long enough. I think the fix is to give ownership of the closures to the Promise (this is what "disposable Promise" is supposed to do). But I'm at a party right now, so I can't do further testing.
02:20:44disruptekexactly. because we want everything to flow from the future.
02:21:27rayman22201Still good progress though. We had to break the cycle first
02:22:52*xet7 quit (Ping timeout: 268 seconds)
02:30:19*Hideki_ joined #nim
02:49:21FromDiscord<Rika> Huh. The default of a range[1..20] is 0, how do I change this?
02:49:58disruptekthat's a good first step.
02:51:16disrupteki don't think you can without default fields; clyybber would know.
02:55:06FromDiscord<treeform> @mfiano it looks like float64 gets auto converted to float32... https://play.nim-lang.org/#ix=27Sd I never know that happens.
02:56:41FromDiscord<treeform> from manual:
02:56:43FromDiscord<treeform> ```Automatic type conversion in expressions with different kinds of floating
02:56:43FromDiscord<treeform> point types is performed: the smaller type is converted to the larger. Integer
02:56:43FromDiscord<treeform> types are **not** converted to floating point types automatically, nor vice
02:56:44FromDiscord<treeform> versa. Use the `toInt <system.html#toInt,float>`_ and
02:56:44FromDiscord<treeform> `toFloat <system.html#toFloat,int>`_ procs for these conversions.```
02:57:41FromDiscord<treeform> But the example I have is larger float64 bit is being auto converted to a smaller float32 bit.
02:59:27FromGitter<Varriount> disruptek: I'm still unsure as to whether this whole "only reference counting" scheme is going to help Nim.
02:59:42disruptekwut
03:00:15disruptek"only reference counting"?
03:00:49disruptekyou mean weak?
03:00:55FromGitter<Varriount> Well, that's why cycles have to be broken in all the async stuff, right? There's no cycle detection/collector
03:01:07disruptekthere is, in the form of orc.
03:01:32disruptekbut orc makes more sense as a tool to help you have orc-free code that's faster to build and faster to run.
03:02:14disruptekobviously there are some cases where it'll be useful as an impl detail but...
03:03:22FromGitter<Varriount> That assumes that a user of the language has high performance requirements
03:04:08disruptekif orc improves then it could be made default, but it's pretty slow right now.
03:04:23FromGitter<Varriount> And that library writers will test their libraries using only arc
03:05:02disrupteki doubt most writers test their libraries.
03:05:27disrupteki mean, with regard to gc.
03:05:57disruptekgolden tests itself for leaks. i don't think i've ever seen such a test before.
03:06:18FromGitter<Varriount> I wonder how possible it is to detect reference cycles at compile time
03:06:25disruptekadmittedly, i haven't looked at a lot of tests. at least, i don't think i have.
03:06:48disruptekthat's what orc does.
03:07:36FromGitter<Varriount> It's not a classic mark-and-sweep GC?
03:08:25disruptekno, i don't think so.
03:09:23disruptekit's weird, but i know the compiler better from c than i do from nim.
03:14:24FromDiscord<treeform> I create a forum post to talk about this float64->float32 stuff: https://forum.nim-lang.org/t/5836
03:16:01FromDiscord<treeform> disruptek, is it easier to test a deterministic GC for leaks? Your program can always check if its allocated memory = 0 right when it exists?
03:16:23*endragor joined #nim
03:16:41FromDiscord<treeform> Maybe there it could auto check on debug builds on exit and says some thing like "leak detected" on exit.
03:16:56disrupteknot just that. in theory you can optimize alloc and layout.
03:23:28*dddddd quit (Remote host closed the connection)
03:24:37disruptekimagine that at process "exit" you examine the memory. you are expecting to find value X.
03:25:18disrupteknow you can mess with the guts and still predict whether you deviate from X.
03:31:27disruptekwe could do that at the end of a closure.
03:32:10disruptekor inside the cfg, really.
03:34:35*Hideki_ quit (Ping timeout: 268 seconds)
03:37:55FromDiscord<treeform> you could create asserts such as grab the amount of memory entering a critical section and exiting a critical section should match it...
03:38:16disruptekor be a multiple of X, etc.
03:39:21FromDiscord<treeform> I wanted to add a pragma ... that says some thing like will not allocate memory ... so that I can guard performance sensitive functions from allocating heap... so its kind of related.
03:40:23disrupteki wonder; is there an effect for heap use?
03:40:56disruptekthat seems like the right place for it.
03:53:08*muffindrake quit (Ping timeout: 248 seconds)
03:55:32*muffindrake joined #nim
04:15:21*rockcavera quit (Remote host closed the connection)
04:48:26*marmotini_ joined #nim
04:51:24*nsf joined #nim
04:53:10FromDiscord<mfiano> @treeform Indeed. It seems like a serious flaw
05:03:26FromDiscord<treeform> @mfiano https://forum.nim-lang.org/t/5836
05:09:03FromDiscord<mfiano> I saw
05:09:42*ptdel quit (Remote host closed the connection)
05:15:13Zevvmoi'n folks
05:15:24disruptekhowdy zevv
05:15:46Zevvwhile we are talking allocs: I noticed nim's alloc implemention does not really do realloc - it always makes a new copy
05:16:05ZevvI have a 3 line snippet that runs 3 times faster with -d:useMalloc then with nims allocator
05:16:16Zevvand its not even that pathethic a use case
05:16:33disrupteky'know i love to hear these stories.
05:16:48disruptekit just means we're barely scratching the surface of what's possible.
05:17:19disrupteki'm not allowed to scratch any more.
05:17:33disruptekfungus, impetigo, mrsa.
05:17:39Zevvhttp://ix.io/27Su
05:17:55disruptekhonestly, i'd get in trouble if they knew i took my gloves off.
05:18:21Zevvscratching the *surface* is always allowed
05:18:27Zevvdon't dig too deep, though
05:18:39disrupteknice "use-case".
05:18:50Zevvfunny eh
05:18:52disrupteki don't think that word means what you think it means.
05:20:04Zevvnow someone will remark that I should use `string.repeat` instead of course
05:21:01disruptektreeform: got another candidate for your nimbench.
05:22:05ZevvI'll see if I can grog nims allocator and make it do the Right Thing here
05:22:19Zevvs/grog/grok/
05:22:29disruptekgrog has its uses, too.
05:23:40disrupteki wouldn't waste it on the allocator, though.
05:24:55Zevvit makes me find the courage, right
05:25:04disruptekthat's it.
05:25:17disruptekit girds the loins.
05:25:17Zevvbut anyway, a more then 3 times speedup might be worth the effort.
05:25:28disruptekthing about the allocator though, is.
05:25:31disruptekshe always puts out.
05:25:32disruptekalways.
05:25:45disruptekdon't waste your grog on the allocator.
05:31:01*Hideki_ joined #nim
05:35:18*Hideki_ quit (Ping timeout: 260 seconds)
05:35:23Zevvwhy do i even talk to you, i wonder
05:35:41Zevvbut then again, hey, why not!
05:36:20disruptekzevv i'd like to tell you, but my dog is growling at me.
05:37:49disruptekkeep my chair warm for the next 8hrs and have a good shift.
05:39:20Zevvsweet dreams
05:39:24*narimiran joined #nim
05:49:49*marmotini_ quit (Remote host closed the connection)
06:31:20*sagax quit (Read error: Connection reset by peer)
06:31:56*voltist quit (Quit: Leaving)
06:39:20FromDiscord<demotomohiro> ~~
06:39:52FromDiscord<demotomohiro> ~nim
06:39:52disbotno footnotes for `nim`. 🙁
06:58:29FromDiscord<DeltaPHC> Is there any documentation on how `testament` works? I can get the command line args of course, but that doesn't tell me how to write the actual tests, lol
06:59:33shashlickthe nim-lang/nim/tests folder is full of them
07:00:20FromDiscord<DeltaPHC> Ah, examples. That's a start, thanks
07:00:47FromDiscord<DeltaPHC> I do think there should be an official guide for tests
07:01:32shashlickagree
07:02:28*dadada joined #nim
07:02:51*dadada is now known as Guest60505
07:07:34*arecaceae quit (Remote host closed the connection)
07:07:59*arecaceae joined #nim
07:13:45FromDiscord<DeltaPHC> It's something that I think Rust gets right for the most part. It doesn't even have the most featureful or amazing tests, but the barrier of entry is so low. Write functions with asserts in them, attribute them as tests, `cargo test`, that's it
07:16:14shashlickthere is also nimble test and unittest module
07:17:03*Vladar joined #nim
07:17:49FromDiscord<DeltaPHC> unittest docs say to use testament :P
07:18:53FromDiscord<DeltaPHC> Didn't know about nimble test though
07:26:27FromDiscord<Rika> i think they mean when making tests for the compiler
07:26:33FromDiscord<Rika> otherwise, unittest is fine
07:26:57FromDiscord<Rika> from my experience there were no issues, but yeah that was my experience
07:29:31FromDiscord<DeltaPHC> I'm thinking that having three different, official ways of testing is a tad confusing, but I suppose it's not as big of a deal as just having tests in the first place
07:31:44FromDiscord<Rika> testament is supposed to replace unittest but i dont know where that's gone
07:37:07FromDiscord<DeltaPHC> Ideally there should be just one official way to do tests. People will still be free to make their own testing frameworks, but just officially speaking, I think unifying into one thing would be beneficial
07:45:56FromDiscord<DeltaPHC> Especially as Nim's ecosystem grows, people at any experience level shouldn't feel intimidated by writing tests, IMO
07:53:49Araqfrederico had the idea of using testament with unittest's syntax
07:53:55Araqand I think it's a good one
07:54:31Araqbarrier to entry is low with Nim too, use 'when isMainModule: assert ...'
07:54:54Araqand then run 'nim c -r mymodule'
07:55:31*muffindrake quit (Quit: muffindrake)
07:56:54*JustASlacker joined #nim
08:00:09FromGitter<Varriount> A mock generating framework would be nice. Somewhat difficult though
08:04:54*gmpreussner joined #nim
08:11:41FromGitter<zacharycarter> most languages don't have "an official way to do tests"
08:12:15FromGitter<zacharycarter> generally libraries are authored to provide support for testing
08:12:36FromGitter<zacharycarter> golang however had a test module in their stdlib
08:12:45*sagax joined #nim
08:13:02FromGitter<zacharycarter> I like the idea of the unittest module staying around, and just having its internals gutted for whatever the best implementation is - whether its testament or something else
08:13:37FromGitter<zacharycarter> I should say - most languages I've used, because I haven't used enough to make that definitive of a statement
08:17:46Araqyeah, unnittest is unkillable, we need to fix it
08:20:54FromGitter<Varriount> @zacharycarter it seems like, usually a de-facto standard arises
08:21:49FromGitter<Varriount> Python has an official unit test module, however most projects use pytest or nose
08:23:13FromGitter<zacharycarter> yeah - I guess I just don't like the word official, because as you just pointed out Python has an official one but most projects don't use it
08:23:43FromGitter<zacharycarter> I suppose that's unavoidable though
08:23:50*solitudesf joined #nim
08:25:50Araqnot sure how it can be fixed though, it uses plenty of templates that are supposed to be "overridable"
08:26:11Araqand it uses inheritance and methods for the output generation
08:26:26Araqnothing I consider idiomatic.
08:29:42*muffindrake joined #nim
08:31:41Araqhmm testament could simply support a very similar DSL
08:36:24*PMunch joined #nim
08:38:19*floppydh joined #nim
08:48:37Zevvso, how do I add these leak checks back in those tests.
08:49:41Zevvusing valgrind is not good for the run time and not portable
08:50:12Zevvglibc has malloc debug support, is that portable enough?
08:50:24ZevvOr add counters into all the alloc implementations?
08:51:08*uu91 joined #nim
08:52:35AraqI hoped there would be some semi-portable way to implement getOccupiedMem
08:52:56Araqlike malloc_opt_getusedmem
08:53:35Araqmaybe will fewer vowels to please the dyslexics
08:53:40Araqmaybe with fewer vowels to please the dyslexics
08:55:47Zevvwe can add that for implementations that don't provide it, would be pretty trivial. Alternative would be to do this ourselves - rename all the allocX procs to allocXimpl, and create some templates with the old names that optionally keep track of allocation counts and sizes. Enable for tests, keep disabled for production.
08:56:25ZevvThe good thing of having one allocX implemenation is also that it is easer to add other ad-hoc trace code, like printing all allocs/frees, and it will work with all implementations
09:00:59PMunchWait, are abbreviations with less vowels actually easier for dyslectics? Or where you just joking?
09:13:25AraqPMunch, joking.
09:13:32AraqZevv, yeah, sounds good
09:14:04*Guest60505 is now known as dadada
09:15:38dadadaI'm considering buying "nim in action" ... will I get updates of this ebook for free, when I buy it? Will it get updated regularly?
09:16:00*Vladar quit (Quit: Leaving)
09:21:34dadadamostly considering it to support Nim development, it would be nice to informed about changes to Nim through future versions of the same book though
09:25:46livcdnot with manning
09:25:52livcdyou get a 50% off at best
09:42:06FromGitter<zah> https://scontent.fsof6-1.fna.fbcdn.net/v/t1.0-9/82879865_2495312787401153_3735925264601841664_o.jpg?_nc_cat=107&_nc_ohc=nAX1hynL67EAX_XVLMv&_nc_ht=scontent.fsof6-1.fna&oh=2ca78be11eee2d0f540b9086ed0749b9&oe=5ED51492
09:45:14*Vladar joined #nim
09:45:50Araq:D
09:46:05FromGitter<zacharycarter> where is that from?
09:46:07FromGitter<zacharycarter> the picture I mean
10:01:00FromGitter<zah> Code::Dive in Poland
10:04:52PMunchdadada, the book is really good. And great care is taken to make sure that the examples all work in newer versions. It won't get updated though, so any completely new features you to to learn about from other sources
10:11:11FromGitter<zacharycarter> oh cool
10:14:06dadadaok, this may be a backwards idea, but hear me out, to create bindings for complex C++ projects couldn't we exploit the binary libraries with debug information? Thankfully work for parsing those has somewhat been done already, https://github.com/eliben/pyelftools
10:14:14*uu91 quit (Read error: Connection reset by peer)
10:15:09dadadathe process would be compile say Qt5 with debug information -> use pyelftools as basis for custom tool to parse the created libraries and get all the information Nim needs to interface/interop with the library
10:17:01Araqit would most likely be machine specific and not help much
10:17:22Araqfor example, how do you get information about the API's default parameters?
10:17:39Araqit's a concept that doesn't exist in the binary, the compiler filled out some parameters for you
10:18:55Araqlook, Qt is very special with its moc compiler, arguably it's not really standard C++ so even if we had a perfect C++ parser producing a perfect Nim wrapper it would fail for Qt
10:19:01dadadagood point about the default parameters
10:19:18AraqQt deserves a special tool.
10:19:31AraqI know it sucks, but I can see no other realistic option
10:19:35dadadarequires maybe, deserves I'm not so sure about...
10:19:49Araqok, agreed
10:22:04dadadathey created shiboken2 for the python bindings, maybe it can be adapted...
10:22:18dadadahave been thinking about how to make Nim popular
10:22:48Araqwe have a QT wrappers btw
10:23:27*sagax quit (Ping timeout: 265 seconds)
10:23:27Araqbut it uses the Qt dynamic stuff, tbh I have no clue. ping filcuc
10:24:35dadadayou mean QML then, I have never really liked that portion of Qt, QtWidget is what KDE is written in basically and that's the API I'd like to get for Nim
10:25:09dadadawell QML might be great, but I've never really found a use for it (yet)
10:25:41dadadaAraq:
10:25:41Araqyeah I think that is what it uses, QML
10:25:58dadadathis basically says you're right http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2008-January/003271.html
10:26:12dadadaDWARF can tell you that there's a default value
10:26:23dadadabut it's not easily readable what that is
10:26:39dadadait points to a subroutine that can define it, but that's machine code
10:26:46Araqthat's only an example
10:26:57Araqhere is what is in DWARF: 16
10:27:08Araqhere is what it really is: sizeof(int) + sizeof(void*)
10:27:25Araqcompilers love constant folding
10:28:33AraqI know of no system whatsoever that uses DWARF to extract a high level interface
10:28:48dadadahow about a backend for clang or gcc that doesn't compile to a library but to a JSON containing all relevant information for bindings
10:28:56dadadanot that I'm going to write that :D
10:29:10Araqthat's what nimterop does to some extend afaik
10:29:44Araqbut if your real goal is to make Nim more popular, try our QML wrapper, write some examples
10:29:51Araqdocument its pain points
10:30:08Araqmaybe offer binary downloads so that the rest of us doesn't have to hunt for missing DLLs
10:30:54Araqseems to be a more fruitful approach
10:31:05dadadawell the best thing would be to port some large Qt project with a user base, that's usually not going to be QML
10:31:32dadadathere's flatpack, snap, appimage, one of those should do the job
10:31:57Araqbut then who's gonna maintain the port? and are the core devs willing to switch languages?
10:32:30Araqthe world is full of reddit clones, yet everybody uses the one and only reddit
10:32:38dadadaI have some abandoned Qt project that I used to maintain that has users
10:32:40dadadaAQEMU
10:32:54FromGitter<dumjyl> for `const a = [1, 2, 3]; const b = a` where does `b` get resolved to `a` in the compiler?
10:33:52Araqdymjyl: line 616 in semstmts.nim
10:34:20FromGitter<dumjyl> thanks
10:34:37Araqdadada, aha, now we're talking
10:52:53*JustASlacker quit (Ping timeout: 272 seconds)
11:03:56dom96@zah: wow, how many talks has Viktor done on Nim now? must be at least 4
11:04:26FromGitter<zah> I've lost the count myself, but 4 sounds about right
11:08:40dadadathe talk is great, hope he keeps it up
11:11:07dom96I got an invite for Code::DIve last year but wasn't brave enough :)
11:13:21FromDiscord<kodkuce> any web scrping lib done in nim?
11:18:05FromGitter<zacharycarter> https://nimble.directory/search?query=scraping
11:19:15FromGitter<zacharycarter> pretty excited to try out weave tonight
11:19:42FromGitter<zacharycarter> and see if it will help with my pathfinding bottleneck
11:19:51*xet7 joined #nim
11:20:28FromDiscord<kodkuce> i was blind 200%
11:23:03FromDiscord<Rika> how do i make a "context manager" (think that's a python term) in nim
11:27:03Araqvia template withX(body) = ...
11:33:15*Hideki_ joined #nim
11:33:18FromDiscord<kodkuce> hmm oh i got html parts i need, now how do i convert html objects to nim objects , i have that xmlNode
11:36:38ZevvIs there a way to get a proc name as a (const) string at compile time?
11:37:08FromDiscord<kodkuce> or do i need to subquery
11:37:52*Hideki_ quit (Ping timeout: 260 seconds)
11:40:54lqdev[m]Zevv: in what sort of case?
11:42:13lqdev[m]you can get the name of a proc as a string pretty easily using macros, but I'm not quite sure what AST you're dealing with
11:42:14Zevvlet's say "echo functionName()"
11:42:47Zevvwhen done in proc foo will print "foo"
11:43:02Zevvno need to have full signatures etc, just to simplify some code where I now pass explicit strings
11:45:21FromDiscord<kodkuce> how do i rip text form <h1>dsadsad</h1>
11:46:04FromDiscord<kodkuce> prbbaly innerText
11:46:25lqdev[m]Zevv: can you give a full example of the input and expected output?
11:47:22*rockcavera joined #nim
11:47:28*dadada quit (Ping timeout: 260 seconds)
11:53:03*sagax joined #nim
11:55:08PMunchZevv, that would indeed be a neat feature
11:55:29lqdev[m]oh, I think I get it
11:55:51lqdev[m]I don't think that's a feature, unfortunately
11:56:46lqdev[m]there's system.instantiationInfo() but it only returns the file and position
11:57:01PMunchAnd it only works for templates
11:57:02PMunchhttps://play.nim-lang.org/#ix=27Ty
11:57:08PMunchI think that is what he wants
11:58:28Zevvlike __FILE__ and __FUNCTION__ in the c preprocessor
11:58:39Zevvbut nvrmnd, Im fine now
11:59:04*dddddd joined #nim
12:02:10FromGitter<dumjyl> You can do that with `owner`. This seems to work https://play.nim-lang.org/#ix=27TA
12:03:25Zevvsweet, thanks!
12:04:15lqdev[m]nice, I didn't think of that
12:06:12PMunchNever heard of owner before!
12:07:12PMunchAdded back in 2018
12:08:59FromGitter<dumjyl> It exposes unspecced implementation details, so best avoid it if you can.
12:09:14lqdev[m]I did play around with owner for name mangling recently
12:14:00Zevvcan't use it in my context, I'm too deep in the stdlib and can't use macros or NimNodes there. No problem, thanks anyway
12:18:02PMunchToo bad this isn't just built in, the compiler has to know this, right?
12:18:21Zevvwell, no one seems to have needed this up to now :)
12:18:40Zevvand the context is tricky probably. What if you call it from within a template?
12:20:19PMunchIt xpands and is then resolved right before the procedure is converted into C code?
12:20:59Zevvdo we have a volounteer? :)
12:22:45FromDiscord<Rika> araq: is that the only way? i guess it works. i asked because i dont really like the withX style
12:23:56FromDiscord<kodkuce> i have wierd issue, am trying to just filter out something, so i am trying to use contains form strutils duno if xmlparser or some othe thing i importing is naming it same or what, but i am getting Error: type mismatch: got <string, string> but expected one of: proc contains[T](a: openArray[T]; item: T): bool, on playground if i do "sdasdsad".contains("sda") it works too so duno wtf is going around
12:24:29*FromGitter quit (Remote host closed the connection)
12:24:47*FromGitter joined #nim
12:25:06FromDiscord<Rika> what version are you on xd
12:25:38FromDiscord<Rika> if xmlparser exported the same name+arity function, it wouldnt compile at all
12:25:45FromDiscord<kodkuce> omg i am retard
12:26:14FromDiscord<kodkuce> i commented out strutils while i was commenting out old imports
12:27:18*matlock quit (Ping timeout: 258 seconds)
12:27:29*ryanhowe quit (Remote host closed the connection)
12:27:40*matlock joined #nim
12:27:41*gsingh93 quit (Ping timeout: 258 seconds)
12:27:45*sacredfrog joined #nim
12:28:22*shadowbane quit (Remote host closed the connection)
12:28:26FromDiscord<Rika> nice
12:28:49*shadowbane joined #nim
12:29:50*gsingh93 joined #nim
12:33:38*dddddd quit (Ping timeout: 240 seconds)
12:33:49FromDiscord<Tak> Maybe a silly question but I read that nim doesn't care if identifiers are my_func, myFunc or myfunc i.e snake case or capitalized
12:33:50FromDiscord<Tak>
12:33:50FromDiscord<Tak> Is that the case for standard library functions or just functions you write?
12:35:42PMunchIt's for any function
12:35:48PMunchOr rather any identifier
12:36:00PMunchSo variables and constants are the same
12:36:14PMunchThe capitilization of the first character matters though
12:36:16narimiran@Vindaar are you around maybe?
12:36:24PMunchso MyFunc would not be the same as myFunc
12:36:34PMunchTak ^
12:37:56FromDiscord<Tak> That's very cool, thanks. Follow-up - when calling a function, I saw it has UFCS where you can go object.func() or func(object). You can also go echo("Text") and echo "Text". Can you use spaced args for functions with more than one variable? i.e haskell style so like instead of my_func(arg_a, arg_b) you can go "my_func arg_a arg_b"?
12:38:14FromDiscord<Tak> Or for functions with no parameters?
12:40:19PMunchYou can't use it for functions without parameters
12:41:48federico3https://news.ycombinator.com/item?id=21969815 this comment should be put in the GC manual
12:42:21PMunchTak: https://play.nim-lang.org/#ix=27TL here is an example of things that are valid
12:43:13PMunchOh, and 100.test2() is also valid: https://play.nim-lang.org/#ix=27TM
12:44:45*dadada joined #nim
12:45:09*dadada is now known as Guest15862
12:46:46*dddddd joined #nim
12:50:16*letto_ joined #nim
12:52:13*letto quit (Ping timeout: 258 seconds)
12:57:25FromGitter<Vindaar> @narimiran yep, I am
12:58:28narimiran@Vindaar i fixed it in the mean time, nevermind :)
12:58:54FromGitter<Vindaar> Heh, ok. Was it about adding `ggplotnim` to the packages?
12:58:59narimiranyeah
12:59:24narimiranby default i couldn't run it locally because i didn't have `ntangle`
12:59:52narimiranbut we'll just test `nim c -r tests/tests.nim` (or any other file if you think it is more suitable or thorough)
13:01:12FromGitter<Vindaar> Oh, right that makes sense. Yes, the full test suite creates a bunch of recipe files from Org files using `ntangle`, which create a bunch of plots. These are then compared to reference plots to check if something changed in the images.
13:02:14FromDiscord<Tak> Brilliant, thanks PMunch, have used a fair few languages so just trying to get a feel for the syntax design 🙂 appreciate the help
13:03:35PMunchHappy to help :) Nims syntax is quite flexible!
13:04:31FromGitter<Vindaar> Maybe it's a better idea to exclude that part of the test from the default "test" task though
13:04:33FromDiscord<Tak> Yes, I've written a lot of FP stuff recently and always liked macro systems in CLisp and Rust so seems cool to have a pythonic lang with it
13:04:35FromDiscord<Rika> it's almost too flexible, but it isnt so thats 100% okay
13:05:17FromDiscord<Tak> Mm, I do wonder if it makes codebases less readable though if everyone uses it differently?
13:06:05Guest15862///////9-*9-----------------------8
13:06:17Guest15862sry, cleaning the keyboard :D
13:08:11FromGitter<Vindaar> @narimiran ok, I changed it. Please use the default `nimble test` now. :)
13:11:04narimiranyeah, it works now
13:11:32*Guest15862 is now known as dadada
13:14:06FromGitter<Vindaar> nice
13:21:45FromDiscord<Rika> tak, it doesnt really as its not very ambiguous
13:21:50*endragor quit (Remote host closed the connection)
13:21:57FromDiscord<Tak> Okie dokie 🙂
13:24:39*Hideki_ joined #nim
13:24:46PMunchIn fact I find it makes codebases more readable
13:25:01*arecaceae quit (Remote host closed the connection)
13:25:24PMunchI can write a library that uses snake_case, but you can use it as camelCase in your code-base so you're not mixing the two styles
13:25:24*arecaceae joined #nim
13:26:03FromDiscord<Tak> That's true, people get to use their preferred way
13:26:03FromDiscord<Rika> but camelcase is preferred over here
13:26:45FromDiscord<Tak> Ok will keep that in mind, is there a style guide?
13:27:46solitudesfhttps://nim-lang.org/docs/nep1.html
13:28:30FromDiscord<Tak> Thanks!
13:30:47*endragor joined #nim
13:33:56*couven92 joined #nim
13:35:39*endragor quit (Ping timeout: 268 seconds)
13:37:08*couven92 quit (Client Quit)
13:38:29FromGitter<kaushalmodi> Tak: Run `nim` with `--styleCheck:hint` or `--styleCheck:error`
13:38:36*couven92 joined #nim
13:39:03FromGitter<kaushalmodi> I put this in my global config.nims: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5e25ad7620d0f078a6ae2037]
13:40:10dadadawhat's the thing Nim sceptics usually dislike most about Nim?
13:40:37FromGitter<kaushalmodi> dadada: I guess the style insensitivity..
13:41:55dadadanah, I think that feature is good :D
13:42:11FromGitter<kaushalmodi> dadada: I am not complaining :)
13:42:18solitudesfthey dislike reading the tutorial and love making assumptions
13:42:54FromGitter<kaushalmodi> I wonder if Araq put that feature in just for the sceptics to hold on to as otherwise they wouldn't have anything else to complain about :P
13:43:28solitudesf@kaushalmodi there is always something to complain about
13:43:31solitudesf~&
13:43:31disbot&: 11unreachable -- solitudesf
13:48:17dadadaI see some minor deviations from python syntax where I'm going "did they really have to do this?", usually I get why it's done like that in all the individual cases, however in sum it means that transitioning from python (back and forth) could become a huge issue, since superficially code between the langs looks very similar, but the devil is in the details
13:48:55dadadadisclaimer: this isn't a complaint!
13:49:05Araqevery deviation from Python had a good reason, ymmv of course
13:49:12FromDiscord<Rika> dadada: i'd like an example
13:49:20FromDiscord<Rika> not that im gonna argue
13:49:22FromDiscord<Rika> i just want to know
13:50:10livcdmissing batteries
13:50:16dadadaFromDiscord: if I give you one example, you or I can both explain why it's making sense, it's the sum of the differences that could (and probably will) trip up some future devs
13:50:33FromDiscord<Rika> i said i just wanted to know
13:50:36FromDiscord<Rika> uuuuuuuuuuuu
13:50:43dadadaoften it's probably python's fault for having less sane syntax
13:52:33*Hideki_ quit (Remote host closed the connection)
13:54:21*Hideki_ joined #nim
13:54:24*Hideki_ quit (Remote host closed the connection)
13:55:00*Hideki_ joined #nim
13:55:13AraqPython: 'def' vs 'class' vs 'global' (?) vs nothing for varable declarations.
13:55:28FromGitter<alehander92> but this is good dadada
13:55:38FromGitter<alehander92> because semantically they are different languages
13:55:55FromGitter<alehander92> so similar syntax might be a bit confusing
13:56:00FromGitter<alehander92> i think syntax feel
13:56:27AraqNim: let vs var, proc vs func, type and const sections
13:56:45dadadaAraq: the ones you named all make sense to me
13:59:18*Hideki_ quit (Ping timeout: 258 seconds)
14:00:42*marmotini_ joined #nim
14:07:12FromDiscord<Rika> compiling C is making me go insane again
14:10:19*couven92 quit (Quit: Client Disconnecting)
14:19:32*rockcavera quit (Remote host closed the connection)
14:21:36dadadaAraq: why "notin" and "isnot" instead of "not in" and "is not" ... it's not a big deal either way, but one of python's draws is the natural language look
14:22:27Araqtwo token operators are arbitrary in a language where you can define your own operators
14:22:54Araqbut on the other hand, Nim's keyword operators are already arbitrary.
14:23:18Araqiirc 'not in' didn't fit my operator parsing algorithm though
14:23:47dadadasuspected that that was the reason ...
14:24:07dadadasimplification for the parser's sake
14:24:30dadadahate to tell you, but that's one of the things I don't quite like
14:24:35*rockcavera joined #nim
14:24:48dadadain a sea of things I love about Nim!(*1000)
14:24:53*Hideki_ joined #nim
14:24:53*Hideki_ quit (Remote host closed the connection)
14:24:54Araqno offense taken
14:25:14Araqbut notice that Python is FULL of "it's easier to implement this way" on its own
14:25:27*Hideki_ joined #nim
14:25:42*Hideki_ quit (Remote host closed the connection)
14:25:54dadadaactually writing a preparser that melts "not in" into "notin" would be easy, wouldn't need to change the actual parser
14:25:55*Hideki_ joined #nim
14:25:57FromGitter<alehander92> there is some kind of consistency here imo
14:25:58*Hideki_ quit (Remote host closed the connection)
14:26:07FromGitter<alehander92> its not only about parser but about overall grammar
14:26:25FromGitter<alehander92> it helps to be able to think "random two words cant be an operator defined by this macro" imo
14:26:30*Hideki_ joined #nim
14:26:45FromGitter<alehander92> and keep in mind "parsing" in your head is very common for the human users
14:26:52FromGitter<alehander92> when writing/reading dsl-s
14:27:43dadadawell isnot isn't part of the english language, if you're going for one word, then isnt or aint would both be more accurate, although you'd lack the '
14:28:07dadada(aint is slang admittedly)
14:29:08Araq'mole hill' vs 'molehill'
14:29:11*Hideki_ quit (Remote host closed the connection)
14:29:26*Hideki_ joined #nim
14:29:27*Hideki_ quit (Remote host closed the connection)
14:29:39FromGitter<alehander92> yeah i agree isnt probably would be a bit better
14:29:47FromGitter<alehander92> but after all .. isNot(a, b)
14:29:52FromGitter<alehander92> is also not part of the english language
14:29:55FromDiscord<Clyybber> I think its fine as is, its not Inform after all
14:30:00*Hideki_ joined #nim
14:30:12FromGitter<alehander92> maybe camelCase would've been the easier fix (and one can actually use that now)
14:30:17FromGitter<alehander92> (i think??)
14:30:17FromDiscord<Clyybber> and the consistency and simplicity gained is more than worth it
14:30:27dadadaalehander92: in the case of isNot the camel case makes it clear that is and Not are separate words, so it becomes clear that they're not one word
14:30:40FromDiscord<Clyybber> is_not :p
14:30:41FromGitter<alehander92> yes i agree that camelcase/_ would've been cleanest
14:30:48FromGitter<alehander92> but thats life
14:31:09FromGitter<alehander92> but mate
14:31:11FromGitter<alehander92> isinstance
14:31:12FromGitter<alehander92> getattr
14:31:13FromGitter<alehander92> etc
14:31:16FromGitter<alehander92> python has many of those
14:31:22FromDiscord<Clyybber> dadada: I mean, you can also simply not use notin, and do not(a in b) instead
14:31:30FromDiscord<Clyybber> Its just there for convenience
14:31:52FromDiscord<Clyybber> And bowing to the irregularity of natural languages doesn't quite fit with macros and stuff I suppose
14:33:29dadadaClyybber that syntax is obviously inspired by python (which I consider a good thing), I'd be surprised if parsing a two word phrase would really cause much trouble ... as Araq said, it's a "molehill", there are bigger fish to fry .... yet, I care about molehills like that, sorry
14:34:05dadadathere's just something off about the term "notin" when "not in" looks familiar and makes perfect sense
14:34:20dadadais notin not in or do we have no tin?
14:34:37Araqfwiw, not that it matters that much
14:34:43Araqfrom https://docs.python.org/3/reference/grammar.html
14:34:50Araqand_test: not_test ('and' not_test)*
14:34:50Araqnot_test: 'not' not_test | comparison
14:34:50Araqcomparison: expr (comp_op expr)*
14:34:50Araqcomp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
14:35:13Araqis ambiguous
14:36:12dadadahow about using ex instead of notin
14:36:19dadadaex means roughly outside
14:36:20Araqoh never mind, it seems to work out. for Python
14:36:22FromDiscord<Rika> dadada: context changes everything
14:36:38FromDiscord<Clyybber> dadada: Why though? Whats so bad about notin
14:36:39FromDiscord<Rika> ex sounds really vague
14:36:49FromDiscord<Rika> cant you write notIn anyway
14:36:58Araqbut here you go
14:37:04Araqfrom the same source:
14:37:17Araq# "test '=' test" is really "keyword '=' test", but we have no such token.
14:37:17Araq# These need to be in a single rule to avoid grammar that is ambiguous
14:37:17Araq# to our LL(1) parser.
14:37:21FromGitter<alehander92> dadada, again isinstance, geattr, python does the same
14:37:40FromGitter<alehander92> almost: yes, no operators, but the difference is not so big
14:37:47Araqsee? Python chooses to simplify things for its parser generator technology
14:37:50PMunchRika, yes you can
14:38:14FromGitter<alehander92> python's stdlib is also not always snake_cased
14:38:18PMunchOr not_in of course, if you'd like
14:38:21FromGitter<alehander92> which is not a problem imo
14:38:23*Hideki_ quit (Ping timeout: 260 seconds)
14:39:04Araq(and it's not a bad thing, LL(1) is a nice property to strive for)
14:39:24FromDiscord<Clyybber> dadada: But I have to confess, when starting to look at nim I also wondered/didn't like notin, but after thinking more about I came to the conclusion that its better to have not_in rather than special case the parser
14:39:28FromDiscord<Clyybber> its also better for tooling
14:43:47Araqhardly but come on, who cares. English itself doesn't know if it's two or one word, molehill, filename
14:43:53dadadaClyybber: notin irritates me, I understand the technical reasons, notIn or not_in would both be okayish, but for everyone who likes python it will keep looking wrong
14:44:32Araqyou're the first who claims that it "keeps" doing that.
14:44:48Araqmost human beings are kings of adaption
14:45:35PMunchdadada, you can use notIn and not_in in Nim :)
14:45:40FromGitter<alehander92> dadada, you keep ignoring my argument that many python core stdlib methods do the same
14:45:49*Hideki_ joined #nim
14:46:24FromGitter<alehander92> so while i agree with you aesthetically, i dont really believe in your conclusion
14:46:58FromGitter<alehander92> and yeah, iirc ive read ruby people complaining about python in this regard :)
14:47:07dadadaalehander92: I haven't ignored it, as I understand it "not" "==" "in" are more like keywords, like methods are methods and have always looked farther away from natural languager, also I don't consider python perfect in all regards obviously, or I wouldn't need to be here :D
14:47:22FromGitter<alehander92> also about even? vs is_even, so there is always more to have
14:47:56*NimBot joined #nim
14:48:10Araqdadada, here is what you should do:
14:48:19FromGitter<alehander92> yeah :)
14:48:52Araqprogram for nim for about 4 weeks and then tell us if it's still weird or whether your preceptrons could move on and you don't mind it anymore
14:49:01dadadaAraq: well, I'm certain I can adjust, but I'm opinionated on this issue, and I feel python's aesthetics here (just in this one case!) are superior
14:49:48dadadaI try to be a reasonable person, so I'll not refrain from using Nim just because of stuff like this, hopefully no one else will, tooo
14:49:57FromDiscord<Clyybber> : )
14:50:44*Hideki_ quit (Ping timeout: 265 seconds)
14:51:53dadadaAraq: what do you think about "ni" instead of "in", the logic that a reverse in means the opposite and randomly n stands for not and i for in, it's shorter too
14:52:08dadadas/reverse/reversed
14:52:15narimiranthis has gone too far
14:52:20solitudesfgarbage
14:52:47Araqdadada, I can accept you like Python more on this single aspect
14:53:05Araqbut I won't change the language or introduce more ways to write the same
14:53:19Araqyou can already use 'if not x.contains(y)'
14:53:38Araqand never use 'notin' anywhere in your codebase, it'll work ;-)
14:54:33*PMunch quit (Quit: Leaving)
14:56:01dadadawell, thanks nevertheless, it's not a big deal, just a matter of taste
14:56:22Araqyes and for good taste use 'contains' instead
14:57:29dadadayeah, that's nice ^^ options
15:05:43*oculux quit (Ping timeout: 265 seconds)
15:06:01*oculux joined #nim
15:08:29*ptdel joined #nim
15:16:40*ng0_ joined #nim
15:16:40*ng0_ quit (Changing host)
15:16:40*ng0_ joined #nim
15:20:03*ng0 quit (Ping timeout: 268 seconds)
15:27:10*marmotini_ quit (Remote host closed the connection)
15:27:44*marmotini_ joined #nim
15:30:37*ng0_ is now known as ng0
15:32:18*marmotini_ quit (Ping timeout: 265 seconds)
15:33:08ZevvProbably a very stupid question, but I don't see what is happening. I get an error "Error: system module needs: nimFrame" when trying to compile lib/nimrtl.nim after I made seemingly unrelated changes to the stdlib
15:33:12Zevvhow do I debug this?
15:33:33*Hideki_ joined #nim
15:34:56FromDiscord<Clyybber> Zevv: since valgrind doesn't help here I'd say use "askaraq"
15:35:20AraqZevv, it means you compile a proc with a body too early
15:35:43AraqNim seeks to give the proc the nimFrame stuff but nimFrame isn't available
15:36:47Zevvyeah, but I can really not see how this is related to my changes. I guess I'll have to backtrack
15:36:58*tane joined #nim
15:37:37Zevvit's this commit: it adds templates around the alloc implementations. I'm not touching anything rtl or nimFrame avaik
15:37:39Zevvhttps://github.com/nim-lang/Nim/pull/13190/commits/c0e04405e2ad63c88e76cf9e97c2a2f6f7159eea
15:37:40disbotRemoved lib/system/allocators.nim. seqs_v2 and strs_v2 now uses allocShared0.
15:38:39disruptekyou might need a shim for allocators before the rest of the machinery is in place.
15:38:39Araq proc `-`*(a, b: AllocStats): AllocStats = ?
15:38:54disruptekie. your tracing stuff, etc.
15:39:15ZevvAraq: what's with that?
15:39:23Araqeasy workaround: {.push stackTrace: off.} .. {.pop.}
15:39:37AraqZevv, it's a proc with an implementation
15:39:49Araqso Nim wants to generate a nimFrame and fails at it
15:40:30Zevvok, I clearly need to read up on this
15:42:04Zevvhow is that different from other procs with implementations in the same file?
15:42:20Zevvoh inlines, right?
15:42:41disruptekthey aren't procs.
15:43:57Zevv`proc freeShared(...)` isnt a proc
15:44:35FromGitter<alehander92> it sounds very socialist
15:44:47*Zevv is kind of in too deep it seems
15:48:38Araqyou cannot read about it
15:48:48disrupteklook at the code.
15:48:49Araqit's only ever an issue in system.nim
15:49:21Araqsystem.nim is crippled until the compiler arrives at the 'nimFrame' declaration
15:49:50Zevvright. So what are the general rules here?
15:49:57Zevv.inline. procs only?
15:50:26Araquse .push and .pop around your procs
15:50:29Araqas I outlined
15:50:58ZevvI removed those procs but still the same issue, so it is somewhere else still
15:51:01Zevvdigging
15:52:49Zevvok, fair enough. stackTrace off it is :)
15:52:50Zevvthanks
15:55:28*floppydh quit (Quit: WeeChat 2.7)
15:56:37*ptdel quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
15:59:10*ptdel joined #nim
16:04:27*Hideki_ quit (Ping timeout: 268 seconds)
16:05:21*krux02 joined #nim
16:07:26disruptekzevv, give us a hook to add a callback that receives some alloc audit info.
16:09:49*dadada quit (Ping timeout: 268 seconds)
16:10:00FromGitter<alehander92> ugh Araq karax breaks capture/closureScope
16:11:45*icebattle joined #nim
16:12:28*Trustable joined #nim
16:12:53Zevvdisruptek: no bah
16:13:06disruptekwell, a poll method, then?
16:13:34ZevvgetAllocStats
16:13:47Zevvyou can do it before and after and subtract them
16:13:59Zevvor do a withAllocStats: block
16:13:59disruptekdude.
16:14:18disruptekwhy no callback?
16:14:22disrupteki'll be good, i promise.
16:14:24Zevvwhy a callback?
16:14:33disruptekfor realtime graphing.
16:14:46Zevvso who times that?
16:15:01Zevvnope, this is it. if you want a graph add it some other way
16:15:04Zevvless is more here
16:15:33disrupteki can add it either way but i'd rather have distinct records of alloc sizes versus averages, etc.
16:15:54disruptekit goes until a define; it will be less most of the time.
16:15:57Zevvit is still tricky though, because there is always stuff going on the counters often do not add up
16:15:58disrupteks/until/under/
16:16:08Zevvyou can get 34 frees and 12 allocs
16:16:10disruptekall the more reason to run a callback.
16:16:20Zevvbut from where?
16:16:21FromDiscord<Rika> i hate C dynamic libraries now
16:16:25FromDiscord<Rika> im going insane due to them
16:16:29disruptekthat's your problem, sport.
16:16:33ZevvnimPreMain and nimPostMain?
16:16:50disruptekit doesn't have to capture initial allocs.
16:16:54disruptekjust the meat of the thing.
16:17:04Zevvthat is why you do a before and an after
16:17:24disrupteki'm gonna have golden's instrumentation running alongside the normal program.
16:17:27Zevvbut first i need to get it past ci and araq anyway
16:17:32disruptekfair enough.
16:20:02ZevvI also have a problem with determinism it seems. the old statistcs only measured free/alloc calls for seqsv2 and strsv2, now I measure them all
16:20:16Zevvbut some things are not stable over runs, which is kind of funny
16:20:31FromDiscord<Clyybber> now that is interesting
16:20:56disrupteksounds like you need that crappy context manager you wanted me to write.
16:21:55Zevvits about lifetime of stuff. things are not dead yet when i get the end result.
16:22:33disrupteksounds bad man.
16:23:11Zevvbut what can i do. my program is measuring itself, there is no outer entity to do that. I want to report allocs from within the program, but they only drop to zero when it is done.
16:23:31Zevvadding a printf() to NimMain?!
16:23:34disruptekso what?
16:23:44disruptekit's normal for programs to alloc memory.
16:23:57disruptekdelta the empty program against the full program.
16:24:26ZevvI'll think about it
16:26:57disruptekyou picked a pretty rotten time to mess with allocators.
16:27:50Zevvno its not
16:27:55Zevvits the right time, surely
16:28:26disruptekshirley, it will confuse arc debugging.
16:29:17Zevvit simplifies
16:29:21Zevvi threw stuff out
16:29:26Zevvi made stuff smaller
16:29:37Zevvtell me again how bad that is
16:29:38disruptekwait, did you add any bugs?
16:29:46Zevv3, but very well hidden
16:29:59disruptekfair enough.
16:30:13disrupteki'd have been disappointed if it were less than 3.
16:37:06*dadada joined #nim
16:37:31*dadada is now known as Guest73511
16:40:02*ptdel quit (Ping timeout: 260 seconds)
16:41:10*Hideki_ joined #nim
16:43:44disrupteki just noticed all my nipples are sagging.
16:43:51FromGitter<alehander92> so what do you want to debug
16:44:08disruptekwell, i gotta perk 'em up somehow.
16:44:09*marmotini_ joined #nim
16:44:27disruptekthey look a little shriveled, too.
16:44:42FromGitter<alehander92> free/alloc count only, or free/alloc "time"/size as well etc
16:44:53FromGitter<alehander92> if you only need count/size
16:45:20FromGitter<alehander92> one thing you can do is run under `rr` and script with simple python the gdb
16:45:33FromGitter<alehander92> to postprocess each alloc/free call
16:45:42disrupteki wanna build this functionality into any nim program.
16:45:46*Hideki_ quit (Ping timeout: 265 seconds)
16:45:51FromGitter<alehander92> this way you should have almost no overhead
16:46:08FromGitter<alehander92> yeah , of course, i just proposed if zevv wants to debug a certain bug in his projects
16:46:08disruptekoverhead is a fact of life.
16:46:35disruptekcats in boxes.
16:46:57FromGitter<alehander92> yeah, but you can move some of the "record" processing out of the original execution
16:47:24FromGitter<alehander92> doing that well enough helps with many practical cases..but i also have the very same problem with callgraphs anyway :P
16:48:02*ptdel joined #nim
16:51:21disruptekwe'll just fork for every malloc and process the audit in another thread. 😁
16:52:44Zevvalehander92: i know we can run under external tools, but arq wants something portable that always works everywhere
16:53:01Zevvthe simple solution would be to dump the counters after nim is done from C
16:59:27Zevvand the overhead is minimal. when enabled two ints are incremented, when disabled there is no code and no data emitted
17:00:57*abm joined #nim
17:23:33Guest73511https://www.phoronix.com/scan.php?page=news_item&px=Red-Hat-MIR-Lightweight-JIT
17:23:41*Guest73511 is now known as dadada
17:24:10*dadada is now known as Guest39061
17:24:30*Guest39061 is now known as dadaa
17:24:55*dadaa is now known as dadada
17:25:42dadadaan an early stage currently, looks like it could become useful for porting Nim to WASM and the like in the future
17:32:35lqdev[m]how does `continue` behave in a for loop? does it jump forward to the end of the `for` loop's block, or what?
17:36:21FromDiscord<mratsim> it starts the next loop iteration immediately
17:36:39FromDiscord<mratsim> @dadada, Nim already compiles to WASM, there is no need to port
17:37:54lqdev[m]@mratsim I know, but I want the details of how it's implemented. after all, an iterator's heart doesn't necessarily have to be a `while` loop
17:38:53lqdev[m]but yeah according to my tests it just jumps past the body https://play.nim-lang.org/#ix=27UU
17:38:59FromDiscord<Clyybber> lqdev[m]: Its like a block with a break
17:39:11FromDiscord<Clyybber> It wraps the whole loop body in a block
17:39:21FromDiscord<Clyybber> and the continue is a break
17:39:27FromDiscord<Clyybber> out of that body
17:39:44dadadamratsim: aha! didn't know that, thanks. Still I'd like to share this interesting read: https://developers.redhat.com/blog/2020/01/20/mir-a-lightweight-jit-compiler-project/
17:40:11FromDiscord<Clyybber> lqdev[m]: See: https://nim-lang.github.io/Nim/manual#statements-and-expressions-continue-statement
17:41:38lqdev[m]yeah, I already figured it out but thanks
17:43:05*icebattle quit (Quit: leaving)
17:44:13*icebattle joined #nim
17:47:56*icebattle quit (Client Quit)
17:49:00*icebattle joined #nim
17:57:17*icebattle quit (Quit: leaving)
17:59:07*icebattle joined #nim
18:15:35disruptekstill think nim is the wrong place to fix fd leaks.
18:36:28disruptekwho has a working pragma macro for me.
18:36:43disruptekWHO
18:36:58rayman22201async? lol
18:40:24*EvergreenTree quit (Quit: Ping timeout (120 seconds))
18:40:52*EvergreenTree joined #nim
18:41:20*nsf quit (Quit: WeeChat 2.7)
18:41:51disruptekgotta be /working/
18:42:18rayman22201async works, just not with arc
18:42:38Araqwhy not?
18:42:47Araqdidn't we fix it yesterday?
18:43:00rayman22201nope. I posted after you went to sleep
18:43:06disruptekthe closure is corrupted.
18:43:23Araqah
18:43:30Araqmakes sense
18:43:33disruptekyeah.
18:43:37AraqI wondered about this too yesterday :P
18:43:51Araqdadada, from the article "The actual performance improvement is only 16%, ..."
18:44:14Araq16% is quite good, I'll take it from a mere recompile with a newer compiler
18:44:31rayman22201https://irclogs.nim-lang.org/19-01-2020.html#23:47:50
18:44:40Araqwe can use these 16% to check for integer overflows etc
18:45:46rayman22201may need to fix that "var name = proc() {.closure.}" codegen / destructor issue to fix the async issue
18:46:12shashlickwhat's the difference between await and waitFor
18:46:21disruptekawait is async.
18:46:44rayman22201await = one async wait for another async. waitFor = sync wait for an async (blocks)
18:46:45disrupteki still think the future has to own everything.
18:47:05rayman22201me too. But in order for the future to own a closure, the codegen better do the right thing.
18:47:24rayman22201"future.field = proc() {.closure.}" needs to work
18:47:56disrupteki think solving that is easier than a brittle rearch of the macro.
18:48:04disruptekor, i should say, more correct.
18:48:50rayman22201not mutually exclusive. both will be required
18:49:06rayman22201it can't be fixed purely at the language level
18:49:11disrupteki don't think async needs to be brittle.
18:49:19shashlickokay thanks
18:49:31rayman22201why would it be brittle?
18:50:00disruptekbecause there are cases where we play fast and loose with cursors that don't need to exist.
18:50:01*marmotini_ quit (Remote host closed the connection)
18:50:40disruptekanyway, that's my interpretation of some of the kitchen-sink solutions.
18:50:49rayman22201Here's the thing. async is a core macro. Most users will never write a future callback by hand. So fixing the macro will make it good enough for 95% of cases.
18:51:12rayman22201library authors and the std lib will need to be careful, but that is true already.
18:51:32Araqin addition to that
18:51:32disruptekthis isn't a story i fancy retelling.
18:51:49Araqapps can use the cycle collector but Nim's core should work well without
18:52:33disruptekthese aren't exclusive concepts, though.
18:52:41rayman22201does the cycle collector have a "debug" or "verbose" mode to give extra information about cycles it detects?
18:52:49disrupteksure.
18:53:02rayman22201I think that just needs docs and it will be fine
18:53:26Araqno the basic algorithm needs to be tweaked, currently it's stupid
18:53:47Araqbut I want async to be free of cycles, it cannot be that hard
18:53:57disruptekthat part doesn't matter; it can be as stupid as it wants in cycle-mode.
18:54:12rayman22201It is free of cycles. You did fix it araq. We just need to fix the lifetimes now
18:54:28Araqno, I got factors of 1000
18:54:30disrupteki think if you want to play dirty, you do that in a special cycle-free mode.
18:54:32Araqtoo slow for debug runs too
18:54:45disruptekie. let orc break the cycles safely.
18:55:06Araqrayman22201, that means we didn't break the cycles properly :P
18:55:22rayman22201It's progress. baby steps :-P
18:56:22Araqplease give me a gist with asyncSleep that shows the crash
18:56:38rayman22201see my irc log
18:56:41rayman22201I posted it
18:57:00rayman22201here is the patch: https://github.com/rayman22201/Nim/commit/39c1131a7d8f6d5b46d4aec78206f01a90b868f8
18:57:10rayman22201here is the test: http://ix.io/27RJ
18:57:48rayman22201I think the next step is to finally use "disposableFuture", which has fields to hold ownership of the closures.
18:58:09disruptekgood.
18:58:13FromDiscord<Clyybber> So is there a compiler bug here or not?
18:58:23disruptekno yet imo.
18:58:52FromDiscord<Clyybber> and rayman thinks there is?
18:59:11disrupteki don't think anything thinks the impl is complete.
18:59:16disrupteks/anything/anyone/
18:59:22rayman22201there is. We are just doing too many things at once
18:59:37disruptekwhat do you think the bug is?
18:59:52disrupteki haven't seen anything not working correctly.
19:00:21rayman22201the bug is this: "proc myClosure {.closure.} = " correctly frees the closure, while "var myClosure = proc() {.closure.}" does not
19:00:55Araq of nkAsgn, nkFastAsgn:
19:00:55Araq if hasDestructor(n[0].typ) and n[1].kind notin {nkProcDef, nkDo, nkLambda}
19:01:10Araqis the suspicious logic in injectdestructors.nim
19:01:37disrupteki don't think you are managing the closure correctly; last patch i looked at the closure was a cursor.
19:01:50FromDiscord<Clyybber> Araq: Anything obvious wrong here?
19:01:55Araqsure
19:02:20FromDiscord<Clyybber> I can't see it..
19:02:20Araqit means we treat 'var x = proc ()' as a cursor
19:02:34FromDiscord<Clyybber> oh
19:03:04AraqI hacked this together to get some other test green :P
19:03:26Araqhopefully it's not required anymore
19:03:39Araqthis code got quite some bugfixes afterwards
19:03:46FromDiscord<Clyybber> hehe
19:06:04disruptekturn off nameitervar as a closure and you get no leaks.
19:06:09disrupteksorry, cursor.
19:06:25disruptektasyncawait.
19:06:31rayman22201We already got no leaks. It just had bad reads
19:06:42disruptekyes, no bad reads.
19:07:24rayman22201then you get leaks? This is what we established
19:07:35disruptekno leaks and no bad reads under --gc:arc.
19:08:20shashlickanother async question - can you await within a top level waitFor
19:08:44rayman22201You can only await inside an async proc
19:08:46disruptekyou can await in any .async.
19:08:59Araqguys, a gist please
19:09:13disruptektests/async/tasyncawait.nim
19:09:25shashlickso when you call a proc which is async from isMainModule, how do you do it
19:09:34disruptekwith waitfor.
19:09:36rayman22201waitFor
19:09:52shashlickokay so that was my question - the async stuff within the waitFor will still work as expected
19:09:54disruptekor, just `future = someproc`
19:10:15disruptekit'll work, but waitfor is sync.
19:10:36disruptekif you want it to run async, don't waitfor. just put the future somewhere where you can recover it later.
19:10:46rayman22201what modification did you do to the patch disruptek? I can't repro
19:11:25rayman22201you have to kick off the asyncEvent loop somewhere disruptek. And make sure the program lives long enough to complete the promise.
19:11:57disruptekyeah, that's his problem.
19:12:02disruptekhe can drain/poll/whatever.
19:12:10disruptekvar nameIterVar = iteratorNameSym
19:12:38disruptekif it's a cursor, the iterator won't live long enough.
19:12:47rayman22201but if it's not a cursor, it leaks
19:12:57rayman22201I literally just ran valgrind with no cursor and it leaks
19:13:11disruptekyou're using malloc, right?
19:13:12shashlickwhat if the async proc doesn't return anything
19:13:14rayman22201yup
19:13:22disruptekokay, it will leak in malloc.
19:13:35rayman22201that's all that matters. nim alloc is sloppy
19:13:39disruptekshashlick: async procs all return futures.
19:13:40*dadada quit (Ping timeout: 265 seconds)
19:13:47rayman22201it will return Future[void]
19:13:54disrupteki'm saying we can fix that because we can diff it.
19:14:08disruptekbut the logic is fine.
19:14:22rayman22201I disagree. There is a bug nim alloc
19:14:33rayman22201you can fix that, but that doesn't make the leak go away
19:14:33disruptekokay, what is it?
19:14:45rayman22201idk, why don't you diff it and find out?
19:14:46disruptekit's a bug that happens to let async work leak-free.
19:14:52disruptekwith no corruption.
19:14:53AraqI have no updated macro so tasyncawait doesn't work for me
19:15:06shashlickso you can let x = asyncProc() and then runForever()?
19:15:07rayman22201araq, use my patch to see
19:16:42rayman22201shashlick, yes, but why even assign to x at that point? runForever() never returns.
19:17:19Zevvok, I need advice again
19:17:31shashlickok as long as async does what i expect
19:17:49shashlickright now even my single threaded version doesn't work so i'm debugging that - it fails the same way as the async version
19:17:53shashlickmulti-threaded works though
19:17:57Zevvsince the malloc counters now count all allocs/frees, it is hard to capture the right part to measure, and I get varying results over platforms. My counts at a ginven time do not match the counts on CI
19:18:11Zevvso I need to report them *after* nim is done
19:18:28Zevvso I need to put that in the codegen, and that is nasty stuff
19:18:52disruptekwhy can't you do this in the context manager?
19:19:25Zevvok, what is the context manager
19:19:38disruptekinsideThisBlockIwillCountAllocs:
19:20:13rayman22201disruptek, I don't understand. You seemed to agree with my "disposableAsync" design a bit ago, but now you disagree? based on what seems to me like buggy behavior (or at least unexplained differences in behavior) between alloc impls?
19:20:16Zevvnope, that does not add up. Some stuff gets destroyed after the block
19:20:44disruptekno, i still think that the future should get a rc'd ref to the iterator.
19:20:47rayman22201looking at the macro code from first principles, without the cursor, it cannot work correctly...
19:21:04rayman22201some magic in the allocator won't fix that. At best it hides it.
19:21:12disruptekwell, my branch passes all the tests except for the traceback (in non-arc).
19:21:23disruptekand it passes --gc:arc for tasyncawait
19:21:50disruptekZevv: use more than one block. lifting, remember.
19:21:54rayman22201the future must own the closure, not the other way around
19:22:00disruptekyes. agree.
19:22:13rayman22201then the closure cannot have an rc'ed ref
19:22:24disruptek"no, i still think that the future should get a rc'd ref to the iterator."
19:22:35rayman22201the iterator is also a closure!
19:22:39disrupteki know.
19:22:50rayman22201the rc implies ownership
19:22:51disruptekthe future should own it. how else can i say this?
19:22:53disruptekyes.
19:22:54disruptekyes.
19:22:54disruptekyes.
19:23:00disruptekholy smokes dude.
19:23:12rayman22201then the iterator MUST NOT have an rc ref to the future
19:23:18disruptekcorrect.
19:23:33shashlickpushed my async update to px2 - same code can run in single threaded, multi-threaded or async modes
19:23:45disruptekwhat is px2?
19:23:45rayman22201rewind. I think I read what you are saying backwards.
19:23:48shashlickof course only multi-threaded works for connect tunneling
19:23:55disruptekrayman22201: agree.
19:24:12shashlicknext gen https://github.com/genotrance/px written in Nim, leveraging libcurl
19:24:36disrupteki wonder if we can fix async exceptions in arc.
19:24:40shashlickwith libcurl now, it will be able to go through any upstream proxy that libcurl supports, which is pretty much everything
19:24:57shashlickany of you stuck behind an NTLM or Kerberos proxy at work will relate
19:25:12shashlickNTLMAps / cntlm replacements
19:25:26*disruptek 🤷
19:25:56shashlicknot you, you independent contractor you
19:26:21shashlickhttps://github.com/genotrance/px2 by the way
19:27:00disruptekZevv: did that help?
19:28:26rayman22201disruptek, I still leak even with nim alloc https://www.irccloud.com/pastebin/zzKodoMt/
19:28:52rayman22201taking out the cursor
19:28:54AraqI really would like to help you
19:28:56Zevvdisruptek: sorry, did what?
19:29:18disruptekZevv: add more scope so when stuff gets lifted it doesn't leave your context.
19:29:21Araqbut I can't, because you're sitting on an unpublished branch or something
19:29:27disruptekAraq: try my async72 branch.
19:29:36Zevvdisruptek: you're pulling my finger, right?
19:29:36rayman22201https://github.com/rayman22201/Nim/commit/39c1131a7d8f6d5b46d4aec78206f01a90b868f8
19:29:50rayman22201I posted it 3 times araq
19:30:11*Trustable quit (Remote host closed the connection)
19:30:46Araqindeed but this is not how I want to work
19:31:00Araqyesterday you had some nice example that was easy to tweak
19:31:01rayman22201what do you need?
19:31:18rayman22201oh, I see. You want the expanded macro
19:31:18AraqI won't touch the macro until I'm sure what it needs to produce
19:31:29disruptekoi
19:31:31rayman22201I can produce this for you. stand by
19:32:12Araqand yeah, it's time to end this hacking around
19:32:43disruptekyou told me to get tasyncawait.nim working without leaks.
19:32:48*jjido joined #nim
19:32:50*abm quit (Ping timeout: 240 seconds)
19:32:51*lritter joined #nim
19:32:53Araqdisruptek, yes I did
19:33:01Araqand also without crashes :-)
19:33:06disruptekhttp://ix.io/27Vk
19:33:18disruptekit's hard to make it work any better than this.
19:33:27ZevvAll heap blocks were freed -- no leaks are possible \o/
19:33:33Araqquite convincing.
19:33:41Araqwhat's the magic behind it?
19:33:50Araqthe macro fix rayman22201 sent me?
19:34:21rayman22201and yet my simple example leaks?
19:34:33disrupteki'm not 100% sure, but we can diff my branch against ray's.
19:34:43disrupteki think it's just the nameIterVar not being a closure.
19:35:03disrupteki would rather narrow the debugging to the malloc/nimalloc diff.
19:35:30Araqdisruptek, did you use -d:useMalloc with valgrind?
19:35:40disruptekno, useMalloc leaks.
19:35:48Araqgah...
19:36:01disruptekyes.
19:36:02Araqthen your result is meaningless
19:36:14Araqvalgrind only works with -d:useMalloc reliably
19:36:27disruptekbut the point is that the lifetime is correct.
19:36:29Araqelse valgrind doesn't understand Nim's allocator and reports "no leak possible"
19:36:51disruptekwe aren't getting corruption because we are not prematurely freeing the closure.
19:37:02Araqyes and no.
19:37:21Araqif you never free memory you will hardly see any corruptions
19:37:34Araqcorruptions are "use after free" bugs, most of the time
19:37:56Araqso if you leak and get no crashes, we don't know if the lifetimes are correct
19:38:03Araqmost likely they really are not
19:38:04disruptektrue. we do free, but maybe we don't free enough.
19:38:08Araqyup
19:38:15rayman22201https://play.nim-lang.org/#ix=27Vm
19:38:43rayman22201exactly what araq says.
19:38:53rayman22201disruptek, you are relying on faulty behavior and getting lucky
19:38:55rayman22201it's not a real fix
19:39:18disruptekmaybe, but it won't work at all if we save a cursor to the iterator in the future.
19:39:20rayman22201the lifetime is still bad, it's just that the way mimalloc works, the memory happens to still be there.
19:39:50disruptekyour disposableFuture needs a hard closure ref.
19:39:57rayman22201oh I see what you mean now! I agree! exactly
19:40:08disruptekfinally 😁
19:40:09rayman22201we are on the same page
19:40:25Zevvbunch of amateurs!
19:40:32rayman22201your mimalloc stuff confused me "_P
19:40:48rayman22201:P
19:41:38rayman22201araq is that good enough or do you want me to minimize the example more?
19:41:39*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:43:14Araqso, this version of yours doesn't crash but leaks memory. correct?
19:44:04rayman22201This one has bad reads
19:44:08rayman22201according to valgrind
19:44:14rayman22201it doesn't actually crash though
19:44:39Araqwell on my machine it leaks and I don't run it via valgrind
19:44:52Araqbecause I'm on this loser OS
19:45:33rayman22201http://ix.io/27Vn
19:45:47Araqwell
19:45:56Araqvar nameIterVar_gensym400019 {.cursor.} = asyncProcIter_400016 # no owner? can't be right
19:46:11disruptekexactly.
19:46:14rayman22201agree
19:46:34rayman22201what's confusing is that it seems to be producing different behavior for different people
19:47:17AraqI "fixed it" via
19:47:17Araq var ownIter = asyncProcIter_400016
19:47:18Araq var nameIterVar_gensym400019 {.cursor.} = ownIter
19:47:22Araqbut that's silly
19:47:43Araqthe closure must own the iterator
19:47:59rayman22201why isn't the iterator def it's own owner?
19:48:16rayman22201just like "proc myClosure() {.closure.}" makes the current proc the owner.
19:48:46rayman22201doesn't "iterator asyncIter() {.closure.}" make the current proc the owner?
19:48:51Araqthe example is bad because if I read it correctly
19:49:06Araqthe callback is never attached to the Future we return
19:49:29Araqso we're looking at the wrong thing
19:49:40Araqsome random closure that doesn't escape and must not leak
19:49:57Araqbut in the real async it always escapes, it's put inside the future
19:50:12Araqplease scream now if I'm wrong.
19:50:18rayman22201I don't understand
19:51:38rayman22201are you saying the "callback=" is never executed in this example?
19:51:52rayman22201that was the whole point of me putting the sleepAsync in there
19:52:18Araqapparently I have no clue
19:52:32rayman22201yeah. I just verified. the callback is added
19:52:36*Araq re-reads everything
19:53:42Araqgah this is a mindfuck
19:53:44rayman22201I see two ways to set it up. Have the Future own the closure cb, and the closure cb own the iterator. Or just have the Future own both the closure cb and the iterator directly.
19:53:53rayman22201I prefer the second option
19:54:30Araqbut currently the future doesn't own anything, does it
19:54:39rayman22201no.
19:54:50rayman22201I think I just need to try to implement this crap I keep talking about
19:55:02Araqok, so that's what I mean I guess
19:55:16Araqthe freaking future doesn't own anything so this has no chance of working
19:55:26rayman22201I wanted to make sure there isn't anything I'm missing first
19:55:35rayman22201i.e. I put all the cursors in the right places
19:56:04Araqbtw I prefer the option "Have the Future own the closure cb, and the closure cb own the iterator."
19:56:20Araqbecause an ownership hierarchy can't be bad
19:56:33rayman22201shallow vs wide tree :-P
19:56:42rayman22201vs. deep tree I mean
19:57:36rayman22201actually, your way saves a field on the Future, so I will try that first
19:57:44*ptdel quit (Read error: Connection reset by peer)
19:59:44Araqtbh I wouldn't mind some larger rewrites, this setup is super convoluted
20:00:02Araqand way more complex than it needs to be
20:01:14Araqbut I complained about it when dom wrote it and he had some good argument like "your solution doesn't work at all"
20:02:13*kungtotte quit (Read error: Connection reset by peer)
20:02:58rayman22201I don't love it, but I'm afraid to make large changes to something that works
20:03:16rayman22201close to working anyway lol
20:03:32*ptdel joined #nim
20:03:32*kungtotte joined #nim
20:03:38rayman22201ok, so giving ownership of the closure to the Future still leaks. idk why
20:03:41Araqproblem that I have with it: once it "works" it's still slow
20:03:59Araqso many allocations and closures
20:04:14rayman22201fair point. I would love to do something based on synthesis. Async really just needs to be a polling state machine.
20:04:41disrupteki really don't think it's that complex. you are both right. just put in the ref on the future and let's take the next step.
20:04:51rayman22201I just did it, and it's not working
20:04:59disrupteklemme see
20:05:03rayman22201I have to push my patch. working on it
20:05:07rayman22201stand by
20:05:11disruptekkk
20:05:29dom96Polling futures are likely the future, but we're stuck with what we have for the duration of 1.0
20:05:51Araqwant to hear my wisdom after decades of debugging complex systems?
20:05:56disruptekhaving a hierarchy sounds better to me.
20:06:47disrupteki feel like with 5 people working on this, we spend every day taking two steps forward and one step back.
20:06:54Araqok, nobody wants to hear my wisdom, too bad.
20:07:04disruptekAraq: don't ask to ask, just ask.
20:07:41dom96Something fun I noticed is that async await in Nim is now 6 years old.
20:07:50rayman22201ok, just pushed it to my branch: https://github.com/rayman22201/Nim/tree/arcify-async
20:07:54disrupteka better set of tests would help this.
20:08:00Araqdom96, we can add more vaporware to --gc:arc, like a mutated version of async
20:08:07rayman22201agreed. I added a few tests for my other async work, but we need more
20:08:28Araqlike I did for 'repr' :P
20:09:08rayman22201oh, and the test. hold on
20:09:12dom96We need a testing framework for async, something which allows to test it without flakiness
20:09:29Araqdom96, but since you're here, do you remember what was wrong with my solution?
20:09:51dom96which solution?
20:09:51rayman22201https://play.nim-lang.org/#ix=27Vx
20:09:56dom96your leak fix?
20:10:04Araqdom96, no my async design
20:10:17dom96which one are you referring to?
20:10:20Araqbefore you wrote yours we discussed things
20:10:40disruptekray, that doesn't work? i'm asking.
20:10:46rayman22201It didn't work for me
20:10:55dom96Araq, I don't recall what your design looked like
20:10:56rayman22201still leaks according to valgrind
20:11:06disruptekjust in malloc, right?
20:11:20rayman22201I didn't check mimalloc.
20:11:46dom96bbs
20:11:47rayman22201mimalloc shows a leak still
20:11:56rayman22201extra Mem: 63208
20:12:12disrupteklemme diff my branch against yours.
20:12:41rayman22201kk
20:12:57*Vladar quit (Quit: Leaving)
20:15:15rayman22201I have to take off again. I'll be on mobile, but I won't be able to test stuff.
20:15:21rayman22201bbl
20:16:36disruptekoh this has all your dispose in it.
20:16:45shashlickhow do you yield execution in async
20:16:59disruptekcall another async proc.
20:19:42shashlickdisruptek: i'm in this loop - https://github.com/genotrance/px2/blob/master/curl.nim#L194
20:19:53shashlickhow do i release control so that another server connection can be handled
20:20:30disruptekasyncSleep(0)?
20:20:31shashlickalso don't we have a stdout.flush() proc?
20:20:49disrupteki think there's something a little more special for this, but i cannot remember what i use.
20:20:53rayman22201wait
20:20:56rayman22201await
20:21:03rayman22201shashlick, await yields execution
20:21:18disruptekjust plain `await`?
20:21:26rayman22201await some async proc
20:21:28shashlicki await asyncSleep(10) and it doesn't
20:21:35Araqdom96, basically we only deal with 'iterator (): FutureBase' in the dispatcher
20:21:38disrupteki know, but there's an idiom.
20:22:19shashlickit doesn't let another connection come in
20:22:21shashlickeven if i do that
20:22:43shashlickconnections come in here - https://github.com/genotrance/px2/blob/master/server.nim#L117
20:22:44Araqthe dispatcher decides which iterator to resume based on which socket data is available
20:29:07*rockcavera quit (Read error: Connection reset by peer)
20:29:25*rockcavera joined #nim
20:29:25*rockcavera quit (Changing host)
20:29:25*rockcavera joined #nim
20:32:15*rockcavera is now known as Guest74317
20:32:15*tiorock joined #nim
20:32:15*Guest74317 quit (Killed (tolkien.freenode.net (Nickname regained by services)))
20:32:15*tiorock is now known as rockcavera
20:34:48*narimiran quit (Ping timeout: 260 seconds)
20:34:53FromGitter<zetashift> I tried compiling godot-nim with --gc:arc and quickly noticed I'm way out of my league here
20:40:46FromDiscord<DeltaPHC> I'm still not entirely sure of the relationship between newruntime, gc:arc, etc, other than they're intended to be stable for Nim 2.0. Or am I wrong?
20:41:14disrupteknewruntime was an experiment that yielded gc:arc, expected to take over the world.
20:41:36FromDiscord<DeltaPHC> So no more newruntime, now all the work is in gc:arc?
20:41:52disrupteknot really.
20:42:14disrupteki mean, yes, everyone is working on gc:arc but newruntime is not trash; most of it was instrumental in building arc.
20:42:45FromDiscord<DeltaPHC> Oh, I didn't mean in terms of quality. I just mean... what is intended to be used in the future
20:42:50*Hideki_ joined #nim
20:42:51disruptekgc:arc
20:43:00disrupteknewruntime (maybe, if it matures further)
20:43:05disruptekgc:refc
20:43:07disruptekgc:orc
20:43:12disruptekgc:boehm
20:43:15disruptekgc:markAndSweep
20:43:18disruptekgc:none
20:43:30disruptekare you picking up what i'm layin' down, here?
20:43:31FromDiscord<DeltaPHC> What's the *default* going to be? lol
20:43:36disruptekgc:arc
20:43:39FromDiscord<DeltaPHC> Alright
20:45:08FromDiscord<DeltaPHC> Are scoped-based destructors going to be part of gc:arc?
20:45:23disruptekthey are.
20:47:19*Hideki_ quit (Ping timeout: 268 seconds)
20:48:25dom96Araq, oh, you mean we get rid of `Future[T]` altogether?
20:49:17dom96shashlick, you should probably `asyncCheck` your `processClient` call
20:49:44dom96yeah... you're literally telling it to wait until processClient finishes before trying to accept other clients
20:55:35*jjido joined #nim
21:02:50*tane quit (Quit: Leaving)
21:04:33shashlickI see, I'll try that
21:04:40shashlickThanks for the review
21:05:15Zevvso disruptek, is the leak fixed now?
21:05:18rayman22201disruptek any ideas from the diff?
21:05:51rayman22201Zevv, no 😭
21:06:37disruptekis there a reason we aren't doing this callbacklist stuff with recursion?
21:06:43disruptekit's pretty verbose.
21:06:47rayman22201I wonder if it's some codegen bug with closure assignment
21:07:04rayman22201that's a question for araq and dom96
21:07:34disruptekima just rewrite it for my own edification.
21:07:35dom96if you're referring to what I think you're referring to then yes, there is a reason
21:07:37dom96check out the blame
21:07:42disrupteki did.
21:07:54disruptekit's "this is verbose but i dunno if i got it right"
21:08:02disruptekwell, i know.
21:08:22shashlickStill don't clearly get await vs waitFor vs asyncCheck
21:08:46disrupteki think we should have a template that disarms closureRef that we use whenever we "finish" the future.
21:09:15dom96shashlick, my book has some nice explanations for these
21:09:24rayman22201I tried to make the closure assignment a move like this: retFuture_400014.closureRef = move(asyncProcNimAsyncContinue_400018)
21:09:25rayman22201but I can't because "error: 'asyncProcNimAsyncContinue_400018' is immutable, not 'var'"
21:09:43rayman22201and I can't make it mutable because of the codegen bug
21:10:57rayman22201disruptek, that is basically what "dispose" did. (The original experimental branch)
21:11:08rayman22201it disarmed the closure
21:12:42rayman22201note: "finish" of the future is sufficient, b/c it is a valid operation read a finished future multiple times. So it must be "lastReadOf(future) -> disarm(closure)"
21:12:57rayman22201"finish" *is not* sufficient
21:14:10disruptekbut read just reads the value.
21:14:26disruptekam i missing something?
21:14:32rayman22201the value may reference the closure
21:15:39disruptekwhy is that a problem?
21:15:51disruptekthe future will hold a ref to it. fine.
21:16:18rayman22201then it's not safe to disarm
21:16:30disruptekwhy not?
21:16:42rayman22201because there is still a ref pointing to it
21:16:48disruptekso what?
21:16:50rayman22201unless I misunderstand what you mean by disarm?
21:16:58disruptekdisarm is `foo = nil`.
21:17:11Araqrayman22201, the codegen bug doesn't care about let vs var
21:17:25rayman22201right, but I can't generate either
21:17:58rayman22201technically I can only generate let
21:18:10rayman22201since that what "proc myClosure {.closure.}" amounts to
21:18:23rayman22201but that means I can't "move" it
21:19:27rayman22201disruptek: you might be right. disarm in the experimental branch actually called a free, there was no reference counting. with arc it might be safe to do it at the "finish"
21:19:48disruptekit's fine.
21:20:05rayman22201disarm used to be more dangerous :-P
21:20:20rayman22201I lost so many arms
21:21:57rayman22201araq, put another way, I want to do "future.closureRef = proc() {.closure.}"
21:22:19rayman22201but I can't do that right now, because "future.closureRef" gets treated like a cursor
21:27:36Araqfeel free to patch the compiler
21:28:15Araqdom96, I'm not sure, in my head the Future is mostly a IO "request" that we yield to the event loop
21:28:39Araqbut I remember this model being incompatible with IO completion ports
21:28:40FromDiscord<mfiano> Araq I made my first post on the forums in reply to a comment you posted earlier because I am extremely confused learning Nim (also looks like I'm moderated so only you can see it) 🙂
21:29:26disruptekima clean up this linked-list stuff because it lacks confidence.
21:29:51dom96Araq, yes, on POSIX we ask whether the socket can be read, then we read it. On Windows we read it and get a notification when the read completes.
21:29:53Araqmfiano: I have no moderated posts in my queue
21:30:14dom96i.e. IOCP fits how async procs work in Nim
21:31:00FromDiscord<mfiano> Odd. It says I am moderated in my comment in https://forum.nim-lang.org/t/5836
21:31:33Araqok, thanks
21:31:48AraqI made you a user and I'm awaiting your spam links
21:32:56rayman22201araq. I'm not familiar with that part of the compiler. where do I start?
21:33:39Araqinjectdestructors.nim line 606
21:33:49Araqbut I'm not sure anymore that it's wrong.
21:33:53FromDiscord<mfiano> Ha, most of my time is spent trying to understand what the compiler is thinking. The documentation says larger number types should never be converted to smaller types.
21:34:25FromDiscord<mfiano> I spent all weekend trying to understand these ~10 lines of code and other oddities...cross-referencing the docs and getting nowhere
21:34:28Araqyeah but floats are not numbers :P
21:34:52FromDiscord<mfiano> The docs uses floats as an example 🙂
21:35:02Araqreally? yay...
21:35:32Araqthe issue here is that float32 doesn't lose information, only precision
21:35:38FromDiscord<mfiano> > Automatic type conversion in expressions with different kinds of floating
21:35:38FromDiscord<mfiano> > point types is performed: the smaller type is converted to the larger. Integer
21:35:38FromDiscord<mfiano> > types are **not** converted to floating point types automatically, nor vice
21:35:38FromDiscord<mfiano> > versa. Use the `toInt <system.html#toInt,float>`_ and
21:35:39FromDiscord<mfiano> > `toFloat <system.html#toFloat,int>`_ procs for these conversions.
21:36:02Araqthat's true.
21:36:27Araqit's about floats and ints, not about combining float32 with float64
21:36:45FromDiscord<mfiano> What it doesn't say is that a larger floating point type can be automatically converted to a smaller, losing valuable precision.
21:37:06FromDiscord<mfiano> I consider this a serious flaw, unless I'm misunderstanding the code I posted in the forum. Just changing the order has type instability
21:37:22Araqlearn how to read
21:37:39AraqFor further details, see `Convertible relation
21:37:39Araq<#type-relations-convertible-relation>`_.
21:37:48Araqand then in there it clearly says
21:38:00Araq proc isImplicitlyConvertible(a, b: PType): bool =
21:38:02Araq ...
21:38:09Araq of float32: result = b in {float64}
21:38:09Araq of float64: result = b in {float32}
21:38:23Araqso the conversions happen both ways
21:38:34FromDiscord<mfiano> Ouch
21:38:40Araqnow we can discuss whether the design is broken or not
21:38:50Araqbut the documentation is good.
21:41:03FromDiscord<mfiano> I argue that any type instability resulting in loss of precision is bad. That's not normally how type contagion works in other languages, and any rounding by loss of precision is a form of data corruption. But I am not a compiler writer, so 🤷‍♂️
21:41:16*letto_ quit (Quit: Konversation terminated!)
21:42:02*letto joined #nim
21:42:41AraqI don't consider it a big issue tbh. float32 is used in the gaming domain where you look at the screen and say "close enough" and stick with 32bits for the speed advantages
21:43:35Araqin every other domain you use float64.
21:44:49Araqwhere are these domains where you need to watch out not to mix float32 and float64 so that your calculations are not off? why are there float32s to begin with?
21:45:50Araqand how can you detect it? if you convert it explicitly to float32 there is still no error detection going on
21:45:52FromDiscord<mfiano> There are a lot of physics computations that are best done with double-precision using a multiple of a machine epsilon to get numerical robustness...in the gaming domain.
21:47:36Araqhere is what I expect to happen: "type mismatch: expected float32, but got float64". Programmers adds a 'float32(x)' conversion and curses the Nim compiler.
21:48:01Araqno thinking involved and the code is as quirky as before
21:48:26Araqbut ok, at least it's visible in the code then
21:48:31Araqso I'll make the compiler emit a warning
21:49:04FromDiscord<DeltaPHC> Yeah, I think the argument is that it makes a difference whether the programmer *knows* when a loss of precision or information is happening
21:49:53Araqfair enough but the point remains: Now that you *know* it, it's still not detected/checked at runtime at all.
21:50:28Araqcompare that with int8(x) which crashes at runtime.
21:51:57FromDiscord<gingerBill> My domain?
21:52:28FromDiscord<gingerBill> I'm a physicist so mixing 32-bit floats and 64-bit floats is a not a great idea. 64-bit floats everywhere except for rendering to a GPU.
21:53:42*Kaivo joined #nim
21:54:27FromDiscord<DeltaPHC> This isn't always a good solution (nor useful on GPUs), but there's also the less-popular fixed point numbers, if you want more consistent and predictable behavior
21:54:42FromDiscord<gingerBill> Sometimes 32-bit floats are stored to reduce memory but 64-bit floats are used in calculations.
21:54:52FromDiscord<gingerBill> Things get weird depends on many legacy systems.
21:57:09FromDiscord<gingerBill> And in many systems you will be using fixed point arithmetic or fixed precision arithmetic.
21:57:18FromDiscord<mfiano> Yes, numerical robustness is enough trouble as it is with floating point math. I am only arguing that the user should be aware of when there is automatic loss of precision, to save them some amount of trouble. Not if it should be an error, per se.
21:57:37Araqas I said, we'll fix it
21:58:56*ltriant joined #nim
21:59:21FromDiscord<DeltaPHC> At least it's not C/C++ where implicit int/float conversion happens. That's even more painful sometimes :P
22:00:48FromDiscord<gingerBill> That is just a nightmare.
22:03:06donpdonpwhy does echo now() show a timestamps and echo &"{now()}" shows nothing?
22:03:17FromDiscord<AGNiMA> please add a GitHub OAUTH token to your $NIMPH_TOKEN
22:04:26FromDiscord<AGNiMA> I've edit my .bash_profile with export NIMPH_TOKEN=<token> I also tried export $NIMPH_TOKEN=<token>
22:04:45Araqdonpdonp, I don't know
22:05:21donpdonp"{now().`$`}" is a workaround.
22:06:35Araqand so is &"{$now()}"
22:07:18donpdonpo^O
22:08:13dom96!eval import strformat; echo(fmt("{now()}"))
22:08:15NimBotCompile failed: /playground/nim/lib/core/macros.nim(557, 1) Error: undeclared identifier: 'now'
22:08:23dom96!eval import strformat, times; echo(fmt("{now()}"))
22:08:28NimBot<no output>
22:08:48dom96!eval import strformat, times; echo(fmt("{Testing: now()}"))
22:08:51NimBotCompile failed: /playground/nim/lib/core/macros.nim(557, 1) Error: undeclared identifier: 'Testing'
22:08:58dom96!eval import strformat, times; echo(fmt("Testing: {now()}"))
22:09:03NimBotTesting:
22:09:11dom96how weird
22:09:22Araqquite a bug
22:09:58*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
22:12:35*Hideki_ joined #nim
22:12:59*sagax quit (Ping timeout: 265 seconds)
22:17:27lqdev[m]Araq: I'm trying out ARC and I'm getting a hint: `passing 'chunk.file' to a sink parameter introduces an implicit copy; use 'move(chunk.file)' to prevent it` however in my case, I can't really move the thing nor copy it, I heard there's a `lent` but annotating my field with it doesn't seem to work, saying that `lent` cannot be used in this context. could you enlighten me on how `sink` and `lent` work?
22:19:33Araqwhy can't you move it? :P
22:19:53Araqbut jokes aside, this warning needs to be tweaked
22:20:02*Hideki_ quit (Ping timeout: 240 seconds)
22:20:06Araqor maybe removed altogether
22:20:23FromDiscord<AGNiMA> anyone seen this from choosenim ? repository error: could not find repository from '/Users/xxxx/.choosenim/toolchains/nim-#devel/.git'
22:23:36Araqah it's a "simple" times.nim bug
22:23:48disruptekagnima: export NIMPH_TOKEN=token should work. make sure you source .bash_profile to test it in your current session.
22:24:05lqdev[m]Araq: I can't move it because it actually needs to be copied, or better yet referenced from multiple tuples
22:24:27lqdev[m]I'd really like to not copy it in this case
22:24:39*rockcavera quit (Remote host closed the connection)
22:24:52lqdev[m]because there can be hundreds of those tuples at once
22:25:08lqdev[m]and they're not mutated
22:25:16Araqtuples are always copied
22:25:22Araqthey are value types
22:33:24FromDiscord<AGNiMA> thanks @disruptek
22:43:21*seni joined #nim
22:45:23*solitudesf quit (Ping timeout: 272 seconds)
23:23:01disruptekso i'm catching up on bugs. async/arc... are we waiting for #12990 or what?
23:23:03disbothttps://github.com/nim-lang/Nim/issues/12990 -- 3arc: C compilation error with imported global code using a closure iterator ; snippet at 12https://play.nim-lang.org/#ix=27Wm
23:23:28*NimBot joined #nim
23:47:53*icebattle quit (Ping timeout: 260 seconds)
23:54:39*leorize joined #nim
23:54:57*sekao joined #nim