<< 14-12-2023 >>

00:07:51FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=html>
00:08:10FromDiscord<graveflo> (edit)
00:09:03FromDiscord<graveflo> actually dont need to test `r`
00:09:26FromDiscord<graveflo> (edit)
00:10:46FromDiscord<Elegantbeef> Something about stack overflow here 😄
00:11:10FromDiscord<Phil> Yeah, write a stackoverflow question about this problem and self-answer!
00:11:14FromDiscord<Phil> 😛
00:11:15FromDiscord<Elegantbeef> No
00:11:19FromDiscord<Elegantbeef> I hate you
00:11:22FromDiscord<graveflo> thats a really gnarly json object your thinking of
00:11:33FromDiscord<Elegantbeef> Hey they said the depth is unknown
00:11:38FromDiscord<Phil> Beef is in your name after all, there never was a chance 😄
00:12:27FromDiscord<Phil> In reply to @graveflo "thats a really gnarly": 5000 layers of depth! The most normal of JSON files !
00:13:13*casaca quit (Remote host closed the connection)
00:18:51FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=html>
00:19:59FromDiscord<Phil> The way to find shit on HTML is always to figure out how the languages equivalent to document.querySelector and then writing the appropriate CSS selector
00:20:29FromDiscord<Phil> Wait, how familiar are you with CSS selectors?
00:21:12FromDiscord<graveflo> wicked are you talking about storing it in an object?
00:21:18FromDiscord<wick3dr0se> I'm not very familiar. I haven't had to write a website in like 3 years at least
00:21:26FromDiscord<wick3dr0se> An object would be just fine
00:21:33FromDiscord<graveflo> or do you know know how to parse the html
00:21:54FromDiscord<Phil> Okay so you know what ids and css classes are right?
00:22:08FromDiscord<wick3dr0se> But I just want to pull the data apart ultimately. I tried with innerText() but when i split on whitespace and such I can't store it correctly
00:22:29FromDiscord<wick3dr0se> In reply to @isofruit "Okay so you know": Yes
00:22:42FromDiscord<Elegantbeef> since you have all the TRs you can just do `let (name, class, level) = (b[0].innerText, b[1].innertext, b[2].innertext)` 😄
00:23:29FromDiscord<wick3dr0se> Ahhh that might work.. I was doing innerText first then similarly assigning but how it broke apart was an issue
00:24:00FromDiscord<Phil> `#myId` matches all HTML tags with the id `myId`↵`.myClass` matches all HTML tags with the css-class `myClass`↵`myTag` matchtes all HTML tags `<myTag></myTag>`↵... or whatever beef suggests, I was going to go query all the desired tags using a CSS selector and then defining a proc to unpack the values from one specific tag
00:24:12FromDiscord<Phil> (edit) "`#myId` matches all HTML tags with the id `myId`↵`.myClass` matches all HTML tags with the css-class `myClass`↵`myTag` matchtes all HTML tags `<myTag></myTag>`↵... or whatever beef suggests, I was going to go query all the desired tags using a CSS selector and then defining a proc to unpack the values from one specific tag ... " added "and using that to loop over the list of selected tags"
00:24:20FromDiscord<Elegantbeef> Nim's stdlib does not have selectors afaik
00:24:30FromDiscord<Elegantbeef> So they'd need another library todo such, they do exist
00:24:43FromDiscord<graveflo> yea the std lib parser should be capable of doing the parsing. You just need to use the api the right way.
00:24:44FromDiscord<Elegantbeef> Plus why use selectors if the layout is static, can just grab indices
00:25:03FromDiscord<Elegantbeef> Selectors are the regex of html
00:25:26FromDiscord<Phil> That is very unfair to selectors which are infinitely more readable
00:25:43FromDiscord<Phil> Deny me and I'll make sure one of my next projects will be some regex-based searcher over DNA sequences or sth
00:25:53FromDiscord<Phil> (edit) "me" => "this"
00:26:10FromDiscord<Elegantbeef> It's not really unfair, they're pattern matching based off hierarchy and attributes
00:26:41FromDiscord<Phil> Yes but one is completely unreadable because you need to know 20+ rules and shorthands for things
00:26:52FromDiscord<Elegantbeef> The same can be said about css selectors
00:27:02FromDiscord<Elegantbeef> The selector spec is quite large
00:27:14FromDiscord<Elegantbeef> https://www.w3schools.com/cssref/css_selectors.php
00:27:18FromDiscord<Elegantbeef> Look at all these selectors!
00:27:23FromDiscord<Elegantbeef> Thats 20+ rules
00:27:24FromDiscord<graveflo> regex is gross
00:27:30FromDiscord<Elegantbeef> I concur
00:27:43FromDiscord<Elegantbeef> Selectors are ok, and should only be used in the same ways as regex 😄
00:27:44FromDiscord<wick3dr0se> In reply to @Elegantbeef "since you have all": Still includes the spaces in the indices but this works
00:28:01FromDiscord<Elegantbeef> Well you want to parse it of course
00:28:01FromDiscord<Phil> sent a long message, see <!doctype html>
00:28:07FromDiscord<wick3dr0se> Well doesnt make sense really index 0 is empty but index 1 contains the name
00:28:08FromDiscord<graveflo> just `strip`
00:28:08FromDiscord<Phil> (edit)
00:28:17FromDiscord<Phil> 6 rules overall
00:28:25FromDiscord<Phil> (edit) "6 rules overall ... " added "that are needed"
00:28:28FromDiscord<Elegantbeef> Well Phil I just showed a bunch of selectors
00:28:32FromDiscord<Elegantbeef> So... that's more than 5
00:29:19FromDiscord<Phil> I'm not talking about the 5 billion ways to do edge cases, I'm talking what's sufficient for 99.9% of cases.↵Which I can't claim for regex because regex almost always drifts into weird shit and greedy vs non-greedy etc.
00:29:40FromDiscord<Elegantbeef> Sure I'm not disputing you can read css
00:29:42FromDiscord<graveflo> k well the real distinction is that regex is a state machine
00:29:42FromDiscord<Elegantbeef> I'm saying it's often overkill
00:29:53FromDiscord<graveflo> these dont even look that comparable tbh 😛
00:30:11FromDiscord<wick3dr0se> I see how both can be very useful 😄
00:30:28FromDiscord<Elegantbeef> Regex is useful if you want to make your code unreadable 😄
00:30:50FromDiscord<Phil> 🤷‍♂️ Personally I find the 6 rules listed above easy enough and useful enough given that you can cudgel basically any possible HTML problem with it.↵It's a one-size fits all solution that maybe has a smidgeon of overhead for really simple usecases but imo that's worth it for the universality of it
00:30:52FromDiscord<graveflo> I switch font to wing dings bc it's easier to read regex
00:30:54FromDiscord<Elegantbeef> Hyperbole aside, we solved the xml problem we can stop taking about css selector
00:31:50FromDiscord<Elegantbeef> Phil I'm just annoyed at my hamburger menu that's implemented using css 😄
00:33:20FromDiscord<Elegantbeef> It uses funky selectors that are very unclear to the uninitiated
00:34:08FromDiscord<Elegantbeef> `#menu-button:checked + label:before` Present me has 0 clue what that actually selects 😄
00:34:45FromDiscord<Phil> ... if people use :before and :after they are lost
00:34:47FromDiscord<Phil> And need help
00:34:49FromDiscord<graveflo> this is why you have a front end / UX friend
00:35:13FromDiscord<Phil> :checked on a menu button is also an...interesting choice
00:35:48FromDiscord<graveflo> not a bad idea though. It's annoying when context menus dont want to stay open
00:36:08FromDiscord<Phil> Sure, but I'd much rather represent an "open" state with its own CSS class
00:36:17FromDiscord<Phil> Sure that requires JS to toggle said CSS class on and off the element
00:36:20FromDiscord<Phil> But that's worth it imo
00:37:11FromDiscord<graveflo> I'm so glad that other people care about this stuff bc I actually cannot tolerate touching CSS
00:38:10FromDiscord<Phil> Eh, I'm at the point where I can see an entire design and code it down in a matter of a couple hours, including all the intended behaviour and unit tests covering them
00:38:17FromDiscord<Phil> (edit) "Eh, I'm at the point where I can see an entire design ... and" added "of a page"
00:38:33FromDiscord<Phil> CSS isn't that much of a big bad
00:39:19FromDiscord<graveflo> yea it's fine. I just don't like messing with it. There nothing fun about it for me, but dont let my bad attitude spoil your fun!
00:39:26FromDiscord<Phil> note: mobile optimized page, so that page ain't going to have a crapton of things with behaviour on it beyond 2-3 dozen or so
00:40:06FromDiscord<Elegantbeef> I mean I do not want js on my site just for a hamburger menu
00:40:07FromDiscord<Elegantbeef> I'm also not a webdev and just try to make something that 'works'
00:41:02FromDiscord<Phil> I mean you got to have complexity somewhere
00:41:09FromDiscord<Elegantbeef> It really is not
00:41:12FromDiscord<Phil> Either eat the JS or deal with complicated CSS, your choice 😛
00:41:12FromDiscord<Elegantbeef> It's a static site it does not need dynamism 😄
00:41:28FromDiscord<Phil> Well then just live without the dynamic burger-menu 😛
00:42:07FromDiscord<wick3dr0se> I actually have a pretty tiny example for a hamburger menu without JS https://github.com/wick3dr0se/learn-astro
00:42:22FromDiscord<wick3dr0se> Only site I wrote anytime recently but obviously it's empty and garbage loll
00:43:28FromDiscord<wick3dr0se> I like to avoid JS at all cost lol
01:20:59FromDiscord<double_spiral> In reply to @isofruit "Just for reference: new": gotcha 👍
01:21:40FromDiscord<double_spiral> In reply to @wick3dr0se "I like to avoid": js is absolutely the worst language i have ever coded in
01:21:52FromDiscord<double_spiral> its very illogical to me
01:32:01*rockcavera quit (Remote host closed the connection)
01:33:35FromDiscord<rubythulhu> nimble keeps complaining about both my own projects and dependencies about improper directory structure. where can i find documentation on the proper way other than nimble just telling me "ur doin it wrong"
02:08:25FromDiscord<nasuray> In reply to @rubythulhu "nimble keeps complaining about": Is this a hybrid package? Nimble v0.14.2 doesn't spit out these warnings anymore since it changed its output to append a `.out` when compiled. The suggestion should exist in past READMEs for nimble though
02:09:27FromDiscord<graveflo> In reply to @rubythulhu "nimble keeps complaining about": `nimble init`
02:10:13FromDiscord<graveflo> also this: https://github.com/nim-lang/nimble
02:11:10FromDiscord<graveflo> and you might want to read this: https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files↵and you should make sure you know where important dirs are like your nimble path
02:12:39FromDiscord<graveflo> and you can use atlas too since it was built to manage dependencies
02:33:43FromDiscord<rubythulhu> In reply to @nasuray "Is this a hybrid": yeah i've been creating hybrid packages for hobbyist stuff b/c honestly i don't understand the difference, but i find it weird that if you just choose binary it doesn't create tests
02:34:22FromDiscord<Elegantbeef> hybrid means you can import the modules but you also want to ship a binary
02:34:30FromDiscord<Elegantbeef> Binary means you want to just ship a binary
02:34:48FromDiscord<Elegantbeef> Source means you just want to provide modules to import
02:34:53FromDiscord<Elegantbeef> I guess it calls it a `library` not source
02:36:23FromDiscord<rubythulhu> In reply to @graveflo "`nimble init`": this is part of what confuses me. for my advent of code thing, it told me for a hybrid i need a single aoc.nim and anything else needs to be in an aoc/ submodule. but if i `nimble init`, i get `src/aoc.nim` and `src/aocpkg/blah.nim`, which directly contradicts the warnings i got, because the warnings say it needs to be an aoc/ subfolder, with no mention of "but you can append arbitrary strings t
02:36:55FromDiscord<Elegantbeef> you do need a `aoc.nim` or `src/aoc/....`
02:37:29FromDiscord<graveflo> there isn't a structly enforced directory structure really. the name `aocpkg` and `submodule` are not specific.. its just `foo`
02:37:30FromDiscord<Elegantbeef> Assuming you wanted to distribute your aoc code as a library you then also need to add to the `bins` or w/e the variable is called for each program
02:37:39FromDiscord<rubythulhu> but theres a lot of things i might like to do that would a library plus a handful of helper binaries. in hybrid it complains if i have more than one file in src/
02:38:12FromDiscord<graveflo> its nice to put it in a `src` folder bc then you can put other stuff on the outside
02:39:39FromDiscord<rubythulhu> my solution to make nimble stop complaining at me has been to make src/mypkgname/bin/.nim, and add explicit rules for building them, and making `src/mypkgname.nim` a dummy file to make nimble shut up, even though its not defined in mypkgname.nimble, and putting everything else in src/mypkgname/.nim
02:39:42FromDiscord<girvo> sent a code paste, see https://play.nim-lang.org/#ix=html>
02:39:50FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
02:39:52FromDiscord<rubythulhu> oh i messed up that formatting
02:40:10FromDiscord<Elegantbeef> Yes Girvo with a `{.cast(gcSafe).}: echo example`
02:40:21FromDiscord<girvo> Fair enough!
02:40:33FromDiscord<nasuray> In reply to @rubythulhu "my solution to make": Update nimble and you won't need to do anything of this
02:40:37FromDiscord<girvo> I _was_ using a reader-writer lock, but it seems so unneccesary lol
02:40:48FromDiscord<Elegantbeef> Yea you could put it in a template of course
02:40:53FromDiscord<girvo> ofc
02:40:57FromDiscord<graveflo> you can edit the config files to specify the output of the binary. I usually use a `bin` folder too. That doesnt really matter where the binary comes out though
02:41:53FromDiscord<graveflo> if you are doing a library or a bin and you want it in some path you can use a build script (I think nimble ca do this with their config file) or just write a bash script or something
02:42:49FromDiscord<Elegantbeef> Nim sadly does not have any gcsafe way of using globals like that
02:43:06FromDiscord<graveflo> In reply to @rubythulhu "my solution to make": the dummy file you are talking about is supposed to be your main module. The one you pass to nim as the entry point. If you are doing hybrid you can put multiple entry point files in that dir
02:43:19FromDiscord<rubythulhu> In reply to @nasuray "Update nimble and you": im using nimble from homebrew b/c choosenim gives me an x86 version and i want an arm64-native version and my nimble is installed that way. brew thinks its up to date.
02:43:24FromDiscord<girvo> In reply to @Elegantbeef "Nim sadly does not": yeah tbh it makes sense as to why. and requiring a guard/lock makes sense too
02:43:44FromDiscord<rubythulhu> In reply to @graveflo "the dummy file you": yeah this is a better way of phrasing my question: how to deal with multiple entry-point CLIs
02:43:47FromDiscord<girvo> Is there a type level differentiator between a `var` string and a read-only immutable let string?
02:44:06FromDiscord<nasuray> In reply to @rubythulhu "im using nimble from": Oof I would build nim from source before I'd use homebrew. Choosenim really needs a facelift or revamp...
02:44:11FromDiscord<Elegantbeef> Well as you probably know `let` does not prevent mutations at all levels
02:44:18FromDiscord<girvo> Yeah 😦
02:44:23FromDiscord<Elegantbeef> But yes the compiler of course knows one is `var T` and the other is `T`
02:44:45FromDiscord<girvo> I guess I'm asking for a _full_ proper read-only shared mem string type to exist lol
02:45:21FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=html>
02:45:49FromDiscord<Elegantbeef> Girvo just use `const` 😛
02:46:09FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=html>
02:46:26FromDiscord<girvo> In reply to @Elegantbeef "Girvo just use `const`": I can't 🥲
02:46:40FromDiscord<girvo> (because its loaded _once_ from non-volatile storage)
02:46:47FromDiscord<Elegantbeef> You could use termer's stackstring if it's not too big
02:46:53FromDiscord<girvo> Ooooh its not big at all
02:46:57FromDiscord<girvo> I'll take a look, cheers!
02:47:10FromDiscord<graveflo> (edit)
02:47:23FromDiscord<Elegantbeef> They're even nil terminated and work on 1.6.x now
02:47:41FromDiscord<girvo> Ooooh thats awesome, we're still on 1.6.14 at the moment
02:47:55FromDiscord<Elegantbeef> You're welcome
02:47:57FromDiscord<Elegantbeef> 1
02:47:57FromDiscord<girvo> Got a branch in play to move to 2, but just had too many things on
02:47:59FromDiscord<girvo> Thank you 😄
02:48:30FromDiscord<Elegantbeef> I added 1.6 support to them when I was making a TOTP library more secure and faster
02:48:47FromDiscord<Elegantbeef> It was using ref objects for holding secrets, scary stuff! 😄
02:48:55FromDiscord<girvo> 😮
03:01:27FromDiscord<rubythulhu> sent a code paste, see https://play.nim-lang.org/#ix=html>
03:02:50FromDiscord<graveflo> I see. Well that shouldn't really hurt anything. it's just in your entry points you would import from `NAMEpkg` instead of `NAME`. You are still passing the entry point to nim and that will create your binaries and output them where they are config to drop
03:03:26FromDiscord<rubythulhu> it also complained about me having multiple entry points in src
03:03:33NimEventerNew question by Nate Ackerman: How do I define a setter in a macro in Nim, see https://stackoverflow.com/questions/77657585/how-do-i-define-a-setter-in-a-macro-in-nim
03:03:39FromDiscord<rubythulhu> only way i found to shut it up was moving them into a subfolder of src/
03:03:46FromDiscord<graveflo> you are doing `nim c src/entry1.nim` like this yes?
03:04:08FromDiscord<rubythulhu> im trying to get nimble build happy with my source folder
03:05:43FromDiscord<graveflo> so you are specifying the entry point as a file or a dir? Idk why it would be choosing the wrong one. The `build` command cn have multiple different build routines iirc. You would need to set it to the entry point you want to use. It shouldn't be guessing that
03:06:34FromDiscord<graveflo> like this: `setCommand "c", "src/myentry.nim"` in `whatever.nimble`
03:07:12FromDiscord<rubythulhu> it works if i add namedBin entries for src/pkgname/foo.nim etc, and take src/pkgname.nim out of pkgname.nimble
03:07:38FromDiscord<rubythulhu> but im not sure if it works b/c thats cool, or i just half-assed myself into a solution that works
03:08:03FromDiscord<graveflo> oh ok if its working thats all that matters for now
03:08:38FromDiscord<rubythulhu> oh yes, working isnt the problem. i just wanted to understand what nimble WANTS me to do, because its only telling me what it doesn't want me to do
03:12:15FromDiscord<rubythulhu> this kind of "your dir structure doesn't match whatever" doesn't seem to line up with nim's principles of "whatever i dont wanna argue about formatting and style" attitude, i can name identifiers however i want as long as the first character matches case, but nimble's telling me i'm naughty for not adhering to some arbitrary directory structure that i can't find the documentation for
03:12:35FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=html>
03:14:01FromDiscord<rubythulhu> i mean core point is, my nimble seems to be doing old stuff
03:14:41FromDiscord<graveflo> ok I believe you. Maybe update at some point then
03:15:05FromDiscord<rubythulhu> well, thats from what this chat is told me
03:15:11FromDiscord<graveflo> nimble isn't the most stable awesome piece of software in the world but its better then nothing
03:15:25FromDiscord<rubythulhu> er s/is/has
03:16:47FromDiscord<rubythulhu> according to nimble --version tho im up to date
03:17:38FromDiscord<graveflo> idk about nibles release schedules but sometimes "up to date" is more accurately the dev build not the latest release. Depends on what your up to though
03:17:44FromDiscord<rubythulhu> and it still creates w/ `pkg` suffix, ie "src/foo.nim" and "src/foopkg/submodule.nim"
03:17:54FromDiscord<rubythulhu> i was comparing github releases vs nimble --version
03:18:18FromDiscord<graveflo> ah ok. You're probably up to date then tbh
03:30:25*edr quit (Quit: Leaving)
03:37:27FromDiscord<rubythulhu> i guess part of the problem is i want `binary` but nimble `binary` doesnt generate tests and i still want that test folder there guilting me into being a better engineer haha
03:41:57FromDiscord<rubythulhu> many parts of whichever project i could write tests for, and entry-points are lightweight wrappers around logic in other files, its library code but it's all internal / private and i may or may not intend to publish the underlying lib
03:43:57FromDiscord<Elegantbeef> This makes me think nimble needs "init templates" 😄
03:45:21FromDiscord<rubythulhu> from what i understand hybrid/library/binary seems to be inferred by mypkg.nimble, rather than explicitly declared, and i haven't found a way to ask nimble to look at some `mypkg.nimble` and even tell you whether it thinks its a hybrid/library/binary, and it seems like theres different requirements on the package based on which of the above it is, and i can't find documentation for those
03:45:43*azimut quit (Ping timeout: 240 seconds)
03:45:46FromDiscord<Elegantbeef> I mean they're really just layouts and defaults
03:45:59FromDiscord<Elegantbeef> a hybrid is a package with `srcdir` and `bins` defined iirc
03:46:06FromDiscord<Elegantbeef> A binary is just a package with `bins`
03:46:16FromDiscord<Elegantbeef> a library is just one with no `bins`
03:47:13FromDiscord<rubythulhu> that's what i understood it as
03:51:42FromDiscord<rubythulhu> sent a long message, see <!doctype html>
03:53:22FromDiscord<rubythulhu> In reply to @Elegantbeef "This makes me think": or a separate tool to create nim starting-points outside of nimble haha
03:55:14FromDiscord<Elegantbeef> Right name it `nimitz` cause it's a launchpad for Nim projects 😄
03:55:37FromDiscord<Elegantbeef> Then make a template file format using toml or yaml
03:55:43FromDiscord<Elegantbeef> Then profit?
04:16:19FromDiscord<rubythulhu> or just fun project to fill a gap in the nim ecosystem 🙂
05:13:05FromDiscord<graveflo> In reply to @rubythulhu "but then nimble tells": I'm pretty sure this means that you didn't configure the nimble tasks
05:14:12FromDiscord<rubythulhu> correct i did not configure any nimble tasks
05:14:52FromDiscord<rubythulhu> well in one project i added a few custom ones, but i'm assuming you mean specific tasks
05:15:10FromDiscord<rubythulhu> nimble docs aren't super clear
05:16:27FromDiscord<graveflo> yea I bet if the task has a `setCommand` directive you can do multiple entry points. like `setCommand "c", "src/nimstoryfont.nim"` and maybe the other error will do away if you change this line? : `srcDir = "src"` to `srcDir = ["src", "foo"]`
05:18:17FromDiscord<graveflo> nimble has to know where the source dir is so that it can add it to nimble path and allow other modules to import it when it is installed
05:46:25*casaca_ joined #nim
05:47:41*casaca_ is now known as casaca
07:13:24*PMunch joined #nim
07:43:06*advesperacit joined #nim
08:02:41FromDiscord<Phil> Huh, that SO quesiton shows an interesting conundrum
08:03:12FromDiscord<Phil> How do you define an operator in a quote do block when the quote do block uses backticks to identify nodes to insert and you need backticks to surround the operator
08:03:22FromDiscord<Elegantbeef> You use genast
08:03:31FromDiscord<Elegantbeef> Or you use the second parameter and change the operator used to quote
08:03:52PMunchOr you define your identifier ahead of time as something which can be inserted at that point with backticks
08:04:06PMunchElegantbeef, I've never been able to get that to work for some reason..
08:05:32FromDiscord<Phil> Pre-defining the operator name seems like the simplest way
08:06:00FromDiscord<Elegantbeef> Genast or quote's second parameter?
08:06:55PMunchquote's second parameter
08:06:59PMunchI would do it like this: https://paste.rs/mxxh5.txt
08:07:18PMunchOf course I'd clean up indentation and adhere to a more royale style as well
08:07:36FromDiscord<odexine> i've also had trouble using the second parameter
08:08:19PMunchWhy is genasts in a separate module?
08:09:20FromDiscord<Phil> genasts is one of those things where I try to use it once in a while and it just doesn't click and I end up falling back to just building the nodes myself or using quote do
08:10:04FromDiscord<Elegantbeef> genast is literally quote but better
08:10:18PMunchSo it's like superQuote?
08:10:30FromDiscord<Elegantbeef> It's in a seperate module likely not to make `macros` larger
08:10:37FromDiscord<Elegantbeef> Not all macros need genast
08:10:49PMunchhttps://github.com/PMunch/macroutils#building-trees
08:10:53FromDiscord<Phil> In reply to @PMunch "I would do it": That won't work, same problem as before (YOu sure you copy pasted the right thing?)
08:11:11PMunchAh damn it..
08:11:30PMunchOnce again bitten by the playground not supporting the Linux select to copy thing..
08:12:03PMunchhttps://paste.rs/XwVxI.txt
08:12:08PMunchThere, that's how I would do it
08:13:57FromDiscord<Elegantbeef> https://hatebin.com/mtnompisju
08:14:15FromDiscord<Elegantbeef> Genast is more flexible as it has the template semantics
08:14:36FromDiscord<Elegantbeef> Replace all captured symbols with their names
08:14:46FromDiscord<Elegantbeef> Plus you can inject your own ast without predeclaring a variable
08:15:07FromDiscord<Elegantbeef> `genast(someLetExpr = newLetExpr(a, b)): someLetExpr` is valid
08:15:26FromDiscord<Elegantbeef> Well guess that's `stmt` not expr
08:16:30FromDiscord<Phil> Mind if I add that to the reply to the guy or will you write him a reply with that yourself?
08:17:05FromDiscord<Elegantbeef> You can reply with it
08:18:03PMunchHoly shit, I managed to get the extra parameter of quote to work: https://paste.rs/iGWMb.txt
08:18:19PMunchIt's super unintuitive though :S
08:18:44FromDiscord<Elegantbeef> you don't need `do` in most cases any more 😄
08:19:03*sagax joined #nim
08:19:06PMunchFair, I just do it out of habbit
08:19:24PMunchIt never hurts, and in some rare cases I think it is still needed
08:19:32FromDiscord<Phil> You fine with me adding that to the SO reply as well?
08:19:43PMunchOf course
08:20:13PMunchWould be kind of a dick move to tell you a solution but not allow you to share it with the person who actually needed it :P
08:20:57*azimut joined #nim
08:20:57FromDiscord<Elegantbeef> He is talking to me afterall
08:24:29PMunchDamn, I had forgot I implemented this: https://github.com/PMunch/macroutils#extracting-nodes-from-a-tree
08:24:40PMunchThat could actually be super useful
08:25:21FromDiscord<Phil> In reply to @PMunch "Would be kind of": I prefer asking ahead of time because just taking code and copy pasting it to SO feels disrespectful 😅
08:25:27FromDiscord<Phil> code from others
08:25:35FromDiscord<Elegantbeef> Funky pattern matching
08:26:52FromDiscord<Elegantbeef> profit.svg https://media.discordapp.net/attachments/371759389889003532/1184773491191451698/profit.svg?ex=658d314c&is=657abc4c&hm=a65be2ac3439a411a33d8c8cdf5e7ac3c02651e049e741ec834278049456dacf&
08:27:01FromDiscord<Elegantbeef> Hmm my flamegraph stuff looks good now minus that text bug
08:27:28FromDiscord<Elegantbeef> If only this was not just a waste of time and a usable profiler 😄
08:28:04PMunchAre you writing a profiler?
08:28:14FromDiscord<Elegantbeef> Sorta, kinda, not really
08:28:39FromDiscord<Elegantbeef> I hijacked the Nim profiler mechanism to sample data then output that into a svg based on the one generated from flamegraph
08:28:52FromDiscord<Elegantbeef> So technically yes, but will it actually be usuable is probably unlikely 😄
08:29:05PMunchHuh, that's a cool idea though
08:29:46PMunchBy the way, that SVG did not embed properly over the bridge :P
08:29:59FromDiscord<Phil> Added a small epilogue about ditching untyped in their case
08:30:12PMunchDitching untyped?
08:30:37PMunchElegantbeef, is that text rendering bug just a bunch of nodes on top of each other?
08:30:52FromDiscord<Phil> sent a long message, see <!doctype html>
08:31:21FromDiscord<pmunch> Fair enough
08:31:39FromDiscord<Phil> Untyped is useful when you're accepting stuff that isn't at all semantically correct, though when it is useful to output untyped I'm unsure of
08:31:40PMunchI rarely use typed unless I actually need the type information
08:31:50FromDiscord<Phil> Because a macro afaik needs always to output valid code
08:32:01FromDiscord<Phil> So typed for output (and thus omitting the output type) makes sense
08:32:02FromDiscord<Elegantbeef> Bridge moment
08:32:05FromDiscord<Phil> At least since Nim2.0
08:32:15PMunchI don't think I've written a single macro which returned `typed` :P
08:32:18FromDiscord<Elegantbeef> Yea you can hit reset view pmunch and the text fixes itself
08:32:31FromDiscord<Phil (he/him)> Wow, that bridge dropped a lot
08:32:40FromDiscord<Elegantbeef> Think it's still dropping
08:32:49PMunchWit, it's dropping messages?
08:32:55FromDiscord<Elegantbeef> Ah we're back
08:32:56FromDiscord<Phil> Nah, it just dropped the entire bits about flamegraphs, everything else is there
08:33:04FromDiscord<Elegantbeef> Anyway you cannot make a macro that returns `typed`
08:33:20FromDiscord<Elegantbeef> The compiler always has to semantically check the macro
08:33:26FromDiscord<Elegantbeef> So `typed` and `untyped` are the same thing
08:34:06FromDiscord<Elegantbeef> I should note there is a hidden reset view in the top left(assuming you opened it in browser)
08:34:26FromDiscord<Elegantbeef> flamegraph does this nice thing of including JS inside of the svg so opening it in a browser gives you an interactive graph
08:34:46PMunchOh right, that's a thing
08:35:03PMunchI actually used to do my presentations as SVGs with embedded JS
08:35:25PMunchReason I stopped was that font support was always dodgy
08:35:35PMunchAnd converting all my text to paths made the SVG comically huge
08:36:05PMunchBesides, making presentations in LibreOffice Impress isn't actually all that bad
08:36:32PMunchBesides syntax highlighting code, that's always a bit of a pain
08:36:36FromDiscord<Elegantbeef> Imagine going to a keynote presentation and not using keynote, Apple shudders
08:36:59FromDiscord<Elegantbeef> Well acktually keynote presentations were named before the program
08:37:05PMunchHaha :P
08:37:32PMunchHave you actually tried Keynote?
08:38:45PMunchDamn it.. `withValue` in the tables module can't return stuff..
08:42:07FromDiscord<Elegantbeef> My school had macs so it's all I've used
08:42:54FromDiscord<Elegantbeef> are you using the variation with both branches?
08:43:44FromDiscord<Elegantbeef> `table.withValue(key, name): name; do: default typeof(name)` should work
08:52:54FromDiscord<Elegantbeef> This also reminds me that there is a slightly safer way of doing `withValue` https://hatebin.com/foplqrgnfg
08:53:03PMunchWait, your school only had Macs for students?
08:53:09PMunchWhat a strange choice
08:53:10FromDiscord<Elegantbeef> Yes
08:53:16FromDiscord<Elegantbeef> I'm in oil country
08:53:27PMunchAnd I'm not?
08:53:40FromDiscord<Elegantbeef> We had laptop carts that had like 4 macs that were shared between a few classes
08:53:59FromDiscord<Elegantbeef> I mean I'm right in the heart of the oilfields
08:54:11FromDiscord<Elegantbeef> So more money than brains is a commonality
08:55:03PMunchAccording to WolframAlpha Norway exports about 5 times as much oil per capita as Canada :P
08:55:11FromDiscord<Elegantbeef> We're talking about people that get new vehicles annually
08:55:19FromDiscord<Elegantbeef> Sure but I'm not talking about Canada
08:55:23PMunchAh right
08:55:26PMunchSpecific areas
08:55:35FromDiscord<Elegantbeef> Compare Alberta to Norway
08:55:43FromDiscord<Elegantbeef> The number will be vastly different
08:55:52PMunchWell, here we do this neat little trick called distribution of wealth. So it's probably not as pronounced
08:56:25PMunchAnd to be fair, back when I was in school we had to go to the library and use one of their two beige machines with CRT monitors running Windows 95
08:56:25FromDiscord<Elegantbeef> Lol we only have a 5% sales tax and that's due to the federal government
08:56:46PMunchWow
08:56:51PMunchI think ours is 25%..
08:57:15FromDiscord<Elegantbeef> Yea I don't get it in elementary school they had the CRT macs here, such a waste of money
08:57:23PMunchWolframAlpha didn't seem to like comparing Alberta
08:57:39PMunchProbably because it can't find oil exports specifically from Alberta
08:57:56PMunchOh the old iMac?
08:58:02PMunchWith the colourful plastic backs?
08:58:08FromDiscord<Elegantbeef> Yea
08:58:25FromDiscord<nnsee> in 2014 it was around 15m bbl/day
08:58:28FromDiscord<nnsee> for alberta
08:58:48FromDiscord<nnsee> sorry what
08:58:52FromDiscord<nnsee> 2.9m
08:59:06FromDiscord<nnsee> i have no idea where i got 15 from, it's like i alt-tabbed back to the page and the number had changed
08:59:34FromDiscord<nnsee> it was 2.9 bbl/day
08:59:38FromDiscord<nnsee> m
08:59:41FromDiscord<nnsee> god i need coffee
08:59:58FromDiscord<Elegantbeef> https://economicdashboard.alberta.ca/dashboard/oil-production/
09:00:10PMunchGot some pretty crazy numbers with 15m :P
09:00:55PMunchI'm drinking a really nice Colombian Geisha micro batch coffee right now
09:01:06FromDiscord<nnsee> In reply to @Elegantbeef "https://economicdashboard.alberta.ca/dashboard/oil-": wait what, so it was 15m!?
09:01:09PMunchCan definitely recommend!
09:01:34FromDiscord<nnsee> it isn't ever mentioned on this document i'm reading, this one says 2.9m
09:01:35FromDiscord<nnsee> https://open.alberta.ca/dataset/b8fea8da-848f-4d04-be0f-983787f88694/resource/10be9c86-9b98-43e5-b16a-904b95800612/download/11-albertas-oil-production-and-where-it-goes-formated.pdf
09:01:47FromDiscord<nnsee> so it's even crazier i somehow misread that as 15m and it's actually correct?
09:02:00PMunchEither way, that beats out Norways oil exports per capita
09:02:04FromDiscord<nnsee> oh wait
09:02:05FromDiscord<nnsee> that's m3
09:02:10FromDiscord<nnsee> not bbl
09:02:19FromDiscord<nnsee> i need to stop trying
09:02:29FromDiscord<Elegantbeef> Nah I think it's about par Pmunch
09:02:35FromDiscord<Elegantbeef> Alberta only has 4.6mil people
09:02:54FromDiscord<Elegantbeef> In 2022 both generated around 230 million m^3
09:02:56FromDiscord<Phil> What gets me (as I'm adding some docs to threading/channel) is that the builtin channel module has perfectly adequate docs that could just be copy pasted for large parts of it
09:03:02FromDiscord<nnsee> In reply to @PMunch "I'm drinking a really": well the thing is i stopped drinking coffee a while back
09:03:03FromDiscord<Phil> Copy paste, then adjust, boom, done
09:03:15FromDiscord<nnsee> since i wasn't really able to sleep well at night and i thought it might've been the caffeine
09:03:29FromDiscord<Elegantbeef> Just drink decaf
09:03:30FromDiscord<nnsee> it definitely helped but not as much as i would've liked it to
09:03:48FromDiscord<nnsee> In reply to @Elegantbeef "Just drink decaf": eh, cba, our machine doesn't make decaf coffee and tea is easier
09:04:03FromDiscord<nnsee> i don't like the taste of coffee _that much_ to go out of my way to deliberately get decaf
09:04:14FromDiscord<Elegantbeef> How doesn't your machine make decaf
09:04:22FromDiscord<nnsee> how do you even make decaf
09:04:36FromDiscord<Elegantbeef> You buy decaffeinated coffee and use it
09:04:43FromDiscord<nnsee> oh lol
09:05:05FromDiscord<Elegantbeef> It's generally a chemical process that removes the caffeine
09:05:07FromDiscord<nnsee> eh, both bean slots are filled and i don't think other people in the office would appreciate me silently cutting off their caffeine intake
09:05:15FromDiscord<nnsee> suddenly everyone's very groggy at the office and nobody knows why
09:05:17PMunchHaha
09:05:23PMunchHad that happen at a place I used to work
09:05:25FromDiscord<Elegantbeef> Drugs r bad
09:05:28FromDiscord<Elegantbeef> They should learn
09:05:39PMunchThis was right when capsule machines where entering the market
09:06:22PMunchWe had run out of caffeinated pods so only the decaf ones where left. The only way to tell was that the decaf pods where red, but it didn't say decay on them, you just had to know
09:07:07PMunchMy mom had a capsule machine, so I knew, but this other unfortunate guy had been drinking 8 cups a day wondering why he had a big headache and was so tired all the time
09:07:27PMunchIt wasn't until someone asked when the new non-decaf pods would arrive that he realised
09:08:06PMunchHe was about a week in at that point
09:08:33FromDiscord<nnsee> lol, the hidden cold turkey
09:08:45PMunchExactly, poor guy
09:08:57PMunchHe just kept drinking more and more cups
09:09:02FromDiscord<Elegantbeef> The only way this could get worse is if the next month someone accidentally left their brownies in the break room
09:09:13PMunchIs it falling asleep, staying asleep, or waking up which is your main issue?
09:09:41FromDiscord<nnsee> combination of all of them actually, but mostly the first two
09:09:50FromDiscord<nnsee> have a hard time falling asleep and when i do, i tend to wake up very easily
09:10:21FromDiscord<nnsee> around 8am, after getting like 5 hours sleep, my sleep just disappears and i can't fall asleep again
09:10:57PMunchWhat worked for me in that case was light regulation. Granted I live in a place that doesn't naturally keep a proper day/night cycle, so YMMV
09:12:11FromDiscord<nnsee> yeah that's what i thought as well, since i don't have curtains, i thought i might've been that i wake up to the light
09:12:19PMunchI basically programmed all the smart bulbs in my house to dim down in the evening, and switched from staying on the computer to reading a book an hour or two before bedtime
09:12:23FromDiscord<nnsee> but during the winter, it's still dark at around 8am
09:12:50PMunchWell it could be that your body learns that 8AM is when the day starts during the summer and it just carries on into the winter
09:13:00FromDiscord<Phil> Just move closer to the north or south pole, easy
09:13:11FromDiscord<Phil> And pack a light jacket as it might get a bit nippy
09:13:17FromDiscord<nnsee> like i said before i want to move to svalbard
09:13:23FromDiscord<nnsee> well maybe not _move_
09:13:35PMunchI keep waking up at 6:30 during weekends and holidays because that's what my body is used to. I quickly fall asleep again though
09:14:38PMunchWell the constant darkness messes with you in the opposite way. Now you'll be tired all day instead, regardless of how well you've slept.
09:15:10PMunchCod liver oil and lights cycling an actual day/night cycle has helped a lot for me though
09:15:29PMunchRight, so I might've added a really neat feature to Futhark
09:15:35PMunchProject mode is the working title
09:16:16PMunchBasically what everyone has asked for ever since I launched it, point it at a folder, and it wraps everything in that folder into individual files with proper imports.
09:16:44PMunchAs an added bonus it also adds `{.compile: "".}` statements if it finds a C file named the same as the header in the same folder
09:17:33FromDiscord<nnsee> very nice
09:19:02PMunchSo code like this: https://paste.rs/IbHbu.txt, turns into code like this: https://paste.rs/fMAf4.txt
09:21:54PMunchThis should allow Futhark to be useable on microcontrollers as well. Because you can now wrap the entire library for a chip, and then just import the modules you want without any extra build and link steps :)
09:22:09FromDiscord<nnsee> neat
09:32:53FromDiscord<Phil> Question regarding https://nim-lang.github.io/threading/channels.html#recvIso%2CChan%5BT%5D↵What distinguishes that from just a normal receive?
09:33:31FromDiscord<Phil> I'm trying to add docs and I don't understand that one at all
09:33:34FromDiscord<Elegantbeef> It calls isolate on the data after
09:35:32FromDiscord<Phil> Assume I don't know what that means because I don't.↵I mean, I was told (by you I believe?) that isolated just means that the data is self-containing or however you should word that.↵Meaning it is a complete package of data, not referencing anything else, no pointers anywhere
09:35:57FromDiscord<Elegantbeef> Yea I do not think that it makes sense and that code likely does not compile
09:36:14FromDiscord<Phil> That last sentence stands on very shaky grounds of my understanding.
09:36:24FromDiscord<Phil> So Isolated is just "You don't have pointers" - Does that include refs?
09:36:32FromDiscord<Elegantbeef> No that's not what isolated mean
09:36:41FromDiscord<Elegantbeef> Isolated means it's a self contained graph
09:37:10FromDiscord<Phil> I lack an understanding of seeing data as graph to analyze that statement
09:37:24FromDiscord<Elegantbeef> References
09:37:29FromDiscord<Elegantbeef> Those are nodes in a graph
09:37:49FromDiscord<Elegantbeef> An isolated graph is a graph that has no references from the outside
09:38:03FromDiscord<Elegantbeef> All nodes inside the graph are only referenced inside the graph
09:38:10FromDiscord<Phil> Ahhhh, it's not that the elements in the graph point to somewhere else, it's that the outside must not point inside
09:38:16Amun-Rait's that the same as pony language's iso?
09:38:52Amun-Ra"This means an iso variable is the only variable anywhere in the program that can read from or write to that object. It is read and write unique."
09:39:21Amun-Ra(asking for a friend)
09:39:24FromDiscord<Phil> Can you... "un-isolate" a graph?
09:39:26FromDiscord<Elegantbeef> I think it's similar
09:39:39FromDiscord<Elegantbeef> Yes you access fields on it
09:39:47FromDiscord<Elegantbeef> I mean Nim's `isolate` is quite dumb
09:39:48FromDiscord<Phil> Ah wait, that goes further than I plan to, just need doc comments for the proc
09:39:52FromDiscord<Phil> Check
09:40:16FromDiscord<Elegantbeef> `Isolated` just wraps references in a way that disallows `copy`ing
09:40:29PMunchPhil, the idea is that if you have an isolated graph you can safely pass the pointer to it between threads. As long as no two threads can hold the root of the tree at the same time, and no threads can point into the tree without holding the root, then you can safely pass the whole tree around just by passing the root reference around.
09:40:36FromDiscord<Elegantbeef> An isolated graph is meant to be moved from one thread to another
09:40:57FromDiscord<Elegantbeef> I would not say "pass the pointer" as that sounds like sharing
09:41:13FromDiscord<Elegantbeef> Isolated is not aimed for sharing, but aimed for safely moving data from a thread to another
09:41:29PMunchWell you are sharing, just not at the same time
09:41:34FromDiscord<Elegantbeef> https://github.com/nim-lang/RFCs/issues/244
09:41:43FromDiscord<Phil> Doc gen question!
09:41:44FromDiscord<Elegantbeef> Shared memory implies concurrent access
09:42:49FromDiscord<Phil> The `Isolated` type is referenced a lot in those procs in the docs.↵However, it is never hyperlinked, I assume because threading is its own package and Isolated is part of the std-lib.↵Can I hyperlink to the definition of Isolted in the std-lib docs somehow?
09:43:10PMunchCompare it to passing the milk, I can take a glass of milk while having the carton (getting a reference into the tree), but the isolated rule says that I need to finish drinking my glass before I can pass on the carton. So anyone who has the carton can be sure that they know exactly how much milk is left
09:43:17FromDiscord<Phil> from within the threading package I mean
09:43:32FromDiscord<Elegantbeef> I mean you can just hard code the Nim url to ti
09:43:35FromDiscord<Elegantbeef> it\
09:44:13PMunchDoesn't work if you decide to build the docs locally though..
09:46:45FromDiscord<Phil> I may just go for a link to the isolated module as a whole in the module-doc-comment at the top
09:47:02FromDiscord<Elegantbeef> I like that Phil is asking you and Me, both people that do not overly document our projects 😛
09:50:12FromDiscord<piqueiras> If I want to edit some elements of a seq[string] (not append or delete, just edit) is proc(text:var seq[string]) good enough for performance?
09:50:20NimEventerNew Nimble package! happyx-native - Macro-oriented web-framework compiles to native written with ♥, see https://github.com/HapticX/happyx-native
09:50:39FromDiscord<Elegantbeef> I do not see the alternative to your question
09:51:09FromDiscord<Elegantbeef> though I'd probably suggest `var openArray[string]` over `var seq[string]`
09:51:13FromDiscord<piqueiras> something weird with cstrings idk
09:51:15FromDiscord<Elegantbeef> No performance difference just more reusable
09:52:18PMunch"HappyX web framework, but for native platforms"
09:52:24PMunchWhat does this even mean?
09:52:31PMunchAren't all platforms native to themselves?
09:53:06FromDiscord<nnsee> same as react-native, I'd imagine?
09:54:30FromDiscord<Elegantbeef> I think it's a program to wrap happyx to make progressive web apps?
09:54:33FromDiscord<Elegantbeef> No clue
09:54:49*adigitoleo quit (*.net *.split)
09:54:52FromDiscord<Elegantbeef> Personally though I find the term "progressive" ironic as it's clearly regressive
09:55:08FromDiscord<Elegantbeef> Guess that's more oxymoronic
09:56:35FromDiscord<Elegantbeef> Seems that's what it's for, even supports android it seems
09:57:05FromDiscord<nnsee> so different to react-native
09:57:38FromDiscord<Elegantbeef> Well I cannot say anything for certain I'm throwing mud at the wall and seeing what stays
09:59:31PMunchAah right
10:00:04PMunchThat's.. Interesting
10:01:03FromDiscord<Elegantbeef> As much as I'd like to be able to just use gtk on android it's nice to see a path there 😄
10:01:28FromDiscord<nnsee> 2024 is the year of the linux phone
10:01:28PMunchElegantbeef, while I have you here, do you have the link to that wasm thing you linked me yesterday?
10:01:45PMunchWhen I was asking for semi-simple projects
10:01:52FromDiscord<Elegantbeef> No I lost it in my paper shreader
10:02:02FromDiscord<Elegantbeef> https://github.com/wasm3/wasm3 is the C project
10:02:06PMunchThanks :)
10:02:08FromDiscord<Phil> I mean, typically this means "You write X and it may compile to web with HTML/CSS/JS, but we can also compile it to a single binary that runs natively as a self contained application
10:02:10FromDiscord<Phil> (edit) "application" => "application""
10:02:18FromDiscord<Phil> Which is what react-native means by those statements
10:02:18FromDiscord<Elegantbeef> https://github.com/beef331/wasm3/blob/master/src/wasm3/wasm3c.nim is my wrapping of it for reference
10:02:33PMunchDoes it bundle Chrome somehow when you do this?
10:02:47*adigitoleo joined #nim
10:02:56PMunchAndroid support is interesting though, might have to give that a go
10:03:03FromDiscord<nnsee> In reply to @PMunch "Does it bundle Chrome": no, react-native doesn't
10:03:04FromDiscord<Phil> In reply to @PMunch "Does it bundle Chrome": react native doesn't, it has different backends
10:03:15PMunchI really want a good Nim -> Android app workflow
10:03:23FromDiscord<Elegantbeef> React-native does not, but happyx hopefully uses your system webview or a portable webview library
10:03:27FromDiscord<Phil> It tries to use native widgets to represent what you input as HTML/CSS/JS.↵That also means it tries to limit what you do
10:03:33FromDiscord<Phil> (edit) "It tries to use native widgets to represent what you input as HTML/CSS/JS.↵That also means it tries to limit what you ... do" added "can"
10:03:41PMunchHmm, right
10:03:57PMunchSo React native is more like React for GUI framework X
10:04:22PMunchWhile happyx seems to be more like Electron in that it just builds the web-app and links to a browser
10:04:35FromDiscord<Phil> Kinda. It's similar to nim in taht sense, you have a "frontend" where you input stuff with webtech and then various backends
10:05:33FromDiscord<Phil> And yeah, it still is an electron-like app:↵> Compiles main happyx file, opens browser in appMode and starts serving at localhost with port
10:06:00FromDiscord<Phil> So not like react native
10:06:10FromDiscord<Phil> (edit) "taht" => "that"
10:06:42FromDiscord<Phil> https://hapticx.github.io/happyx-native/happyx_native/app/app.html↵For the interested
10:07:00FromDiscord<Phil> In reply to @Elegantbeef "https://github.com/beef331/wasm3/blob/master/src/wa": That's a lot of compiler flags
10:07:26FromDiscord<Phil> I am mildly scared that I'm actually starting to remotely understand some of this
10:07:58FromDiscord<Phil> I mean not what it does but the syntax for doing the binding stuff
10:09:11FromDiscord<nnsee> In reply to @isofruit "I am mildly scared": truly scary
10:09:44FromDiscord<Phil> Look, like I started the year with 0 knowledge about macros and 0 knowledge about wrapping C
10:10:34FromDiscord<Phil> I do one macro based project and suddenly I find myself contributing to GTK bindings with a macro-based, declarative interface and generating a library's worth of code for a multithreading library
10:11:02FromDiscord<Phil> (edit) "generating" => "writing" | "writinga ... library's" added "second library that generates another"
10:11:07FromDiscord<Phil> (edit) removed "a" | removed "library"
10:11:41FromDiscord<Phil> Its drugs I tell you!
10:11:46FromDiscord<nnsee> it's a steep slope
10:11:55FromDiscord<nnsee> and slippery
10:13:19PMunchMacros are like one of those slides at a water park. The climb up is long and kinda scary, but once you get to the top you just start sliding and you can't really stop!
10:14:24FromDiscord<Phil> It actually gets kinda easy, it was 2 core truths that I needed to wrap my head around and after that it became a free for all with nothing being sacred
10:17:28PMunchWhat where those? Just curious
10:18:20FromDiscord<Phil> sent a long message, see <!doctype html>
10:19:10FromDiscord<Phil> The rest imo evolves out of that
10:20:15PMunchPretty good summary :thumbsUp:
10:20:38PMunchWelp, that didn't do well with the bridge :P
10:20:39FromDiscord<Phil> Point 3 is why I wrote myself my own versions of "expectKind" and "assertKind" that I use everywhere.↵First line of a proc is basically always "nodeParam.assertKind(<nodekinds>)"
10:21:18FromDiscord<Phil> It makes debugging where I went wrong so much easier because it tells me immediately where my expectations are incorrect
10:21:28PMunchUseful for DSLs, but in general I'd say that if you need to care about your input arguments you're doing something wrong
10:21:37PMunchThe exception is of course DSLs
10:21:42PMunchWhere it is very important
10:23:44FromDiscord<Phil> I would disagree on that. I mean, take mapster.↵You annotate a proc with a macro.↵That does nothing but add a line `param.mapTo(result)` at the start of the proc, where `mapTo` is a generic proc that copies values from `param` over to result if the name and type match.
10:24:26FromDiscord<Phil> I provide options to validate the everliving hell out of that proc to e.g. guarantee at compiletime that all fields of the result-type get assigned to
10:25:16FromDiscord<Phil> I also provide options for mapping to variant types where I also validate that you hand me that your inputs match what I expect so I generate the correct code.↵In this case that your proc has a parameter that defines the kind of the object variant you want to create
10:25:30FromDiscord<Phil> (edit) "I also provide options for mapping to variant types where I also validate that you hand me that your inputs match what I expect so I generate the correct code.↵In this case that your proc has a parameter that defines the kind of the object variant you want to create ... " added "- that the kind-parameter matches the expect type of the kind-field on the object variant etc."
10:26:48FromDiscord<Phil> Same for my current multithreading thing.↵You have macros to register types and handler-procs with it.↵Registering a macro immediately checks if the proc that was just registered uses types that were also registered.↵And fails if the types are already being used by another registered proc
10:28:39FromDiscord<Phil> My mantra is that in order to generate code reliably I need to know what you're inputting, otherwise I'm opening my user up weird macro errors.↵It's not ironclad of course, but the direction is much more in the direction that macros may only be used in the manner described by the docs and everything else is not supported
10:28:53PMunchWait, so with mapster you're looking at the passed in AST and replacing calls?
10:30:05FromDiscord<Phil> No, I just add one at the start of the proc-body, I leave the proc-body itself untouched
10:30:40FromDiscord<Phil> It really is just adding that single line at the start and that's it.↵The validation is separate, that just means I blow up at compiletime with decent error messages of what you did wrong
10:30:50FromDiscord<Phil> that doesn't replace anything
10:31:44PMunchAh right
10:31:46PMunchHmm
10:32:20FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
10:32:36FromDiscord<Phil> (edit)
10:33:03FromDiscord<Phil> That interacted poorly with the backticks I had in the doc comment
10:57:55FromDiscord<piqueiras> sent a code paste, see https://play.nim-lang.org/#ix=html>
11:05:59FromDiscord<demotomohiro> In reply to @piqueiras "Is there some way": https://nim-lang.org/docs/system.html#toOpenArray%2Cseq%5BT%5D%2Cint%2Cint↵with↵https://nim-lang.org/docs/manual_experimental.html#view-types
11:10:40FromDiscord<piqueiras> damn
11:10:40FromDiscord<piqueiras> cool
11:10:42FromDiscord<piqueiras> ty
11:11:14FromDiscord<piqueiras> would that work if I had a matrix (seq of seqs) to obtain a column?
11:14:43PMunchElegantbeef, hmm it struggles on the WASM library. Basically in wasm3.h it references M3Environment, which is defined in m3_env.h, but that file is never imported in wasm3.h
11:27:01FromDiscord<Clonkk> Does anyone generate code coverage during unit tests execution ? All existing nim project around that seems deprecated / obsolete
11:30:44FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
11:31:44FromDiscord<ringabout> Yes, because you cannot share refs, I suppose `let msgI = isolate(LargeMessage)` should work
11:31:54FromDiscord<Phil> I mean, I get why its throwing an error, because msg is holding a ref and isolate seemingly can't change that because that could lead to nil access or sth, but I wonder what your options are there - Only to implement hooks?
11:32:24FromDiscord<Phil> hooks that move ownership on reassignment I mean
11:33:18FromDiscord<ringabout> (edit) "isolate(LargeMessage)`" => "isolate(LargeMessage())`"
11:33:47FromDiscord<ringabout> I don't think hooks work, the only option is `let msgI = isolate(LargeMessage())`; that how it was designed
11:34:19FromDiscord<Phil> I mean, I can also msg[]
11:34:50FromDiscord<Phil> That's more in the context of "what if somebody else passes me an object to isolate"
11:35:10*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
11:36:09FromDiscord<Phil> Which is the situation you'd be in if you were writing a framework/lib for easy webserver-like multithreading and need message-passing, which leads to calls to isolate on objects whose types you can't know 😄
11:36:30FromDiscord<Phil> (edit) "Which is the situation you'd be in if you were writing a framework/lib for easy webserver-like multithreading ... and" added "(with a thread behaving like a server)"
11:39:08FromDiscord<Phil> I guess I'll just write that ref-type messages are not supported because while I could implement that, it would require me unreffing the message, then sending it, and then turning it back into a ref on the other thread
11:40:03FromDiscord<piqueiras> how do I ignore indent 🥲 https://media.discordapp.net/attachments/371759389889003532/1184822106949689414/image.png?ex=658d5e93&is=657ae993&hm=ca8a2d5574792175615fcd23c7112df610f1a7933f245f77a64e8fc4ad1abc87&
11:41:06FromDiscord<Phil> Disable nimsuggests ability to show you these things, embrace the compiler as your only true source of knowledge for whether your code works or not!
11:41:16FromDiscord<Phil> Because I certainly do!
11:41:23FromDiscord<piqueiras> Error: nestable statement requires indentation
11:41:24FromDiscord<piqueiras> rip
11:41:51FromDiscord<Phil> Well that fell flat
11:42:00FromDiscord<Phil> But not as flat as the line you tried to sneak past the compiler!
11:42:17FromDiscord<Phil> 👉 👉
11:42:31FromDiscord<piqueiras> 😭
11:43:14FromDiscord<Phil> TBH the amount of shit nim lets you get away with is kinda nuts
11:44:21FromDiscord<piqueiras> In reply to @piqueiras "would that work if": im trying to do this
11:44:39FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
11:44:49FromDiscord<piqueiras> get a seq that is actualy a slice of a column of a matrix
11:45:52FromDiscord<piqueiras> (and pointing to it as well)
11:45:59FromDiscord<Phil> No idea, I have not messed around with seqs enough to give you a response.↵Mainly because seqs have value semantics and how you convince nim that no, you indeed just want a mutable slice of that seq (which it looks like you want) is beyond me
11:46:11FromDiscord<piqueiras> cause this is doable https://media.discordapp.net/attachments/371759389889003532/1184823648167673946/image.png?ex=658d6002&is=657aeb02&hm=1553bf061090d409ead18f4ccbac97b38ce54226b734c060c65e55557ca83d6f&
11:46:13FromDiscord<Phil> It might be that you straight up aren't allowed to because that sounds super unsafe
11:46:29FromDiscord<piqueiras> In reply to @isofruit "It might be that": it can be done with a seq so
11:46:31FromDiscord<Phil> Having mutable slices of another seq I mean
11:47:00FromDiscord<Phil> In reply to @piqueiras "it can be done": Yeah but that's not slices of a seq, that's a 2D array with mutable rows
11:47:03FromDiscord<piqueiras> https://media.discordapp.net/attachments/371759389889003532/1184823865298403389/image.png?ex=658d6036&is=657aeb36&hm=fc560a4032b953598fc83d75c4275f2ad7e9f070f6be331c7a4b271059b93e28&
11:47:19FromDiscord<piqueiras> in columns it just seems kinda undoable
11:50:49FromDiscord<Phil> That really is a forum question
11:50:56FromDiscord<Phil> Because folks can take a longer time to reply to that more elaborately
11:51:25FromDiscord<piqueiras> might do
11:51:31*ehmry joined #nim
11:56:16FromDiscord<griffith1deadly> sent a code paste, see https://play.nim-lang.org/#ix=html>
11:56:24FromDiscord<griffith1deadly> (edit)
12:11:32PMunchWelp, there we have our first major hitch: https://paste.rs/ZsnQA.txt
12:16:28FromDiscord<alwaysoutofrange> is there a way to read a short from filestream? i tried using a 2 byte array but it didnt work out for me also readInt16() does not work for me either im getting the wrong number back when i try this
12:21:01PMunchCould be a big-endian vs. little-endian issue
12:21:18PMunchBoth your approaches should work fine
12:23:08FromDiscord<nnsee> In reply to @alwaysoutofrange "is there a way": what number are you getting and what number are you expecting
12:25:17PMunchHmm, anyone knows what this error means? "Error: cannot export"
12:25:23FromDiscord<piqueiras> In reply to @griffith1deadly "i think you can": huh
12:25:26PMunchIt doesn't say anything about _why_ it can't export
12:26:37PMunchHmm, seems related to the circular import thing..
12:26:58FromDiscord<kuroisatoridevs> is there a nice install script that will non-interactively install nim, nimble, atlas and niminst into the system? It's for my CI
12:28:01PMunchIs the curl script not good enough?
12:28:04FromDiscord<nnsee> In reply to @kuroisatoridevs "is there a nice": choosenim has a "use defaults" flag
12:28:18FromDiscord<nnsee> also if it's for your CI why not use a base image with them already installed
12:28:22FromDiscord<alwaysoutofrange> In reply to @nnsee "what number are you": im getting 8203 and i expect 163
12:28:23FromDiscord<kuroisatoridevs> choosenim wont install atlas and it wont install niminst.
12:29:17FromDiscord<alwaysoutofrange> everything is little endian but that should not be a problem because i read a int32 and its the right value
12:29:37FromDiscord<kuroisatoridevs> my current solution is building nim from source and using koch csource -d\:danger just to tell it to build niminst
12:29:54PMunchWhat's niminst?
12:29:57FromDiscord<nnsee> In reply to @kuroisatoridevs "choosenim wont install atlas": it will definitely install atlas
12:30:03FromDiscord<nnsee> just not create the proxyexe
12:30:16FromDiscord<nnsee> but the actual atlas binary exists in the nim dir itself
12:30:22PMunchalwaysoutofrange, are you sure you are reading at the correct position?
12:30:24FromDiscord<nnsee> i have no idea what niminst is
12:30:30FromDiscord<Chronos [She/Her]> In reply to @PMunch "What's niminst?": Probably the compiler...?
12:30:36FromDiscord<nnsee> In reply to @alwaysoutofrange "everything is little endian": that doesn't really make any sense
12:30:40FromDiscord<Chronos [She/Her]> Not sure, probably not actually
12:30:50FromDiscord<nnsee> sorry, replied to the wrong message
12:31:02FromDiscord<nnsee> i don't see any link between 163 and 8203
12:31:05FromDiscord<kuroisatoridevs> nim's csource thats needed for bootstrap is generated using niminst; it is actually a very good piece of software
12:31:10PMunchhttps://nim-lang.org/docs/niminst.html
12:31:18PMunchApparently a package to make Nim installers
12:32:01PMunchkuroisatoridevs, what? That doesn't sound right
12:32:16PMunchcsources aren't installed via an installer, it's just a repo you clone..
12:32:23FromDiscord<alwaysoutofrange> In reply to @nnsee "that doesn't really make": i think i found the problem im skipping a value
12:33:04FromDiscord<nnsee> In reply to @kuroisatoridevs "nim's csource thats needed": niminst is provided as a .nim file in the toolchains dir even when using choosenim. you can simply run it.
12:33:19*edr joined #nim
12:33:40FromDiscord<nnsee> In reply to @PMunch "csources aren't installed via": there actually is a `csource` command in `niminst`, i think that's what they're talking about
12:33:55FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#ix=html>
12:34:42FromDiscord<kuroisatoridevs> https://github.com/dom96/choosenim#choosenim cant see anything about non-interactive install
12:35:14FromDiscord<alwaysoutofrange> ye now its working
12:35:40FromDiscord<nnsee> `nim r $(< ~/.choosenim/current)/tools/niminst/niminst.nim` for running niminst in a choosenim install
12:37:50FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#ix=html>
12:43:19FromDiscord<kuroisatoridevs> sent a code paste, see https://play.nim-lang.org/#ix=html>
12:43:22FromDiscord<kuroisatoridevs> thanks
12:47:34FromDiscord<kuroisatoridevs> and to summarize it into oneliner
12:47:42FromDiscord<kuroisatoridevs> sent a code paste, see https://play.nim-lang.org/#ix=html>
12:56:57FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#ix=html>
12:58:12FromDiscord<nnsee> oh wait, it doesn't show that on matrix
12:58:16FromDiscord<nnsee> maybe a bridge issue
12:58:31FromDiscord<nnsee> looks like this to me
12:58:33FromDiscord<nnsee> https://media.discordapp.net/attachments/371759389889003532/1184841859655282688/image.png?ex=658d70f8&is=657afbf8&hm=9680e5d5ba74f5b5f71a5a3ba24c9f3992e7b418b8c01f8b351e2a8da430d5c3&
12:59:07FromDiscord<kuroisatoridevs> yes, tags are not there
12:59:21FromDiscord<kuroisatoridevs> curl https://nim-lang.org/choosenim/init.sh -sSf \| CHOOSENIM\_NO\_ANALYTICS=1 bash -s -- -y; echo "" \> $HOME/.choosenim/analytics
12:59:24FromDiscord<kuroisatoridevs> oh
12:59:46FromDiscord<kuroisatoridevs> i don't know how not to send things without tags
13:00:30FromDiscord<nnsee> maybe:
13:00:43FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#ix=html>
13:01:02FromDiscord<nnsee> && instead of ; to short circuit early if choosenim fails for some reason
13:01:17FromDiscord<nnsee> and propagate the error code
13:01:59FromDiscord<nnsee> `bash -s -- -y` is a neat trick that seems kind of obvious in hindsight, thanks
13:03:32FromDiscord<kuroisatoridevs> such things are considered unsafe, but i like it for readability in dockerfiles
13:04:19FromDiscord<nnsee> it's only unsafe if you don't trust the origin
13:05:08FromDiscord<kuroisatoridevs> it's unsafe to trust humans
13:10:31FromDiscord<Phil> Oh hey, my benchmark for threadbutler finally returns more realistic outputs
13:10:46NimEventerNew Nimble package! note - A simple pastebin, inspired by w4/bin, see https://codeberg.org/pswilde/note
13:11:02FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
13:11:46FromDiscord<nnsee> In reply to @NimEventer "New Nimble package! note": thought this might be a contender with what i'm writing, but...↵> notes are stored in a table within the runtime. No persistance is currently in place, nor required as far as I'm concerned. Effectively, all notes are lost when the binary is restarted.
13:19:02PMunchHmm, anyone bored enough to want to write a cycle checker?
13:19:48PMunchI basically have a `Table[string, HashSet[string]]` of modules and their imports. And I want to check that for every key in the table that there are no paths to itself
13:19:54PMunchNot hard, just tedious :P
13:22:05*khazakar joined #nim
14:10:18FromDiscord<kuroisatoridevs> Where can I read about nim.cfg and especially about nimscript that does the same thing? I want to use pkg-config with different flags for different targets in my project
14:12:06*jmdaemon quit (Ping timeout: 260 seconds)
14:24:06FromDiscord<deadm0th> how i can configure vim or spacevim ?
14:24:13FromDiscord<deadm0th> how can i \
14:24:36FromDiscord<Phil> PMunch, vim is your beer
14:25:43FromDiscord<Phil> In reply to @kuroisatoridevs "Where can I read": Regarding nimscript, the docs to it are actually linked in the documentation section of nim's main page 😄
14:25:56FromDiscord<nnsee> In reply to @deadm0th "how i can configure": by editing the init file
14:26:07FromDiscord<Phil> Left center https://media.discordapp.net/attachments/371759389889003532/1184863897405112400/image.png?ex=658d857e&is=657b107e&hm=d968dd4e515ff020fcced14892221a590e93b392a998eeee960c1fab10708e8d&
14:26:21FromDiscord<Phil> https://nim-lang.org/docs/nims.html
14:26:55FromDiscord<Phil> Okay I don't get it, sometimes channels just randomly blow up on me and I don't see where and how
14:40:47FromDiscord<Phil> Is there a way to get better stacktraces out of nim? Some compiler flag or sth?↵What I get is 50% wrong for example, naming procs that I define and telling me they're in the macros module etc.
14:42:51FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
15:05:19FromDiscord<kuroisatoridevs> maybe --stackTrace\:on --lineTrace\:on --opt\:none
15:07:27FromDiscord<kuroisatoridevs> the actually useful documentation was hidden in https://github.com/nim-lang/Nim/wiki/Using-nimscript-for-configuration
15:21:04FromDiscord<Phil> Nope, still incorrect stacktraces =/
15:25:55*PMunch quit (Quit: Leaving)
15:31:33FromDiscord<piqueiras> how can I init a seq of empty hashsets
15:32:53FromDiscord<piqueiras> does newSeqWith(100,toHashSet("")) work as intended 🤔
15:34:05FromDiscord<piqueiras> no it doesnt
15:35:43FromDiscord<piqueiras> newSeqWith(100,initHashSet[string]())
15:35:46FromDiscord<piqueiras> oh this does
15:39:02FromDiscord<nnsee> In reply to @piqueiras "no it doesnt": how doesn't it
15:39:04FromDiscord<nnsee> it works for me
15:39:15FromDiscord<nnsee> pretty much the exact same as initHashSet
15:49:29FromDiscord<piqueiras> i they dont seem to be string sets
15:51:49*khazakar quit (Quit: Connection closed for inactivity)
15:55:19FromDiscord<nnsee> oh, yes, `""` is a seq of chars
15:55:24FromDiscord<nnsee> i assumed that's what you wanted
15:55:26FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
15:56:31FromDiscord<nnsee> In reply to @piqueiras "i they dont seem": it would work with `toHashSet[string]([])`
15:57:04FromDiscord<nnsee> if you _really_ wanted to use toHashSet for whatever reason
16:02:30FromDiscord<piqueiras> no I dont need tohashset
17:16:48*khazakar joined #nim
17:39:33FromDiscord<jviega> Phil, templates often mess up location info. Can get the wrong file, and definitely the right file but wrong line number
17:39:47FromDiscord<jviega> Not clear when it will happen and when it won't, always
17:51:48FromDiscord<Phil> I figured out what killed me
17:52:04FromDiscord<Phil> It was benchy and interaction with somehow somewhere causing deallocations
17:52:33FromDiscord<Phil> I'm now investigating how else to do some nice little benchmarking just to make sure there's no performance degradation between system.Channels and threading/channels
17:58:28*jmdaemon joined #nim
18:09:59FromDiscord<Phil> Nope nevermind, that wasn't it either, oh god dangit man
18:10:14FromDiscord<jviega> 😦
18:20:31FromDiscord<apetransaction> anyone know how to convert a sequence of bytes to a cstring?
18:21:00FromDiscord<jviega> Is there any possibility the sequence will be empty?
18:21:05FromDiscord<apetransaction> nope
18:21:09FromDiscord<apetransaction> 0 possibility
18:21:26FromDiscord<jviega> If not, then `cast[cstring](addr s[0])` should do you fine
18:21:34FromDiscord<apetransaction> thanks
18:29:35FromDiscord<Phil> I have it! A small-ish example just based on threads on what's blowing up!
18:30:19FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
18:30:32FromDiscord<Phil> (edit) "threads" => "channels"
18:30:48FromDiscord<Phil> (edit)
18:46:20FromDiscord<kuroisatoridevs> sent a code paste, see https://play.nim-lang.org/#ix=html>
18:47:30FromDiscord<kuroisatoridevs> not sure about your code, but nim 2.0 hasn't threading/channels
19:08:18FromDiscord<apetransaction> pain
19:08:35FromDiscord<apetransaction> sent a code paste, see https://play.nim-lang.org/#ix=html>
19:11:27FromDiscord<guttural666> does the default initialization fail when I guard a field with a lock? it seems to: https://media.discordapp.net/attachments/371759389889003532/1184935703163965631/image.png?ex=658dc85e&is=657b535e&hm=45cb9e05d30edd899c7115757f160841ba727a74f9a7b7de6f4bff9b438b02c8&
19:11:46FromDiscord<guttural666> seems I have to yeet all that default stuff into my init function and change those fields with the lock to the default value↵weird, because this default initialization seems to work anyway: https://media.discordapp.net/attachments/371759389889003532/1184935780808937603/image.png?ex=658dc871&is=657b5371&hm=06fb8f004aff172e20c9b4e6f4edcd0ace853821fef017ec4fb74cdc258bdd3e&
19:12:08FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#ix=html>
19:15:30*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
19:18:32*Lord_Nightmare joined #nim
19:25:44FromDiscord<guttural666> okay, seemed to be correct, that I'd have to initialize guarded things myself with a lock and initDeque doesen't seem to do a lot vs. just declaring the thing: https://media.discordapp.net/attachments/371759389889003532/1184939295996379268/image.png?ex=658dcbb7&is=657b56b7&hm=2fc37b8eecb57ebcc33aa891b4cdebaa7889b5c57620261ef76850d42cd9e411&
19:38:57*xutaxkamay quit (Quit: ZNC 1.8.2+deb3.1 - https://znc.in)
19:40:56*xutaxkamay joined #nim
19:47:35*xutaxkamay quit (Quit: ZNC 1.8.2+deb3.1 - https://znc.in)
19:49:14*xutaxkamay joined #nim
19:52:07*azimut quit (Ping timeout: 240 seconds)
20:58:19FromDiscord<Elegantbeef> @apetransaction you can do `result[0..^1] = data` instead of that copymem
21:00:49FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:01:03FromDiscord<Elegantbeef> No you cannot
21:01:11FromDiscord<Elegantbeef> Rather should not
21:01:22FromDiscord<apetransaction> In reply to @chronos.vitaqua "You can do `result": No, casting gave me weird ass results
21:01:30FromDiscord<Elegantbeef> you can just do `@data` on top of it
21:01:39FromDiscord<Elegantbeef> No need for the silly `toSeq` template
21:01:57FromDiscord<apetransaction> I got a string of length 0 with no content but if you echo the string it prints fine
21:02:00FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Rather should not": Should not cast?
21:03:04FromDiscord<Elegantbeef> Of course not `seq[byte]` and `string` are different internally
21:03:13FromDiscord<Chronos [She/Her]> ...they are?
21:03:26FromDiscord<Chronos [She/Her]> I actually never knew that
21:03:38FromDiscord<Chronos [She/Her]> I know there are plans to do it, but not that they were different
21:03:50FromDiscord<Chronos [She/Her]> Casting has always worked for me, besides that weird edgecase on Windows-
21:04:03FromDiscord<Chronos [She/Her]> Though I don't think copyMem is much better
21:04:32FromDiscord<Elegantbeef> I mean they're ever so slightly different
21:04:42FromDiscord<Elegantbeef> Remember that strings are nil terminated and seqs are not
21:04:53FromDiscord<Elegantbeef> so `cast[string]` means you have a non nil terminated string
21:05:04FromDiscord<Elegantbeef> Which means if you attempt to use it for any `cstring` operations it'll explode
21:05:44FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Remember that strings are": Nim strings aren't nil terminated, though?
21:05:48FromDiscord<Chronos [She/Her]> I thought they weren't?
21:05:51FromDiscord<Elegantbeef> Yes they are
21:05:57FromDiscord<Chronos [She/Her]> And that's why you had to do `myStr.cstring`?
21:05:58FromDiscord<Elegantbeef> They're pascal strings but also nil terminated
21:06:01FromDiscord<Elegantbeef> For 0 cost C interop
21:06:02FromDiscord<Chronos [She/Her]> ...huh
21:06:13FromDiscord<Elegantbeef> Almost all modern strings are nil terminated
21:06:22FromDiscord<Chronos [She/Her]> Purely for interop?
21:06:36FromDiscord<Elegantbeef> The reason you explicitly should do ` cstring myStr` is to clearly ensure that you do not make a cstring outlive the string
21:06:40FromDiscord<Elegantbeef> Yes purely for interop
21:06:48FromDiscord<Chronos [She/Her]> So even now, we have to deal with the curse of C 😔
21:06:53FromDiscord<Elegantbeef> You can pass it to a procedure expecting a pascal string or a nil terminated string without any overhead
21:06:57FromDiscord<Chronos [She/Her]> But that's actually useful information :P
21:06:59FromDiscord<Elegantbeef> No we do not have to deal with the curse of C
21:07:07FromDiscord<Elegantbeef> Since the length is saved and it's O(1)
21:07:14FromDiscord<Chronos [She/Her]> Yeah makes sense
21:07:21FromDiscord<Elegantbeef> It always just adds a `\0` so you can send it to anywhere
21:08:52FromDiscord<Elegantbeef> @Phil you do realise your code almost instantly eats up 100% of memory right?
21:09:19FromDiscord<Elegantbeef> Atleast with 16gb it allocates so much so quickly I cannot reliably say how much memory it eats
21:09:32FromDiscord<Elegantbeef> But it does get to 80% by the time it crashes
21:10:11FromDiscord<Elegantbeef> I'm also uncertain why you use a `ref object` for your container
21:11:03FromDiscord<Phil> In reply to @Elegantbeef "I'm also uncertain why": Honestly just because of my mental model:↵There should only be one, ever
21:11:30FromDiscord<Phil> That gets passed around and needs to be accessible in every thread
21:11:47FromDiscord<Elegantbeef> Right but there is no reason for it to be heap allocated
21:11:57FromDiscord<Elegantbeef> You have two pointer indirection presently
21:12:06FromDiscord<Phil> In reply to @Elegantbeef "<@180601887916163073> you do realise": And no I did not, my memory tracker in the upper right corner:↵Never even registered the deallocation https://media.discordapp.net/attachments/371759389889003532/1184966062253551736/image.png?ex=658de4a4&is=657b6fa4&hm=e1d072dfa54b253e9722213866cd63b25e97fc0eed48e43a07a5534a002385b4&
21:12:15FromDiscord<Phil> (edit) "deallocation" => "memory consumption"
21:12:39FromDiscord<Phil> But how?↵I'm not even sending anything that large
21:12:53FromDiscord<Elegantbeef> For the container just disable `=copy` and `=dup`
21:13:06FromDiscord<Elegantbeef> Now you have only ever one alive
21:13:15FromDiscord<Elegantbeef> I mean on my machine it spikes up to 100% and then crashes
21:13:55FromDiscord<Phil> I mean, what, a single message is one seq of 500 numbers, that's 8 bytes per number 500 = 4000 Byte = 4 KB.↵Now I send 100 messages, that's 400KB.↵↵How many fucking copies is it doing to spike to 16GB
21:14:16FromDiscord<Phil> 500 because I adjusted the value to see how low I could go to make it run again
21:15:48FromDiscord<Elegantbeef> `routeMessage` does not take a `sink BackendMessage`
21:15:55FromDiscord<Elegantbeef> That's one copy
21:16:22FromDiscord<Elegantbeef> Fixes it
21:17:02FromDiscord<Elegantbeef> Now it only ever uses 0.6% memory
21:17:42FromDiscord<Elegantbeef> With 10000 ints
21:18:38FromDiscord<Phil> HOW?!↵I mean, I get that saves a copy, but 15 GB worth?!
21:18:54FromDiscord<Elegantbeef> Might be an arc bug 😄
21:18:56FromDiscord<Phil> I may be overreacting because this may have cost me 8h by now
21:19:02FromDiscord<Elegantbeef> `--expandArc:routeMessage`
21:19:20FromDiscord<Phil> expandArc?
21:19:39FromDiscord<Elegantbeef> It expands the injected hooks inside of procedures
21:20:11FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:20:49FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
21:20:52FromDiscord<Phil> I... can't really read this well
21:20:56FromDiscord<Elegantbeef> Nope it frees `msg` so uhhh
21:21:14FromDiscord<Elegantbeef> It just shows you the IR and where the hooks are placed
21:21:51FromDiscord<Elegantbeef> In the first example it shows that it copies the `msg` then isolates it
21:21:58FromDiscord<graveflo> maybe this is just another example of how "free" and os level mem allocation are not the same thing
21:22:01FromDiscord<griffith1deadly> for objects that take up little memory space and are small in size (string + 4 bytes), is it better to use object or ref object?
21:22:11FromDiscord<Phil> object
21:22:12FromDiscord<Elegantbeef> It does not matter the size
21:22:15FromDiscord<Elegantbeef> It matters what you're doing
21:23:00FromDiscord<Phil> I mean, isn't it basically "If you got to ask, then object"?↵ref object is sth I only turn to when I really need it to match my memory model
21:23:07FromDiscord<Phil> (edit) "memory" => "mental"
21:23:11FromDiscord<griffith1deadly> In reply to @Elegantbeef "It does not matter": protocol buffer for reading data from socket's
21:23:23FromDiscord<Elegantbeef> Ok phil the issue is 100% Nim's allocator not returning resources
21:23:36FromDiscord<Elegantbeef> Running with `-d:useMalloc` it's rock solid without `sink`
21:23:57FromDiscord<Phil> Wait, so I should change my nim-issue I opened for this to be about nim's allocator?
21:24:04FromDiscord<Elegantbeef> Probably
21:24:05FromDiscord<Phil> That's the first time I found a bug this fundamental so not quite sure
21:24:20FromDiscord<Elegantbeef> Given it happens only with Nim's allocator
21:24:20FromDiscord<Phil> https://github.com/nim-lang/Nim/issues/23078↵The issue in question
21:24:31FromDiscord<graveflo> yea you should post info about this stuff for sure
21:24:32FromDiscord<Elegantbeef> At this point phil you should just wait for me to look at your code 😄
21:25:01FromDiscord<graveflo> This really does remind me about another issue that happened though. Where memory appears to not be released to the OS in come situations
21:25:10FromDiscord<Elegantbeef> It's certainly a Nim allocator bug
21:25:16FromDiscord<griffith1deadly> In reply to @isofruit "Wait, so I should": there's already an open issue about it (allocator don't return memory to os)
21:25:29FromDiscord<graveflo> bc the OS doesn't necessarily have to take the mem back right away
21:25:42FromDiscord<Elegantbeef> > protocol buffer for reading data from socket's↵So what you're saying is that you do not have multiple views into a single value, so you do not need to use a `ref`
21:25:44FromDiscord<Elegantbeef> 😄
21:25:54FromDiscord<Elegantbeef> Well grave this is the allocator not even reusing it's owned memory blocks
21:26:00FromDiscord<Elegantbeef> Which indicates a showstopper bug if you ask me
21:26:01FromDiscord<Phil> In reply to @griffith1deadly "there's already an open": Trying to find it, where?
21:26:31FromDiscord<Elegantbeef> Like at 16GBs of usage you're telling me the allocator cannot find a place to plop down 10000 ints
21:26:39FromDiscord<Elegantbeef> If that's the case I hate to see how fragmented the blocks are 😄
21:26:49FromDiscord<Phil> I'm happy to link to it and more but I'd need to find the issue first
21:26:55FromDiscord<griffith1deadly> In reply to @isofruit "Trying to find it,": https://github.com/nim-lang/Nim/issues/22510
21:27:26FromDiscord<griffith1deadly> In reply to @Elegantbeef "> protocol buffer for": thanks!
21:28:12FromDiscord<Elegantbeef> References with Nim2.0 are only beneficial for large data types you wish to be able to move(think array[1000, int]), or multiple views
21:28:26FromDiscord<Elegantbeef> Otherwise it's just an introduction of the billion dollar mistake and you should stop it
21:28:55FromDiscord<Elegantbeef> But even for large data types i'd probably do `type MyType = distinct ref array[1000, int]` so I can define my own hooks
21:30:02FromDiscord<griffith1deadly> In reply to @Elegantbeef "References with Nim2.0 are": because it storage at heap?
21:30:30FromDiscord<Elegantbeef> Right by using heap you can actually give up ownership of resources
21:30:53FromDiscord<Elegantbeef> `sink` does not work for value types for relatively obvious reasons
21:31:31FromDiscord<Elegantbeef> If they're not obvious, it's cause you cannot give up ownership of a field regardless where the memory is safely, it's apart of the parent type always
21:33:21FromDiscord<Phil> In reply to @griffith1deadly "https://github.com/nim-lang/Nim/issues/22510": Should I @ you in the issue (given you may be interested in this), if so what's your github?
21:40:01FromDiscord<Phil> Okay, that means I need to adjust some code generation to make that a sink (which I'd want just so this unversally works and I don't have to tell users that they must use -d:useMalloc)
21:41:00FromDiscord<Elegantbeef> @Phil Am I going to get mentioned by name twice in a single comment again?! 😛
21:41:02FromDiscord<Elegantbeef> You can go for all 3 names, my github handle, my real name, my matrix name
21:41:09FromDiscord<Elegantbeef> Just keep adding names until I stop helping you
21:41:27FromDiscord<Phil> twice? I ping you once that's it
21:41:54FromDiscord<Phil> There only be one beef in that issue comment xP
21:43:56FromDiscord<Phil> In reply to @Elegantbeef "Just keep adding names": Next are nicknames
21:43:56FromDiscord<Phil> "beefy"
21:44:00FromDiscord<Phil> "bigbeef"
21:44:03FromDiscord<Phil> "beefy boy"
21:54:27FromDiscord<Phil> In reply to @Elegantbeef "For the container just": Actually, how do I do that? Just write my own and have them be empty?
22:00:27FromDiscord<Elegantbeef> @Phil write the header but add the error pragma `proc =dup(a: T): T {.error.}`
22:00:47FromDiscord<Elegantbeef> This will error whenever you call it statically so you know when a dup/copy is being desired
22:01:20FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:03:28FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:04:11FromDiscord<Phil> Ohh right, yeah the problem there is with ChannelHub for assigning stuff the hub suddenly needs to be a var every time
22:04:21FromDiscord<Elegantbeef> Oh noes
22:04:39FromDiscord<Phil> Which is... really easy, nevermind
22:04:56FromDiscord<Phil> I had to change like 2 procs
22:05:13FromDiscord<Phil> Correction, 1 proc
22:06:14FromDiscord<Elegantbeef> Damn unfathomable
22:06:34FromDiscord<Elegantbeef> One day Phil will either yell at me due to my sass, or not talk to me
22:07:01FromDiscord<Phil> Why would I? It makes my code better
22:07:08FromDiscord<bostonboston> I think
22:07:12FromDiscord<bostonboston> Unthinkable
22:07:22FromDiscord<Elegantbeef> It's sass
22:07:42FromDiscord<Phil> In reply to @bostonboston "Unthinkable*": You tried to spell it right and that's what matters
22:07:48FromDiscord<Phil> Even if attempt number 2 still is wrong
22:08:11FromDiscord<Elegantbeef> Wait what are we correcting?
22:08:29FromDiscord<bostonboston> I'm correcting myself
22:08:30FromDiscord<Phil> Nothing, I'm teasing him for the extra star at the end because I'm bored and terrified to go back to my benchmark example
22:08:33FromDiscord<bostonboston> Did I do it wrong twice
22:08:39FromDiscord<bostonboston> Ah
22:08:54FromDiscord<Elegantbeef> I'm confused
22:08:58FromDiscord<Phil> Because it will blow up on me again in strange ways
22:09:12FromDiscord<bostonboston> I stopped editing my messages in this discord cause someone told me it looks bad through the bridge
22:09:42FromDiscord<Phil> It does to irc and that is indeed correct
22:09:47FromDiscord<Phil> However, I'M a terrible person
22:09:52FromDiscord<Phil> (edit) "I'M" => "I'm"
22:09:59FromDiscord<Elegantbeef> Lol
22:10:02FromDiscord<Phil> Which is why I literally can't stop myself
22:10:07FromDiscord<Elegantbeef> I just send code blocks with nothing
22:11:35FromDiscord<Phil> Now that you mentioned it I can actually add sink to a fair amount of procs
22:11:44FromDiscord<Phil> Like my sendMessage proc etc. all of those can be sinks
22:11:55FromDiscord<Elegantbeef> Move semantics is the future
22:12:02FromDiscord<Elegantbeef> Now if `--sinkInference:on` didnt explode
22:14:46*xet7 quit (Remote host closed the connection)
22:17:20FromDiscord<Phil> ... am I a magician? Apparently I now manage to run into alloc issues even with sink everywhere
22:17:34FromDiscord<Phil> Not in the example posted, more in my own benchmark that I derived the example code from
22:17:49FromDiscord<Elegantbeef> Does it go away with `-d:useMalloc` 😄
22:17:55FromDiscord<Phil> Yeah
22:19:01FromDiscord<Phil> Not a memory crash issue though for sure, I looked at another memory tool that measures every 500ms and that noticed no memory spike
22:19:58FromDiscord<graveflo> wait, I thought there was an issue though
22:21:16FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:21:29FromDiscord<Phil> I thought that fixing the latter would fix the former - it didn't
22:21:39FromDiscord<Phil> Turns out that -d:useMalloc fixes both though
22:24:41FromDiscord<Phil> Also yay, my documentation PR to threading/channels was accepted, it got docs now!
22:24:53FromDiscord<Elegantbeef> Congrats!
22:32:00FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=html>
22:41:11FromDiscord<Phil> Huh I might not have a memory leak in Threadbutler
22:41:22FromDiscord<Phil> That... for me that is kind of nuts, particularly given I do some pointer magic here and there
22:42:02FromDiscord<Phil> But after sending `2_100_000` through my stress test so far and seeing no change in memory usage that's kind of inspiring
22:43:01FromDiscord<Phil> In reply to @Elegantbeef "Congrats!": Also: Thanks!
22:52:46*xet7 joined #nim
23:13:15*advesperacit quit ()
23:17:45*xet7 quit (Remote host closed the connection)
23:33:43*azimut joined #nim
23:57:41*mahlon quit (Read error: Connection reset by peer)