<< 13-12-2020 >>

00:02:07disruptekquibono: did you look at openapi?
00:02:11disruptek!repo openapi
00:02:12disbothttps://github.com/disruptek/openapi -- 9openapi: 11OpenAPI Code Generator for Nim 15 35⭐ 2🍴 7& 5 more...
00:02:57FromDiscord<Quibono> No I didn’t.
00:05:47disrupteki'm taking donations for a xmas gift for our bdfl.
00:06:58FromDiscord<Beckingham> yeah so that document tag is hardcoded into the htmlparser package
00:07:02FromDiscord<Rebel> bdfl?
00:07:09FromDiscord<Beckingham> benevolent dictator for life
00:07:34FromDiscord<Rebel> oh
00:07:46FromDiscord<Rebel> you would probably share the same fate as Mussolini πŸ˜…
00:08:04FromDiscord<Beckingham> @Araq I hope you're reading this ^
00:08:05FromDiscord<Beckingham> Haha
00:08:30FromDiscord<Beckingham> yeah so how are you supposed to use that htmlparser library if it sticks <document> into everything it parses?
00:09:35FromDiscord<Rebel> huh
00:09:37FromDiscord<Rebel> that's a yikes
00:09:41FromDiscord<Rebel> could always go for plan B
00:09:44FromDiscord<Rebel> and use fancy regex
00:10:16disrupteki dunno, that tropico guy has been around for years.
00:10:29disrupteksome people can make it work. others are trumps.
00:11:51FromDiscord<Beckingham> I am a trump then
00:38:33*Jesin quit (Quit: Leaving)
00:40:11*Jesin joined #nim
00:44:01*Jjp137_ quit (Read error: Connection reset by peer)
00:46:20FromDiscord<19> is it possible to call a function defined in module A from module B without importing A into B?
00:46:30*leorize quit (Remote host closed the connection)
00:47:13*leorize joined #nim
00:47:20FromDiscord<Revenant> yo
00:48:03FromDiscord<Quibono> Lo?
00:48:05FromDiscord<Revenant> i've been searching for a json library this morning that can serialize/deserialize arbitraty objects with the possibility of defining your own custom serializers for certain types
00:48:25FromDiscord<Revenant> but couldn't really find any, any suggestions?
00:48:35FromDiscord<Revenant> this came close, but it cannot deserialize...
00:48:36FromDiscord<Revenant> https://github.com/disruptek/jason
00:49:33disruptekuse planetis[m]'s library; it should absorb jason eventually (or vice-versa if he's too lazy).
00:50:21disruptek!repo neminim
00:50:21disruptek!repo niminem
00:50:22disbotno results 😒
00:50:22disbotno results 😒
00:50:40FromDiscord<Revenant> cheers, having a look
00:51:02FromDiscord<Revenant> i'm just used to the abundance of json libraries in JVM land, there's literally shitloads of them...
00:51:07disrupteksomething like that.
00:51:13*Jjp137 joined #nim
00:51:16disruptekthere are too many, here, too.
00:51:38disruptektreeform made one recently, too.
00:51:46FromDiscord<Revenant> well yeah, just most seemed abandoned or not fit for purpose πŸ™‚
00:52:51disruptekjason is really just for use in an openapi rest shim. it was a proof-of-concept for frosty.
00:53:02disruptekand it'll be improved once concepts are sorted.
00:53:57FromDiscord<Revenant> eminim looks okay, i'll give it a go
00:54:28disruptekit should be pretty decent. let me know what the performance is like.
00:54:34FromDiscord<Revenant> i wrote something with cfgparse + some custom macros that does the job... then i realised, this is actually a solved problem to encode/decode from objects graphs with some custom type mappers...
00:55:01FromDiscord<Revenant> performance will be a non issue, i'm just using this thing to store configs for a desktop app
00:55:24FromDiscord<Revenant> few hundred lines at most, loaded at startup
00:55:40disruptekah, then why use json? you need it to work with other stuff?
00:56:26FromDiscord<Revenant> well, because json is hierarchical, i don't want use binary for configs either
00:56:32FromDiscord<Revenant> at least people can edit by hand, you can diff them, etc
00:57:03disrupteki mean, they're not great for that.
00:57:08FromDiscord<Revenant> like what else is there: json, ini, yaml, or your custom format which is pointless
00:57:12FromDiscord<ElegantBeef> Toml
00:57:26FromDiscord<j-james> toml is very nice
00:58:03FromDiscord<Revenant> yeah that looks nice, wasn't aware of it
00:58:13FromDiscord<Revenant> nice is i don't have to write an encoder/decoder myself πŸ˜›
00:58:18FromDiscord<Revenant> (edit) "is" => "if"
00:58:20disruptekyeah, we have a few other formats i would choose first.
00:58:20disrupteknim's cfg or nimscript would be a consideration, too.
00:58:54disrupteki plan to impl nestedtexts eventually.
00:59:01FromDiscord<Revenant> i'll show you a snippet
00:59:34FromDiscord<j-james> you could also go the "suckless" route
00:59:48disrupteki couldn't make toml work for nimph, for some reason. but others here say it works well for them.
00:59:48FromDiscord<Revenant> this works, but it's a bit primitive
00:59:48FromDiscord<j-james> define some consts and make everyone recompile
00:59:57FromDiscord<Revenant> sent a code paste, see https://play.nim-lang.org/#ix=2HMh
01:00:13FromDiscord<Revenant> see, colors are encoded as strings, but probably i'd do it the same way with json, just store them in a string
01:00:24FromDiscord<ElegantBeef> Well with nimscript you can store them as colours πŸ˜›
01:00:24FromDiscord<Revenant> but we could use some extra nesting levels, which is not possible in ini
01:01:34FromDiscord<Revenant> @j-james i'm not expecting the users of this app to be programmers πŸ™‚
01:02:07FromDiscord<Revenant> yeah i'll look into nimscript, never used it before so it wasn't even a consideration
01:02:14FromDiscord<Revenant> good tip
01:02:42FromDiscord<Revenant> yeah so it only has to work with my app, that's it
01:02:44FromDiscord<ElegantBeef> https://github.com/beef331/moe if you want to see how it works
01:03:01FromDiscord<ElegantBeef> That relies on my nimscripter library
01:03:35FromDiscord<j-james> i know, i was joking πŸ˜›
01:03:43FromDiscord<j-james> !repo toml_serialization
01:03:44disbothttps://github.com/status-im/nim-toml-serialization -- 9nim-toml-serialization: 11Flexible TOML serialization [not] relying on run-time type information. 15 7⭐ 0🍴
01:03:59FromDiscord<j-james> that's one toml library i'm aware of
01:07:07FromDiscord<Revenant> it's not quite clear to me whether that supports custom types
01:07:36FromDiscord<Revenant> i think not
01:08:16FromDiscord<ElegantBeef> Nimscript supports all nim types πŸ˜›
01:09:03FromDiscord<Revenant> hmm, maybe it does
01:09:03FromDiscord<Revenant> https://github.com/status-im/nim-toml-serialization/blob/master/tests/test_decoder.nim#L45-L55
01:20:15*krux02 quit (Remote host closed the connection)
01:27:32FromGitter<awr1> hello all
01:31:09FromGitter<awr1> was talking about rust and zero cost FP-ish things with some friends of mine, I guess my general issue is that the nim stdlib copies way too much
01:33:36FromGitter<awr1> zero-functional provides some nice utilities if you're looking for using higher orders because sequtils just copies for everything
01:33:59FromDiscord<ElegantBeef> Hey i've got a iterator that uses lent πŸ˜›
01:34:03FromDiscord<ElegantBeef> It's only a pr though
01:34:48FromGitter<awr1> strutils, though...strutils copies for p much everything
01:49:16mipriit gives you strings back, yeah, which are value types, so they have to be copies. The experimental section of the manual lays out view types, which still have serious bugs but are somehigh high priority. The experimental viewtypes are important for making it first class, but for limited uses you can still .toOpenArray to get Rust's &str
01:49:56mipricasual, non-addictive use of Rust still has a huge effect on the brain's concern for copying, though.
01:51:35FromGitter<awr1> Yes, copying sometimes is not categorically *bad* in itself. But I think a lot of people dive into Nim using strutils without quite being aware of what's going on
01:52:00*xet7_ is now known as xet7
01:53:04mipriI think that's definitely the case. Nim works like C++ while having the ergonomics of a scripting language. Rather than surprising behavior (why is this getting mutated?! ... oh, I need to use deepcopy), you can get surprising performance (why isn't this faster?! oh, if I pass this arg directly instead of let'ing it, it skips the copy)
01:53:15*xet7 quit (Quit: Leaving)
01:53:40*xet7 joined #nim
01:54:13mipriI don't think trading strutils in wholesale for the surprising behavior option would be an upgrade. Though I'm still looking forward to viewtypes.
01:54:35FromGitter<awr1> right now, if anything takes in a seq[T] or string or w/e, and returns one in some FP-ish manner for the sake of purity, I'm typically like "yup, that's a copy" which, y'know, I'd like to have to think about that less
01:55:08miprisee, that's the casual use of Rust
01:55:11FromDiscord<Revenant> using mutation should be an optimisation step, default should be the current behaviour
01:55:18FromDiscord<Revenant> most of the time you just don't care
01:55:48FromGitter<awr1> actually more my C++ brain, I don't use Rust that often, but yes
02:05:05FromDiscord<Rebel> packedjson vs jason? Thinking of replacing default module for a fun modular codebase that will have working threading in it one day
02:05:06mipriheh, the very next conversation I walk into is someone not liking Julia because it also copies all the time when slicing arrays. This as the default behavior is hated even though Julia already has views as an option.
02:06:03miprifrom an APL perspective it's y'all reference semantic array languages that are weird, though...
02:08:48mipriin Nim though would I would expect is an initial borrow to get the view, and then the remainder of the code looks like normal sequtils stuff but it's all non-copying now because of the types involved. It sounds like Julia has view ops rather than types, so slicing a view the normal way will give you a copy.
02:09:15*jxy quit (Quit: leaving)
02:09:35*jxy joined #nim
02:11:54FromDiscord<ElegantBeef> Yea i was thinking something like `^[0..1]` would return a openArray instead of a new seq
02:12:01FromDiscord<ElegantBeef> `^` indicating it's a "pointer"
02:12:38FromDiscord<Hel> hey guys
02:12:52FromDiscord<Hel> so i found this random weird thread on the nim forum
02:12:55FromDiscord<Hel> https://forum.nim-lang.org/t/7200
02:13:08FromDiscord<Hel> what is this
02:13:30FromDiscord<Hel> some bot posting weird stuff and thread got deleted?
02:14:51miprithat's just a convenient .toOpenArray, but after that [0..1] on the openArray will give you another openArray, which I think is preferable to it giving you a copy because you "should have used ^[0..1]"
02:14:58mipriyeah it's spam that got deleted.
02:15:03FromDiscord<Rika> Not deleted, not accepted to be shown
02:15:16FromDiscord<Hel> ah
02:15:19miprisays under the title, Moderated, not visible.
02:15:22FromDiscord<Rika> I mean it isn't deleted, it's not...
02:15:44FromDiscord<Hel> nim team covering up drug trafficking
02:15:55FromDiscord<Rika> All posts start moderated
02:16:13mipriif you found that from a search engine hit, it'd be a good thing to actually delete anyway.
02:16:50miprithe idea might've been to not delete it so that spammers are slower to learn the system and find an effective way to spam
02:16:54FromDiscord<Hel> nah i just changed a valid thread's number to a random (aka this one)
02:17:18mipriwell now that you've linked it in a logged channel it way show up in search engines :/
02:17:25FromDiscord<Hel> oh
02:17:29FromDiscord<Hel> sorry
02:17:59miprinah, it's funny. anyway the "2.0 in "web 2.0" stands for the administrative cost multiplier to running a website.
02:18:22mipriif you put up anything users can modify and don't pay the administrative cost, it just turns into spam like this.
02:19:08mipriI guess it would've been bad marketing to be clear about this but you should expect it :)
02:19:58FromDiscord<Hel> ah
02:23:34FromDiscord<ElegantBeef> Yea mipri i agree that for the most part views should be used
02:26:56FromDiscord<ElegantBeef> But like i said before something as simple `refSlice(1..2)` or similar for an iterator would be nice
02:27:58FromDiscord<ElegantBeef> Hence this shitty PR πŸ˜„
02:28:00FromDiscord<ElegantBeef> https://github.com/nim-lang/Nim/pull/16327
02:28:01disbotβž₯ Added `refSlice` and `mRefSlice` which sensibly iterates openArray slices.
02:29:19mipriwhat I'm saying is that you should get a view and then the rest of your code doesn't copy, rather than have lots of non-copying operations, because in the latter case your code is polluted with them and you have to write multiple versions to get/avoid copying, and in this case the library default of copying means that avoiding copies is still a huge hassle.
02:32:11FromDiscord<ElegantBeef> Yea, and the current methods are less than descriptive
02:32:22FromDiscord<ElegantBeef> `toOpenArray` is very obscure imo
02:32:26mipriso, somearray.view[1..5].items rather than somearray.refSlice(1, 5)
02:33:38FromDiscord<ElegantBeef> Yea that's clearly better
02:33:40miprithere are still a lot of bugs in view types, and a lot of limitations if you try to use openArrays without turning on the experimental feature
02:34:08mipribut after they're solid maybe something like .view would work better
02:34:20mipriwhich is just .toOpenArray(0, somearray.len)
02:38:14FromDiscord<Revenant> hmm, so nim-toml-serialization is not bad, but it insists on encoding enums with their ordinal value, which sucks for readability. sadly there's no option to persist them with their displayable names as strings...
02:52:56FromDiscord<ElegantBeef> @Revenant for what you want i do highly suggesting checking out this part of that moe fork https://github.com/beef331/moe/blob/develop/src/moepkg/settings.nim#L1936
02:53:37FromDiscord<ElegantBeef> Those macros are just to automate the settings generation since there are some issues from dependancies
02:54:01FromDiscord<Revenant> checking
02:54:16FromDiscord<ElegantBeef> Rather the way they do `colour` makes it pretty much impossible to interop easily afaik
02:55:21FromDiscord<ElegantBeef> The end result is this bottom is the nimscript file https://media.discordapp.net/attachments/371759389889003532/787512958388797450/98611805-edd96280-22af-11eb-8d5b-47e5ad16c3eb.png
02:57:31FromDiscord<ElegantBeef> you could probably even have `proc 'property='`
02:57:37FromDiscord<Revenant> yeah that's cool but still a lot of custom code
02:57:41FromDiscord<ElegantBeef> It's really not
02:57:56FromDiscord<ElegantBeef> The only reason those macros exist is cause of the way they do colours
02:58:25FromDiscord<ElegantBeef> for a normal enum it's just as simple as having a wrapped `setColor` and exposing your enums
02:58:40FromDiscord<Revenant> i mean my ini based solution works, i just had to write some macros. so i thought i'd ditch the whole thing and just something like a json library or whatever. i guess i'm not interested in non-drop in solutions, i'll just keep what i have then and that's it.
02:58:42FromDiscord<Revenant> btw this is what i have
02:58:44FromDiscord<ElegantBeef> Exposing an enum is as simple as `exportCode:` πŸ˜„
02:59:06FromDiscord<Revenant> this is the definition of the theme strucure
02:59:07FromDiscord<Revenant> https://github.com/johnnovak/gridmonger/blob/master/src/theme.nim
02:59:15FromDiscord<Revenant> (edit) "https://github.com/johnnovak/gridmonger/blob/master/src/theme.nim" => "https://github.com/johnnovak/gridmonger/blob/master/src/themedef.nim"
02:59:56FromDiscord<Revenant> these are the macros
02:59:57FromDiscord<Revenant> https://github.com/johnnovak/gridmonger/blob/master/src/theme.nim
03:00:17FromDiscord<Revenant> then some config helpers for parsecfg
03:00:18FromDiscord<Revenant> https://github.com/johnnovak/gridmonger/blob/master/src/cfghelper.nim
03:00:25FromDiscord<Revenant> hmm, actually it's a lot of code too πŸ˜„ but it works
03:09:02FromDiscord<Revenant> ah you're actually using parsetoml, not the status one...
03:36:30disruptekjason doesn't have deserialization yet, but it will probably use eminem or whatever if the performance is okay.
03:37:08disrupteki would use json for your application.
03:37:28disruptekdoesn't seem like there's a good reason to worry about performance.
03:39:22FromDiscord<acek7> disruptek
03:45:01*vicfred quit (Quit: Leaving)
03:51:11disruptekwut
03:57:41*waleee-cl quit (Quit: Connection closed for inactivity)
04:02:27FromDiscord<m0nsta> disruptek
04:04:33*spiderstew_ joined #nim
04:04:42FromDiscord<Rika> disruptek
04:05:08*spiderstew quit (Ping timeout: 260 seconds)
04:06:01*supakeen quit (Quit: WeeChat 2.9)
04:06:33*supakeen joined #nim
04:16:21*thomasross quit (Ping timeout: 256 seconds)
04:31:27FromDiscord<ElegantBeef> @Revenant who is you?
04:31:38FromDiscord<ElegantBeef> That moe fork is just an implementation of nimscript on moe
04:31:41FromDiscord<Rebel> disruptek? πŸ˜›
04:32:06FromDiscord<Rebel> is it time to put an end to this senseless suffering? πŸ€”
04:32:25FromDiscord<Revenant> what do you mean? πŸ™‚
04:32:57FromDiscord<ElegantBeef> I didnt make Moe, i just forked it and added nimscript configuration, it uses parse toml, i didnt do anything with it
04:33:25FromDiscord<Revenant> yeah i get that, i was confused about the "who is you" part πŸ™‚
04:33:36FromDiscord<ElegantBeef> "ah you're actually using parsetoml, not the status one..."
04:49:27*narimiran joined #nim
05:25:15FromGitter<awr1> I still havent played around with view types yet
05:30:53*pbb_ joined #nim
05:33:25*pbb quit (Ping timeout: 272 seconds)
05:36:21FromDiscord<ElegantBeef> They're fun
05:55:42*astronavt quit (Quit: ...)
05:56:16*MightyJoe joined #nim
05:58:08*cyraxjoe quit (Ping timeout: 256 seconds)
06:06:38*Tanger quit (Quit: Leaving)
06:14:49*a_chou joined #nim
06:15:26lainwhat's the simplest / most idiomatic way to convert between a string and an enum in nim? (both ways)
06:15:42mipri$enum, parseEnum[Enum](str)
06:16:22lainoh I somehow missed parseEnum[](), thanks! :3
06:22:43*Cthalupa quit (Ping timeout: 256 seconds)
06:24:44*Cthalupa joined #nim
06:25:05*a_chou quit (Remote host closed the connection)
06:31:04*habamax joined #nim
06:35:06FromDiscord<sealmove> guys, is `bitand` from `bitops` module more performance than system's `and` operator?
06:35:56FromDiscord<sealmove> should be exactly the same, right?
06:40:29miprithey're not exactly the same, but they map to the same magic of BitandI
06:40:48mipribitops uses a func and proc uses a proc with noSideEffect
06:41:01mipri*and system uses
06:41:18mipricompare lib/system/arithmetics.nim and lib/pure/bitops.nim
06:44:13FromGitter<awr1> bitand should use the bitwise and instruction
06:45:05FromGitter<awr1> in terms of impl, I added a thing a while back that enabled varargs support for bitand, bitor, and bitxor
06:45:51FromGitter<awr1> but in all reality this difference should be almost meaningless once the C compiler does its thing
06:53:03FromDiscord<impbox> hmm using `if x is Foo:` when you should be using `if x of Foo:` should probably raise an error/warning, when x is a variable and Foo is a type, does `x is Foo` ever make sense?
06:54:32mipriI've put it in asserts.
06:55:19leorizeprobably issue a misuse warning in runtime context
06:55:27FromDiscord<ElegantBeef> isnt `when a is B` common?
06:55:37leorizewe already have those for other stuff I think, so adding this shouldn't be hard
06:56:35FromDiscord<ElegantBeef> I missed the `if`
06:56:43*Cthalupa quit (Ping timeout: 256 seconds)
06:56:44FromDiscord<ElegantBeef> I'm not bad at reading, you are
06:57:14FromDiscord<impbox> alternatively, maybe `is` should act as `of` in this case
06:57:57miprimaking the language more complex because you made a mistake is just going to result in more mistakes.
06:59:45FromDiscord<impbox> indeed
07:00:42*Cthalupa joined #nim
07:46:31*nyaayaya quit (Remote host closed the connection)
07:52:16FromDiscord<acek7> is disruptek around i keep getting busy and missing him lol
07:53:55FromDiscord<ElegantBeef> He's back
07:55:59FromDiscord<acek7> he mentioned helping with web design
07:56:04FromDiscord<acek7> for the nim sites
07:56:09FromDiscord<acek7> or something
07:58:59*mika_ joined #nim
08:03:26*mika_ quit (Ping timeout: 256 seconds)
08:21:41*mbomba joined #nim
08:28:45*Vladar joined #nim
08:29:50Zevvdamn i lack crucial insight
08:30:00Zevvstory of my life i guess
08:30:04FromDiscord<sealmove> hex float literals are not supported right?
08:30:39miprithey are supported
08:30:43Zevvwell, they exist
08:30:47Zevvbut who is supporting them
08:30:55mipri>Floating-point literals may also be in binary, octal or hexadecimal notation
08:31:13mipri!eval 0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64
08:31:15NimBotCompile failed: /usercode/in.nim(1, 1) Error: expression '0b0100011101000000101001000111101011101111111011000101001101001001'f64' is of type 'float64' and has to be used (or discarded)
08:31:30mipri!eval echo 0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64
08:31:32NimBot1.7282561e+35
08:31:33FromDiscord<sealmove> oh sweat! does this mean equality will work?
08:31:50FromDiscord<sealmove> !eval echo 0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64 == 0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64
08:31:52NimBottrue
08:32:23FromDiscord<sealmove> neat way to avoid "almost equal"
08:32:51miprihow the notation change how == works?
08:34:32FromDiscord<sealmove> you specify the exact bytes, precision is lost because of notation, no?
08:35:00FromDiscord<sealmove> i think I am right, am I right? lol
08:35:41FromDiscord<ElegantBeef> Well you're telling it what it is, so
08:40:56*Cthalupa quit (Ping timeout: 240 seconds)
08:44:21*Cthalupa joined #nim
08:50:32FromDiscord<Rika> Precision isn't lost, it's more like exact value is estimated from the literal
08:56:57FromDiscord<sealmove> does writing a null-terminating string into a StringStream make sense?
08:57:43FromDiscord<ElegantBeef> It's going to cause an error if you have more data after it
08:58:03mipriI would expect that to not be the case. it's a string stream, not a cstring stream
08:58:05FromDiscord<sealmove> ouch. so if i use a FileStream it's ok?
08:58:44FromDiscord<ElegantBeef> Ah nvm yea
08:58:46FromDiscord<ElegantBeef> I'm dumb
08:59:35*hnOsmium0001 quit (Quit: Connection closed for inactivity)
08:59:41mipri!eval import streams; echo newStringStream("a\0b").readStr(3) == "a\0b"
08:59:43NimBottrue
08:59:48*mbomba quit (Quit: WeeChat 3.0)
09:00:02FromDiscord<sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2HOn
09:00:13FromDiscord<sealmove> I am doing this
09:00:40FromDiscord<ElegantBeef> How are you reading?
09:02:34FromDiscord<sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2HOr
09:02:55FromDiscord<ElegantBeef> Do you `setposition(0)`?
09:03:13FromDiscord<sealmove> but I don't want to do this, I have other data before and after
09:03:27FromDiscord<ElegantBeef> Well do you move it back the few chars?
09:04:08mipri!eval import streams; var s = newStringStream(); s.write("ABC"); s.write('\0'); s.setPosition(0); echo s.readStr(4) == "ABC\0"
09:04:10NimBottrue
09:04:12FromDiscord<sealmove> oh sorry of course I set possition to 0 yes
09:04:44FromDiscord<sealmove> but mipri I don't use readStr()
09:04:54FromDiscord<sealmove> because it's null-terminated
09:05:19mipri... ?
09:05:41FromDiscord<sealmove> i don't know the length of string i am reading
09:05:59mipriand?
09:06:14mipriI can't type !eval all day
09:06:15FromDiscord<sealmove> and I can't use readStr because it takes the length of bytes to read as argument
09:06:35mipri!eval import streams; var s = newStringStream(); s.write("ABC"); s.write('\0'); s.setPosition(0); echo [s.readChar, s.readChar, s.readChar, s.readChar]
09:06:38NimBot['A', 'B', 'C', '\x00']
09:08:40FromDiscord<sealmove> yeah well, that's what I am doing
09:09:00miprihttps://play.nim-lang.org/#ix=2HOx
09:10:10FromDiscord<sealmove> I suspect it's a flush problem or something
09:10:55miprihmm a minor problem with that link is that if you readCStr before the \0 is written, you'll still be able to read a string instead of getting an error.
09:11:44mipriwhat you might want to do instead if you have control over bends of this stream, is send the length of the string first and then read that many chars
09:15:49FromDiscord<sealmove> ok here is the situation
09:17:02FromDiscord<sealmove> I am reading from stream #1 to an object, then I am writing this object to stream #2, then i set position of #2 to 0, and read another object out of it. then I compare objects.
09:17:37FromDiscord<sealmove> data are read correctly the first time, written correctly to stream #2, but a null terminated string at the end of the stream is not written the 2nd time.
09:19:07mipriah that's not a minor problem actually, '\0' is defined as EOF for readChar and friends
09:20:02mipris.readInt8.char avoids that
09:23:04FromDiscord<sealmove> hmm
09:25:05FromDiscord<sealmove> s.readInt8.char doesn't seem to avoid it
09:25:26mipriI'm talking about the minor problem I mentioned above
09:25:54*spiderstew_ quit (Quit: ZNC 1.7.2+deb3 - https://znc.in)
09:26:08*spiderstew joined #nim
09:30:29FromDiscord<sealmove> oh ok I found out the issue
09:30:48mipriwhat was it?
09:32:40FromDiscord<sealmove> I am writing a non-null-terminated string before the null-terminated one. Docs say write(someString) doesn't put null termintated byte, so I assumed there won't be one in between them. Hmm, is this a bug though?
09:33:26mipriaren't you just reading the first one as a cstring, and thereby reading both?
09:33:45FromDiscord<sealmove> eh, it's a bug in my code, I always write a null byte before calling streams.write(someString)
09:34:01FromDiscord<sealmove> no, I use readStr(len) for 1st one
09:36:59FromDiscord<sealmove> I need 2 procs, `writeNullTerminatedString` and `writeString`
09:37:28FromDiscord<sealmove> because I always write already parsed strings, which are nevel null-terminated
09:37:43FromDiscord<sealmove> this asymmetry bite me L:|
09:43:30FromDiscord<sealmove> btw guess, do you know if unaligned strings are seen in the wild?
09:43:36FromDiscord<sealmove> btw guys
09:49:55*fredrikhr quit (Read error: Connection reset by peer)
09:54:40*habamax quit (Ping timeout: 246 seconds)
09:57:03*habamax joined #nim
09:58:07planetis[m]@Revenant toml is sh**t as others will tell you, whatever lib you use, choose json u want regret it.
10:00:10FromDiscord<mratsim> json has no comment support though, for user-friendly configuation toml seems better
10:00:52FromDiscord<mratsim> @Zevv, @disruptek, how do you deal with environment apcking and unpacking in CPS? Are you using liftLocal or any Nim provided facilities or are you rolling your own closure?
10:02:03planetis[m]Just make an about:config page for power users, problem solved
10:03:05planetis[m]use an extra explanation field
10:03:16planetis[m]Can be localized as well
10:05:10FromDiscord<XxDiCaprioxX> Can you guys help me? If I want to initialize a variable to a type that has no arguments, how do I do that?
10:07:35FromDiscord<XxDiCaprioxX> `let foo = Bar` doesn't work because vs code thinks I want to declare and `let foo = Bar()` doesn't work either because vs code complains about empty parenthesis. But as my type has no extra parameters I can't really put anything in there, can I?
10:08:44FromDiscord<mratsim> let foo = Bar() or let foo = default(Bar) should work.
10:09:22FromDiscord<mratsim> let foo = Bar() only limitation is with arrays.
10:10:03FromDiscord<XxDiCaprioxX> that may be the reason
10:10:15FromDiscord<XxDiCaprioxX> I forgot to state that my type Bar is a seq
10:10:35FromDiscord<XxDiCaprioxX> sorry for that. Is there a workaround for seqs?
10:11:01*narimiran quit (Ping timeout: 264 seconds)
10:11:55planetis[m]Is Bar a tuple by any chance?
10:11:56FromDiscord<mratsim> use default or use newSeq[T](length)
10:12:30FromDiscord<XxDiCaprioxX> no Bar is a sequence
10:12:38FromDiscord<mratsim> or use `let foo: seq[int]: @[]`
10:12:43FromDiscord<XxDiCaprioxX> thank you @mratsim I'll try that
10:12:48FromDiscord<mratsim> let foo: seq[int] = @[]
10:18:02*tane joined #nim
10:21:03Zevvmratsim: we roll our own. all continuable blocks are isolated and for each an object type is composed (which is the actual continuation)
10:22:14FromDiscord<mratsim> how do you deal with the variable number of variables to save? do you have a max number of variables saved?
10:22:19*krux02 joined #nim
10:22:30Zevvhow are they variable?
10:22:43Zevvthe code dictates which local vars exist in any scope
10:23:53Zevvbasically we identify all locals, and rewrite the code to use the variables from there instead
10:23:56FromDiscord<mratsim> Yes, but there are a different number of local vars depending of the code
10:24:16Zevvsure, that just gets picked up, its not too hard
10:24:37Zevvthe code is abit convoluted, mostly because of the logic involved in rewriting various kinds of control flow
10:24:56FromDiscord<mratsim> My question is about memory management
10:25:16Zevvim having a little hike now, ill be back in an hor or so
10:25:22FromDiscord<mratsim> are you using a seq or anything GC managed or are you using an array with max size but that is multithreading friendly
10:25:22Zevvping me
10:25:43FromDiscord<mratsim> sure
10:48:08*mika_ joined #nim
10:53:56*idf joined #nim
10:55:50Zevvback
10:56:11Zevvbasically, for each proc we dissect, we create 1 object type
10:56:29Zevvthis holds all the locals that exists in the stack frame of the function
10:56:49Zevvversion 1 is just 1 plain list, I have thought of optimizing this to make it work like a stack using object variants
10:56:49disruptekand anything we capture. πŸ˜‰
10:57:07Zevvwhere memory used by things that leave a scope can later be reused by other things living in the same spot
10:57:15Zevvmy mental image is basically just exactly the layout of the original stack
10:57:19Zevvbut then made explicit in an object
10:57:28ZevvCPS does not care where the object is allocated, how or by whom
10:57:43Zevvit's just an object, consisting of a function pointer to the next continuatio proc, and the locals that apply at that point in time
10:57:59Zevvso now we allocate one object, set 'fn' to the first proc, and trampoline
10:58:21Zevvthat proc get's passed one single argument, which is a var object
10:58:33Zevvthe code in that function that used to work with locals now works with the data in that object
10:58:47Zevvat return time it will set the 'fn' part of the object to the next continuation proc
10:59:08Zevvso for the total life time of the original function that was cut into pieces, there is only 1 single allocation
10:59:23Zevvthat ideally is exactly as large as the deepest point of the original stack frame
10:59:27*idf31 joined #nim
10:59:48disruptekwell, that's not necessarily possible, but yeah.
11:00:02Zevvwhat disruptek calls 'fork', is basically making a copy of the object, and calling the fn for the original and the copy
11:00:05Zevvdisruptek: dude
11:00:09disruptekand technically, we could use smaller objects, but they'd vary more in size.
11:00:24Zevvwe talked about this a ton of times. I am right and you are wrong
11:00:28disruptekthis seems worse than fewer allocs.
11:00:47Zevvthe ideal case is an object variant of which the largest variant is exactly as big as the largest stack frame
11:00:52Zevvalso, what time is it
11:00:52disruptekhow do you make a seq inside the env, then?
11:01:06Zevvhow do you make a seq on the stack?
11:01:08Zevvyou dont
11:01:10disruptekuh
11:01:18Zevvthe 16 byte header is on the stack. The seq itself is on the heap
11:01:19Zevvalways
11:01:31Zevvno different here
11:01:34disruptekyes, so are you going to hack the seq into the heap-stack-env?
11:01:50disruptekwith a cast?
11:01:54Zevvyou don't, it was originally also not on the stack, was it?
11:01:55disruptekyou don't usually get to pick the seq's address.
11:02:05disruptekit's in the heap, but not in the same memory block.
11:02:10Zevvright
11:02:10disruptekso it's not contiguous.
11:02:13Zevvright
11:02:17Zevvthat' wont work for a seq anyway
11:02:21disruptekso there is more than one alloc.
11:02:24Zevvright
11:02:27disruptekthat's my only point.
11:02:35Zevvclear
11:02:42Zevvalso, what time is it
11:02:46disruptekum
11:02:56disruptek90:9
11:03:01Zevvsuch much
11:03:19disruptekokay, have a good hike.
11:03:24Zevvno i'm back
11:03:36disruptekoh.
11:03:39Zevvhike's always over arounnd 90:9
11:03:47Zevvbut now mratsim is gone
11:07:19ZevvI am still surprised about the confusion over what CPS is, and mostly, is not
11:07:26Zevvas it is almost nothing
11:08:20disrupteki know. i guess we need to focus on doing it by hand and then explain, again, that the module merely performs the rewrite for you.
11:08:34Zevvright.
11:08:38Zevvthat is way I keep saying
11:08:41Zevvkeep that stuff separated
11:08:43disruptekplanetis[m]: chucklehead, hit me up in a few hours and we'll debate hash as it relates to ic.
11:08:46Zevvdon't put your event loop thing in the same repo
11:08:48Zevvit confuses people
11:08:56ZevvCPS does not cancel, timeout, async, or whatever
11:09:03Zevvseparate that stuff, really
11:09:10disruptekeh, whatever.
11:09:12Zevvdon't even put your trampolines in there
11:09:14disruptekit was useful at the time.
11:09:29disruptekotherwise, we'd have had no way to truly demonstrate async code.
11:09:32Zevvtrue that
11:09:38Zevvno, second repo
11:09:40Zevvone repo doing CPS
11:09:45Zevvother repo doing stuff with it
11:09:55disruptekyeah, i don't care. it's whatever.
11:10:37disrupteki do hope cps can shrink a bit, though, even though it should do more.
11:10:37disrupteki guess once typed is in we'll know what we can delegate to the compiler.
11:11:00disruptekthe boss wasn't super helpful wrt the carnac bug.
11:11:25Zevvwilling or able
11:11:48disruptek"probably a bad nfSem", which i think i already ruled out. but i guess i can look again.
11:11:52Zevvbecasue it's still just the empty room problem, right
11:12:05FromGitter<jrfondren> can sugar.collect be used without assigning a variable? the closest I've got to immediately consuming the result is https://play.nim-lang.org/#ix=2HPe
11:12:20disruptekremind me.
11:12:54Zevvif you start doing typed macro's, you feel like your just entering an empty room that no one cared to decorate yet
11:13:01Zevvno furniture, bare bulb on the ceiling
11:13:13Zevvit's not broken perse, more that no one ever comes here
11:13:33disruptekoh yeha.
11:13:56disruptekso carnac works, which is cute, but only if you take the macro output and run it.
11:14:06disruptekso that's my test, now.
11:14:10Zevvwell isn't that useful
11:14:27disruptekcurrently, it produces idents for things like the proc name and result, which isn't ideal when you're trying to compile it to C.
11:15:25disruptekthis could be a thing that people solve with multi-level macros, but that's a shitty solution, honestly.
11:16:26Zevvso, I'm not really sure how your carnac thing relates to the CPS thing we were blocked on
11:16:29Zevvexplain it to me
11:16:46disruptekit's a smaller demo of a typed proc rewrite; that's it.
11:16:54Zevvok right
11:16:55disruptekit does the resym.
11:17:12Zevvwell, I do like that @mratsim seems to take interest in this
11:17:24Zevvit might help building some momentum
11:17:26disruptekyou'd have to be dom96 not to.
11:17:50disruptekit's like, obviously the way forward.
11:20:23*habamax quit (Quit: leaving)
11:20:42*habamax joined #nim
11:24:25FromDiscord<Clyybber> disruptek, Zevv sup
11:25:07Zevvoy
11:25:15Zevvwe had @mratsim asking good questions about CPS
11:25:22Zevvbut then he ran off
11:25:30disruptekclyybber wtf. where have you been?
11:26:47FromDiscord<Clyybber> on the run
11:27:16disruptekhmmph.
11:28:08FromDiscord<Clyybber> Ill look at the carnac today
11:29:14disruptekthanks; i have to peform sex acts for money instead of coding, but maybe i'll catch you later if the police haven't nabbed you by then.
11:30:54*antranigv quit (Quit: ZNC 1.8.2 - https://znc.in)
11:32:36*antranigv joined #nim
11:36:09*mika_ quit (Quit: Lost terminal)
12:03:44FromDiscord<dom96> https://irclogs.nim-lang.org/13-12-2020.html#11:00:24 lol
12:03:45FromDiscord<m0nsta> i mean, he could be on the run from the object oriented mafia
12:04:11FromDiscord<dom96> > you'd have to be dom96 not to.
12:04:25FromDiscord<dom96> I literally was asking questions about it like two days ago
12:06:02*supakeen quit (Quit: WeeChat 2.9)
12:06:34*supakeen joined #nim
12:11:50*hmmmm joined #nim
12:12:02hmmmmalo~
12:15:55*antranigv quit (Quit: ZNC 1.8.2 - https://znc.in)
12:17:30planetis[m]disruptek: I m curious, but i don't think it would be related to ic at all.
12:18:00*antranigv joined #nim
12:20:08FromDiscord<mratsim> @Zevv I didn't run off, I was trying to optimize cryptographic code. square root for complex big int in particular πŸ˜‰
12:20:47ForumUpdaterBotNew thread by Lecale: StartProcess help (2), see https://forum.nim-lang.org/t/7249
12:20:50FromDiscord<mratsim> My question stems basically from the fact that Weave task seems to be basically CPS continuation + Weave metadata
12:21:34FromDiscord<mratsim> the proc {.nimcall.} + an environment/closure representing all variables captured for the execution of the proc {.nimcall.}
12:21:59FromDiscord<mratsim> So I could have Weave be an executor for CPS
12:22:29FromDiscord<mratsim> And we could have another executor for IO/async and they would all use the same primitives.
12:23:14FromDiscord<mratsim> And maybe later we have an executor interface and people would just write code and depending on their need dispatch that to Weave for CPU-bound or an async/await executor for IO-bound.
12:23:21FromDiscord<dom96> I like how everyone is just reimplementing what the compiler already implements
12:24:15FromDiscord<mratsim> But, I absolutely need that environment to be threadsafe, and ideally bounded in size so that we can handle millions/billions/trillions of them and that needs a memory pool
12:24:51FromDiscord<mratsim> @dom96 the compiler doesn't expose local captures unfortunately, though I didn't check what liftLocals does.
12:25:06FromDiscord<mratsim> and the owner magic macro isn't sufficient.
12:25:16FromDiscord<mratsim> local variable captures
12:25:47FromDiscord<dom96> Pretty sure there is a way to get at the captured closure data, it's useful for FFI
12:26:24FromDiscord<mratsim> There is this: https://github.com/nim-lang/Nim/pull/8253 but no doc at all.
12:26:27disbotβž₯ Add sym owner to macros ; snippet at 12https://play.nim-lang.org/#ix=2HPI
12:26:49FromDiscord<mratsim> and lifLocals is even more hidden
12:26:53FromDiscord<mratsim> liftLocals
12:27:40FromDiscord<dom96> I remember passing a {.closure.} to a GTK callback a while ago with its data as the callback data
12:28:08FromDiscord<mratsim> sure, you can use rawEnv: https://nim-lang.org/docs/system.html#rawEnv%2CT
12:28:17FromDiscord<dom96> yeah, that's it
12:28:25FromDiscord<mratsim> but that doesn't help when you need to build your own custom closures.
12:29:45*Cthalupa quit (Ping timeout: 240 seconds)
12:31:30FromDiscord<mratsim> to be more concrete @Zevv: this is the core task system of Weave extracted and cleaned from anything scheduler related: https://github.com/mratsim/blocksmith/blob/master/cross_service_calls.nim#L21-L127
12:33:20*Cthalupa joined #nim
12:43:31*Q-Master quit (Ping timeout: 256 seconds)
12:50:07Zevvthat looks familiar, but our "env" consists of a object or sum type of concrete stuff that is lifted
12:50:18Zevvso env size is bound and fixed at compile time
12:50:51Zevvand now I need to run off again, for some reason my family has D&D sessions every sunday afternoon and I ended up joining that somehow
12:51:36Zevvthis feels compatible, as long as we don't string and seq
12:52:10Zevvalso it seems like a nice fit where CPS ends & where weave begins
12:52:22ZevvCPS does not do anything about actually calling your continuations somehow
12:52:35Zevvit only produces them from plain flat nim code
12:52:58FromDiscord<dom96> Wow. Your family is epic, can I join? πŸ˜„
12:53:11Zevvman I loathe it, really
12:53:17Zevvbut the kids seem to enjoy it a lot
12:53:57ZevvI like the game part, but the rules are really utterly brain dead needlessly complicated
12:54:14Zevvmight as well spin up The Witcher
12:54:24ZevvSame stuff, but the computer does the bookkeeping
12:55:36FromDiscord<dom96> It’s about interacting with the people, any computer involvement lessens this. ↡That said, the Alexa skill which helps play Ticket To Ride is awesome.
12:55:57*PMunch joined #nim
12:56:01Zevvi interact more then enough with my kids already, thank you
12:56:14Zevvthey have a swiss uncle doing the mastering from switzerland, over zoom
12:56:28Zevvthat makes it pretty hard, him being on a tiny speaker not being able to lash out or shout
12:56:37Zevvanyway, ETA 00:03:30
12:56:40Zevvbbl
13:02:26FromDiscord<m0nsta> sent a code paste, see https://play.nim-lang.org/#ix=2HPW
13:02:52FromDiscord<m0nsta> can anyone help explain this to me ?
13:03:57FromDiscord<Vindaar> what are you not understanding?
13:03:59FromDiscord<m0nsta> i get T means it'll be a matrix of type `T`, that you'll pass. for eg `int` or `float` or `string`
13:04:21FromDiscord<m0nsta> what does those Rows and Colums in the typedef mean ?
13:04:31FromDiscord<lqdev> these are extra generic params
13:04:44FromDiscord<lqdev> imo they should also be annotated with a `static int` constraint
13:04:46FromDiscord<Vindaar> yes, but for rows and columns this should probably be `static int`
13:04:54FromDiscord<lqdev> like `Matrix[T; Rows, Columns: static int]`
13:04:57FromDiscord<Vindaar> ^
13:05:24FromDiscord<m0nsta> alright, but what does it mean to you guys when you read that ?
13:05:38FromDiscord<lqdev> these are generic parameters for the type
13:05:59FromDiscord<Vindaar> well, to me nothing really, because as they are generic parameters of the type, but I don't see the actual fields of the type
13:06:14FromDiscord<Vindaar> can only deduce the intent
13:06:16FromDiscord<lqdev> `type matrix with generic parameters T, Rows, and Columns, which is an object`
13:06:34FromDiscord<m0nsta> like rows will be of type Rows ? but hen dafuq is a Column type doing there ?
13:06:43FromDiscord<lqdev> no
13:06:48FromDiscord<lqdev> they're generic parameters like `T`
13:06:56FromDiscord<lqdev> so they may be any type
13:07:03mipriRows and Columns are both static ints
13:07:03FromDiscord<m0nsta> so, they dont mean shit, yet
13:07:10FromDiscord<lqdev> yet.
13:07:32FromDiscord<m0nsta> its from the manual and its really confusing to me lol
13:07:35miprithis is the same semicolon use taht you see in parameters.
13:07:44FromDiscord<m0nsta> might just name them XYZ or something
13:08:30mipri!eval import strutils; echo (proc (a, b: int; x: string): int = a + b + x.parseInt)(1, 2, "3")
13:08:33NimBot6
13:08:45FromDiscord<m0nsta> now then, all of those generic params could be used to define generic fields int the object definition if we chose to amirite
13:08:54mipria and b are ints; x is a srting. above, T is completely generic; Rows and Columns are static ints
13:11:08FromDiscord<Vindaar> but `Rows` and `Columns` are _not_ static ints here?
13:11:22FromDiscord<m0nsta> doesn't seem like
13:11:24*hmmmm quit ()
13:11:35FromDiscord<m0nsta> https://nim-lang.org/docs/manual.html#generics-implicit-generics
13:11:45FromDiscord<m0nsta> scroll down a little there
13:11:49mipriin what m0nsta said, no. I was replying to what lqdev said.
13:12:08*Q-Master joined #nim
13:12:16FromDiscord<Vindaar> oh haha
13:12:35FromDiscord<Vindaar> @m0nsta I had no idea one could write `Matrix.T` to match the name `T` from the type definition, wth
13:12:43FromDiscord<Vindaar> the type `T`
13:12:46FromDiscord<lqdev> @Vindaar that's legit yeah
13:13:22FromDiscord<m0nsta> @Vindaar Araq wasnt messing around when he meant generic lol
13:13:37FromDiscord<lqdev> @Vindaar https://nim-lang.org/docs/manual.html#generics-implicit-generics
13:13:52FromDiscord<lqdev> that's where this snippet is from
13:13:57FromDiscord<Vindaar> I mean it makes sense, but I simply wasn't aware of it. Imo implicit generics in most use cases are really bad style
13:13:58FromDiscord<m0nsta> YAS
13:15:19FromDiscord<m0nsta> so Rows and Colums are just names here that dont really have anything to do with row or column types right?
13:15:58miprithey're names, correct
13:16:40FromDiscord<m0nsta> got it
13:17:08FromDiscord<m0nsta> i was confused how are they specifying the row or column types here
13:17:17FromDiscord<m0nsta> or am i missing something lol
13:17:39FromDiscord<m0nsta> or wth is even a column type lol
13:17:40FromDiscord<trippleA> In this screenshot, what does the mean in these two different examples? https://media.discordapp.net/attachments/371759389889003532/787669568801210428/asterik.png
13:17:40mipriin your example, they're not
13:17:46mipriit's purely a name
13:17:52FromDiscord<m0nsta> gotcha
13:17:57*lytedev[m] quit (Ping timeout: 260 seconds)
13:17:57*BitPuffin quit (Ping timeout: 260 seconds)
13:18:32*GitterIntegratio quit (Ping timeout: 260 seconds)
13:20:00*lytedev[m] joined #nim
13:20:04*BitPuffin joined #nim
13:24:26FromDiscord<lqdev> @trippleA multiplication
13:35:40PMunchAnyone ready for day 13 of AoC?
13:38:15PMunchStream is live! https://www.twitch.tv/pmunche https://www.youtube.com/watch?v=oFxW7MJ-7qw
13:45:30Zoom[m]My solution for P2 fails for one of the test inputs :)
13:45:51PMunchSounds like you did something wrong :P
13:46:32Zoom[m]No shit! It works for my input, though
13:46:54Zoom[m]That's the worst kind of bug
13:47:28Zoom[m]Nope, the worst is failing for someone else's data, while passing your tests
13:51:32Zoom[m]Ha-ha, I just lost a digit while copypasting the test data
13:52:04Zoom[m]PMunch: why aren't you in the second private Leaderboard?
13:53:08FromDiscord<pietroppeter> It was shared in mega thread once the main one was full
13:55:13FromDiscord<pietroppeter> The idea of the second leaderboard was to allow for other people to be in the leaderboard when the main one was full. Also since main one has lots of people who joined in the past and are not doing this year in Nim, the new leaderboard is specific for those doing 2020 in Nim
13:56:33Zoom[m]I couldn't joint the main one since it was full but I just checked and I'm in
13:57:44FromDiscord<dom96> > but that doesn't help when you need to build your own custom closures.↡Why do you need to build your own closures? Is it just to control how they're allocated?
13:57:50Zoom[m]Not bad, 38 place, considering I started from D4 or something like that, and I'm sleeping for the first 4-5 hours of the aocDay
14:11:56FromDiscord<sealmove> @PMunch hey! check this out! https://github.com/sealmove/binaryparse/blob/master/tests/testsuite.nim πŸ™‚
14:12:40PMunch@sealmove, sorry I'm streaming right now, and have to go right after. But from a quick glance it looks good .)
14:13:51FromDiscord<sealmove> np, just wanted to show that I made proper test suite
14:14:21FromDiscord<sealmove> most features are tested and work
14:14:44FromDiscord<sealmove> enjoy aoc!
14:16:19FromDiscord<pietroppeter> that's a good path you are going...
14:16:29FromDiscord<pietroppeter> what about the two highest bus number
14:16:32FromDiscord<pietroppeter> ?
14:22:24FromDiscord<mratsim> Because I need threadsafe closures for multithreading
14:25:35FromDiscord<pietroppeter> sorry if I have thrown of your path. you might want to continue own with your reasoning. one good thing though would be to put the input in better shape: you only care about buses without the x and the position is only useful to get the timedelta (your i) which you do not have to compute it every time in the loop.
14:27:47FromDiscord<pietroppeter> then what I mean about the two highest it was not even really about the two highest. it is about the fact that you were taken some steps according to your first bus. then when you find a time that goes well with two buses, what can you do to take bigger steps for the rest of the buses
14:27:49FromDiscord<pietroppeter> ?
14:28:56FromDiscord<pietroppeter> gotta go, sorry, will check later how it went πŸ™‚
14:29:34*antranigv quit (Quit: ZNC 1.8.2 - https://znc.in)
14:31:12*antranigv joined #nim
14:34:31*narimiran joined #nim
14:35:02FromDiscord<dom96> in other words, you want to control how they're allocated, right?
14:36:12FromDiscord<mratsim> That is a nice to have. Closures not being threadsafe is a blocker.
14:39:17FromDiscord<dom96> in what way are they not thread safe?
14:45:41FromDiscord<mratsim> They are managed by the GC
14:46:08FromDiscord<xotonic> About the actual tool that parses RST file `doc` and converts it to HTML. Is it written in Nim or Koch invokes some 3rd party utility?
14:46:17FromDiscord<xotonic> (edit) "file" => "files in"
14:46:19FromDiscord<mratsim> it's in the compiler
14:46:55FromDiscord<dom96> huh? I don't get how that's somehow different to what I said above regarding their allocation.
14:47:12FromDiscord<dom96> You want to manage how they are allocated yourself, not leave it to the GC
14:47:22FromDiscord<dom96> Because the GC puts it on a thread-local heap
14:48:01FromDiscord<mratsim> It's different because if the closures had a single owner and were done using destructors I could use them. The limitation being performance if a lot are allocated.
14:48:17FromDiscord<mratsim> so doing my own closures is just an option
14:48:57PMunchMan that was annoying.. Felt like I was getting close and now I have to run..
14:48:59*PMunch quit (Quit: leaving)
14:49:19FromDiscord<mratsim> if the closures are managed by the GC with thread local heap and the GC-ed memory allocated in one thread is exposed to the other thread, I don't have an option, i am forced to do custom closures.
14:49:41FromDiscord<dom96> Yes, so if Nim closures allowed you to manage their allocation all would be fine
14:49:49FromDiscord<mratsim> so the difference is optional vs mandatory.
14:50:08FromDiscord<dom96> And I would argue that as a systems programming language this should be made possible
14:50:53FromDiscord<mratsim> there are a couple of solutions:↡- some "liftLocals" that accept a var openarray as a serialization destination↡- closures with an allocator parameter
14:51:53Zevvmratsim: I still have missing pieces in my mental image
14:52:12FromDiscord<dom96> Yeah, it would be awesome if we could have those solutions πŸ™‚
14:52:19FromDiscord<dom96> Maybe I should write an RFC hmm
14:52:21Zevvjust like disruptek noted earlier: we can put our things in your var openarray, but how would that handle "native" strings and seqs
14:52:28Zevvthese are still GC managed
14:52:50FromDiscord<mratsim> The thing is, I'm sure cooldome actually has that, I think he is the only user of the "owner" macro and liftLocals pragma
14:53:31FromDiscord<mratsim> but I don't know how to compose both into something for custom closures.
14:54:11FromDiscord<dom96> Perhaps what we really need is custom allocators ala Zig/Jai
14:54:20FromDiscord<mratsim> @Zevv, this is my "Isolated" remark↡> I assume those are ref objects only now but in the future they will become Isolated #244 otherwise they can't be moved across threads and a continuation should be owned by a single thread anyway right?
14:54:24FromDiscord<dom96> But ugh, so many features, makes me sad.
14:54:43Zevvright, so isolated will be crucial for this, that was my assumption
14:54:56FromDiscord<mratsim> I don't think we need to go into custom allocators, just provide the tools to workaround limitations
14:55:11FromDiscord<mratsim> with destructors it's easy enough to write your own "managed" sequence.
14:55:34FromDiscord<mratsim> but lifting local variables is more involved, so a primitive for this would be helpful.
14:55:45FromDiscord<dom96> I can see this either being a parameter to newSeq or a global override
14:55:48FromDiscord<Conquestor> I meant to type in anime- And I typed in nim
14:55:53FromDiscord<dom96> Both would require a custom allocator to be specified
14:56:14Zevvmratsim: you mean lifing from nim itself, or lifting from a macro?
14:56:15FromDiscord<dom96> @Conquestor you are now duty bound to commission an anime artist to draw a Nim mascot
14:57:15FromDiscord<mratsim> We can have a "SeqInterface" template that accepts a type name and an allocator and do "instantiate(SeqInterface, seq[T], defaultAllocator).
14:57:43FromDiscord<mratsim> any if someone needs a custom allocator `instantiate(SeqInterface, MySeq[T], MyAllocator)`
14:57:52*waleee-cl joined #nim
14:58:19FromDiscord<mratsim> this doesn't pollute the default sequence with allocator parameter, allocator callback or Allocator as a static type.
14:58:26FromDiscord<mratsim> it's backward compatible.
14:58:58Zevvbut it will add overhead to the type keeping track to the allocator
14:59:04FromDiscord<mratsim> However it needs the standard library to be written with an "interface"/"concept" perspective instead of catering to an implementation
14:59:16Zevvwe just threw that out a year ago
14:59:51FromDiscord<mratsim> it won't, MyAllocator.malloc calls are all replaced at compile-time.
15:00:10FromDiscord<mratsim> it's not a field.
15:00:20Zevvhm, and likewise the deallocs
15:00:24FromDiscord<mratsim> it's a template that generates all the proc of something sequence-like.
15:01:02Zevvhow can that work? Will the generated objects be of a distinct type?
15:01:14Zevvwhat if I put two things in a container that are allocated by a different allocater
15:01:17Zevvand GC the container
15:01:24Zevvhow does it know how to dealloc the individial thing
15:01:25Zevvs
15:01:26FromDiscord<dom96> I don't think rewriting the stdlib with concepts everywhere is a good idea
15:01:30FromDiscord<dom96> At least not right now
15:01:56FromDiscord<mratsim> @Zevv, the use case for 2 similar types with different allocators seem strange
15:02:06FromDiscord<dom96> A much less intrusive implementation of this would just be a setAllocator() call
15:02:07Zevvbut not impossible
15:02:22FromDiscord<mratsim> setAllocator is problematic with Nim DLLs
15:02:29FromDiscord<mratsim> then you need Vtable
15:02:47FromDiscord<mratsim> just like you need VTable or methods for inherited types in the same container
15:03:07FromDiscord<dom96> You need the Nim runtime as a DLL anyway, maybe you could build a Nim runtime with a custom allocator
15:03:17FromDiscord<mratsim> regarding the lifting, it's grabbing variable from the outer scope to make them available in the continuation.
15:03:43FromDiscord<exelotl> Yo can we get TysonTan to do the Nim mascot
15:03:53FromDiscord<mratsim> but in complex application you might need 1 allocator per event loop. One allocator for async, one for CPU-bound tasks.
15:04:22FromDiscord<Clyybber> disruptek: has carnac evolved from a minimal repro?
15:04:30FromDiscord<mratsim> anyway this should likely be in "#internals"
15:04:43FromDiscord<dom96> nah
15:05:45FromDiscord<dom96> Hm, I can't imagine a scenario where I'd need more than 1 allocator in my app. But seems like an edge case in any case.
15:05:58FromDiscord<dom96> If we were to provide `setAllocator` it would already go a long way
15:06:09FromDiscord<dom96> for those edge cases we could also allow a custom allocator passed to newSeq etc.
15:09:07Zoom[m]<FromDiscord "<dom96> I don't think rewriting "> From what I gathered about std this is unavoidable in the long run. ATM there's some duplicating functionality implemented in slightly different ways to work with different types.
15:11:14FromDiscord<lqdev> oh wow this is the first time in my life that `with` actually worked
15:11:24FromDiscord<lqdev> and i tried like, 5 times already
15:12:30FromDiscord<exelotl> lol glad I'm not the only one who had trouble with it
15:12:53FromDiscord<lqdev> notably it has problems with modifying arrays
15:13:16FromDiscord<lqdev> PMunch please make the playgrond's text field autofocus ._.
15:13:27FromDiscord<lqdev> (edit) "playgrond's" => "playground's"
15:13:32FromDiscord<dom96> Zoom: yeah, quite likely. But not something to focus on right now in order to get custom allocators.
15:13:40FromDiscord<zetashift> shouldn't be hard to PR to the playground right?
15:14:10FromDiscord<lqdev> a simple example like this fails miserably https://play.nim-lang.org/#ix=2HRa
15:14:22FromDiscord<lqdev> like, come on…
15:17:31FromDiscord<zetashift> think karax uses `setFocus` and i needs to be hooked up to `editor`?
15:17:35FromDiscord<dom96> @lqdev guess not many are using it, seems like a nice intro to fixing bugs in the compiler though
15:17:43FromDiscord<zetashift> (edit) "i" => "it"
15:21:22*kenran joined #nim
15:47:15ForumUpdaterBotNew thread by Saem: Perceus: Garbage free reference counting with reuse, see https://forum.nim-lang.org/t/7250
15:48:00FromDiscord<shadow.> can anyone look over my day 12 part two logic
15:48:13FromDiscord<shadow.> https://play.nim-lang.org/#ix=2HRw
15:48:17FromDiscord<shadow.> (for aoc)
15:48:34FromDiscord<shadow.> `type Vector = tuple[x, y: int]`
15:50:09FromDiscord<Recruit_main707> why a tuple
15:51:31FromDiscord<shadow.> idk why not
15:52:03mipriwith tuples you get terse initialization but still have names for fields.
15:52:23FromDiscord<shadow.> yeah i think that's why i chose it iirc
15:52:24FromDiscord<shadow.> lmfao
15:52:53FromDiscord<pietroppeter> @shadow: from the look of it seems nice (clean and effective). Are you having issues?
15:52:58FromDiscord<shadow.> i can do `var x: array[5, Vector] = [(0, 1), (1, 0), (5, 10), (2, 12), (11, 023)]`
15:53:01FromDiscord<shadow.> well
15:53:07FromDiscord<shadow.> it works for the test given
15:53:10FromDiscord<shadow.> but on my input it says too low
15:53:42FromDiscord<pietroppeter> Usually it is an off by one error, but I would go with echo and try the test example...
15:53:46mipriat a guess, the bug isn't there, but is in the initial values of your waypoint
15:54:05FromDiscord<shadow.> hmm
15:54:11FromDiscord<shadow.> (10, 1)?
15:54:18FromDiscord<shadow.> east 10 and north 1 iirc
15:54:34mipriyep, that's right.
15:54:57FromDiscord<shadow.> hmm
15:55:00FromDiscord<shadow.> how odd
15:55:17mipriwell it was a guess after all.
15:55:42FromDiscord<shadow.> and the response is the manhanttan distance of (0, 0) with the ship's position?
15:55:54FromDiscord<shadow.> diff of (0, 0) and ship pos
15:55:58mipriit's the same as with part1, yes
15:56:03FromDiscord<shadow.> weird
15:57:03FromDiscord<sealmove> guys, i am creating an object which has a variant and i assign a value to the variant after its creating. i think I am observing some weird behavior because of this. is it likely?
15:57:12FromDiscord<Bimbo> Is there any library for nim that can handle playback of music files? I want to try making a clone of cmus for fun and couldn't find anything relevant
15:59:54mipri'nimble search music' has some modules
16:00:59FromDiscord<shadow.> even odder, my part one is screwed up now but ill figure that out later...
16:01:04FromDiscord<shadow.> still confused on why part two is wrong
16:01:05FromDiscord<pietroppeter> @shadow you sure is it parsing the complete input (do you have \n at the end)?
16:01:10FromDiscord<shadow.> yes i do
16:01:14FromDiscord<shadow.> it'd raise an assertion error tho
16:01:18FromDiscord<shadow.> if it was unparsable
16:01:30FromDiscord<shadow.> since im using npeg
16:01:44FromDiscord<pietroppeter> Again I would echo stuff out
16:01:47FromDiscord<shadow.> for instance?
16:02:11FromDiscord<pietroppeter> What is parsing, ship position and waypoint after each iteration
16:02:17FromDiscord<pietroppeter> And test on example
16:02:33FromDiscord<shadow.> example worked lol
16:02:43FromDiscord<shadow.> that's the confusing part
16:02:43miprithe last time I used npeg, it was quite a while ago, but I had to explicitly match * !1 to ensure that I parsed the entire input
16:02:51FromDiscord<shadow.> hmm
16:02:52FromDiscord<shadow.> i haven't had that issue before
16:03:08FromDiscord<shadow.> yeah that gave same answer
16:03:30FromDiscord<shadow.> pietro, if you've solved it would you mind telling me a ballpark of how far off i am on my input so i can see how to fix it?
16:03:44FromDiscord<shadow.> i can send you input if you'd like
16:04:03FromDiscord<pietroppeter> On the phone right now but you can find my solution on my advent of Nim repo
16:04:08FromDiscord<shadow.> ah ok fair enough thanks
16:05:19FromDiscord<shadow.> nvm i dont wanna see the exact answer lol
16:05:20FromDiscord<shadow.> ill figure it out
16:06:02FromDiscord<pietroppeter> Yeah you will! πŸ™‚ let us know!
16:07:24FromDiscord<shadow.> so ive done some echos
16:07:27FromDiscord<shadow.> left rotation looks like this
16:07:37FromDiscord<shadow.> sent a long message, see http://ix.io/2HRV
16:07:37FromDiscord<shadow.> that seems correct
16:07:53FromDiscord<shadow.> 3 90-deg right rotations for a left rotation of 90
16:07:57FromDiscord<shadow.> so i guess i can check that off lmao
16:10:04*letto quit (Quit: Konversation terminated!)
16:10:22FromDiscord<shadow.> alr N S E W L R seem to all be working
16:10:30FromDiscord<shadow.> issue must be with forward or at the beginning / end of code
16:12:20FromDiscord<Clyybber> disurptek: pong
16:12:42*NimBot joined #nim
16:12:51*letto joined #nim
16:13:06Zoom[m]@shadow. I've left 2 ways to deal with CCW rotation in my code
16:15:06Zoom[m]One is converting it to CW first (360-x), the other one is just an if and mod operation (floorDiv)
16:15:33FromDiscord<shadow.> yeah i've done that too
16:15:44FromDiscord<shadow.> i just do 360 - x
16:15:55FromDiscord<shadow.> > ship at (x: 2, y: 8) waypoint at (x: 7, y: 8)↡> moving ship to waypoint 81 times↡> ship at (x: 569, y: 656) waypoint at (x: 7, y: 8)↡this looks correct, right?
16:16:50FromDiscord<shadow.> yeah thats correct im so confused
16:17:21mipriyeah that's correct.
16:17:40FromDiscord<shadow.> FUCK
16:17:54FromDiscord<shadow.> `abs shipPos.x + abs shipPos.y` -> `abs(shipPos.x) + abs(shipPos.y)`
16:17:56FromDiscord<shadow.> that was the issue
16:17:58FromDiscord<shadow.> of course it was
16:18:25FromDiscord<shadow.> LMAO
16:18:28mipriah yeah, command syntax.
16:18:43FromDiscord<dom96> ouch
16:18:52FromDiscord<shadow.> lmfao
16:19:07FromDiscord<shadow.> time to upload to github
16:19:49FromDiscord<shadow.> !repo shadowninja55/aoc-2020
16:19:50disbothttps://github.com/shadowninja55/aoc-2020 -- 9aoc-2020: 11my attempt at advent of code 2020 in nim. 15 1⭐ 0🍴
16:19:56FromDiscord<shadow.> i actually think my day 12 was quite elegant
16:20:18FromDiscord<shadow.> > for _ in 1..(num div 90):↡> swap(wpPos.x, wpPos.y)↡> wpPos.y = -1↡i just whipped open a graphing calculator to figure that out lol
16:30:50FromDiscord<shadow.> how can i read the nth line of a file?
16:31:21mipriread n-1 lines, and then read the next one. read the entire file and split it by lines.
16:31:40FromDiscord<shadow.> ohh ok fair enough
16:31:46FromDiscord<shadow.> thanks
16:31:59miprithere aren't really any clever options unless you deal with unusual files.
16:37:05FromDiscord<sealmove> `tuple[genedSym: int]` what `NimSymKind` do I use for it?
16:37:14FromDiscord<sealmove> `nskField`?
16:45:42FromDiscord<sealmove> Ok `nskField` works
16:50:19FromDiscord<shadow.> can you index an ordered table with an int?
16:50:25FromDiscord<shadow.> or is it only ordered in terms of iteration
16:52:09Zevvyou good npeg wise shadow?
16:52:17mipriyeah, just iteration
16:52:25Zevvk
16:52:30FromDiscord<shadow.> and yes im good on npeg thanks
16:52:39FromDiscord<shadow.> it's very intuitive lol
16:52:58Zevvnice
16:55:54FromDiscord<Clyybber> Zevv: since disruptek is gone, can you tell me which cps bugs are still valid?
16:56:00FromDiscord<Clyybber> or how to repro them
16:57:08FromDiscord<shadow.> how do i enumerate an iterator?
16:58:04FromDiscord<shadow.> im trying to enumerate `string.split()`
16:58:10FromDiscord<shadow.> from `strutils`
16:58:31mipriare you looking for std/enumerate ?
16:58:54FromDiscord<shadow.> probably
16:59:58mipri!eval import std/enumerate; for (i, n) in enumerate([1]): echo (i, n)
17:00:01NimBot(0, 1)
17:01:38FromDiscord<shadow.> im guessing you can't brute force day 13?
17:01:39FromDiscord<shadow.> 12
17:03:14miprisupposedly day 13 part 2 is amenable to DP techniques as well.
17:04:18FromDiscord<shadow.> fuck im awful at DP
17:04:26FromDiscord<shadow.> for day 10 i just used statistics lmfao
17:04:52FromDiscord<dom96> Ahh DP, why is this problem tricky for DP?
17:05:45mipriwell I reckon about 99% of the gold stars discussed it, saw that they had to use a specific algorithm (not DP related anymore), and then implemented that by rote copying an implementation online, and are now congratuling themselves for having persevered and having 'learned' this algorithm that they will forget entirely because it's so narrowly useful (once per year in AoC events)
17:05:59mipriyeah I'm mad about today as well.
17:06:23FromDiscord<shadow.> rip
17:06:36FromDiscord<mratsim> dynamic programming is the worst technique name ever
17:06:40FromDiscord<shadow.> right now im just trying to brute force on intervals of the highest bus id or so
17:06:47FromDiscord<shadow.> im guessing that will not suffice
17:07:19FromGitter<fish-face> Could someone help me understand why the following does not compile: https://dpaste.com/8DMBL7LLM ? Error is a type mismatch on line 13: `got <seq[int], string> but expected one of: proc `[]`(s: RefSeq; p: string): int` - why is `rs` a `seq[int]` not a `RefSeq` (or `ref seq[int]`)
17:07:51miprino, any brute force worthy of the 'brute' term isn't going to suffice.
17:08:06FromDiscord<shadow.> fair enough
17:08:44FromDiscord<mratsim> @fish-face just use type RefSeq {.shallow.} = object; data: seq[int]
17:09:42FromDiscord<mratsim> this is what I have been using for 3 years in Arraymancer https://github.com/mratsim/Arraymancer/blob/v0.6.1/src/arraymancer/tensor/data_structure.nim#L21-L30 until I dropped down to pointer + length this week
17:11:25disruptekclyybber: carnac demonstrates the bug i'm working on now.
17:11:37FromDiscord<mratsim> Nim has autodereferencing of "ref" in some cases and it might be triggered on your last line
17:11:55FromDiscord<mratsim> ah
17:12:07FromDiscord<Clyybber> disruptek: Oh cool, which one is it?
17:12:44mipri>The . (access a tuple/object field operator) and [] (array/string/sequence index operator) operators perform implicit dereferencing operations for reference types
17:13:24Zoom[m]PMunch made me feel good, saying the proper solution to today's aoc P2 is "super clever" in his stream :3
17:13:31disruptekcustom allocators aren't a problem for arc.
17:14:15*FromDiscord quit (Remote host closed the connection)
17:14:32*FromDiscord joined #nim
17:16:22Zoom[m]Can we have a nice compiler error for tuple unpacking in For loops?
17:17:44disruptekclyybber: the bug is that the body of the proc it rewrites reaches the backend without having been sem'd.
17:17:47FromDiscord<shadow.> https://play.nim-lang.org/#ix=2HSl
17:17:51disruptekparts of it, anyway.
17:17:53FromDiscord<shadow.> mipri: so im guessing this is too inefficient
17:19:29mipriyou can see how long it takes on the test input for part 2.
17:20:46FromDiscord<shadow.> instant
17:20:50disruptekdom96: the reason you might want separate allocators is to impl regions, pools, x-device memory, or, like, a million other things. allocating memory is a kinda basic operation that is nice to be able to control.
17:21:17FromDiscord<shadow.> hmm im guessing im gonna need some sort of math in here to implement skipping ahead
17:21:25FromDiscord<Clyybber> disruptek: Ah, is it the result of a macro and if so what is the return type of that macro?
17:21:56disrupteki dunno, and the return type doesn't matter. even the proc itself is unsem'd.
17:22:07disruptekin the carnac test, it's a fibonnaci.
17:22:27disruptekit's a macro result, yes. carnac is a proc macro.
17:22:33disruptekit's well-commented, too.
17:23:00disruptekit memos your func calls and their results, loading and storing the cache from disk at runtime.
17:23:08disruptekthat's it.
17:23:43FromDiscord<Clyybber> cool, where are you at currently?
17:23:52FromDiscord<Clyybber> investigating or minimizing?
17:26:20FromDiscord<dom96> > allocating memory is a kinda basic operation that is nice to be able to control.↡agreed. It would be nice if we could get support for custom allocators in Nim.
17:26:59disruptekdom96: arc makes custom allocators about as easy as they could be.
17:27:13disrupteki looked at the site of the crash and noted that the codegen input was not sem'd.
17:27:24disrupteki asked araq wtf that was about and he said, "probably something bugged in nfSem".
17:27:29disrupteki haven't looked at it since then.
17:27:35disruptekthere's no point to minimizing; it's pretty damned minimal, by design.
17:27:47disrupteksorry; my network is such shit i dunno what made it through.
17:27:58FromGitter<fish-face> mipri: ah I see, how do you control when/whether that happens? I think I am having performance issues due to copying large structures but am having trouble testing? Is that what @mratsim's `{.shallow.}`does?
17:28:24mipri{.shallow.} gives you reference semantics on assignment yes
17:28:34FromDiscord<Clyybber> disruptek: so you are working on it?
17:28:37disruptekdom96: you could, like, define an allocator just for a single scope.
17:28:38FromDiscord<mratsim> Nim sequences have value semantics by default. {.shallow.} make them having reference semantics and so they share by default insstead of copying.
17:28:38FromDiscord<Clyybber> or is it up for the taking
17:28:51mipri--gc:arc --expandArc:blah helps a lot to reveal unexpected copying
17:29:03disruptekclyybber: we can work on it together, but i am prostituting myself today, so i might not be so helpful.
17:29:25FromDiscord<Clyybber> disruptek: cool
17:29:39miprias for controlling the automatic dereferencing, I think you'd have to use distinct or a wrapper object so you can get the [] you want
17:29:40disruptekit's one of this bugs that is probably simple, but the problem is not where you first look.
17:30:04disruptekso, like, we just have to work backwards and the solution will probably fall out on the floor.
17:30:10FromDiscord<Clyybber> yeah
17:30:22FromDiscord<shadow.> welp got it
17:30:23disruptekthis is one of the cps blockers.
17:30:34FromDiscord<shadow.> but i agree, that chinese remainder theorem shit is only going to be used this one time
17:30:38FromDiscord<shadow.> i dont see how that's a good challenge lmfao
17:30:41FromDiscord<dom96> disruptek: does this mean it's possible to specify what allocator closures use?
17:31:04FromDiscord<Clyybber> @dom96 not yet afair
17:31:06disruptekalso, i did confirm that the test passes when you take the macro out of the test and just compose it manually.
17:31:17disruptekor, compose it from the macro output, i mean.
17:31:33disruptekdom96: you could do that, yes.
17:31:34FromDiscord<Clyybber> compose as in result = newTree(...) ?
17:31:41FromDiscord<Clyybber> or compose as in write it down
17:31:53disrupteklike, i dumped the macro output and then put it in a file and ran it.
17:32:04FromDiscord<Clyybber> ah, yeah that works of course
17:32:30disruptekhttp://ix.io/2HSv/nim
17:32:36FromDiscord<dom96> If it's possible then mratsim should have been able to use that instead of writing his own implementation of closures, and I think this would apply to the CPS work as well.
17:32:53FromDiscord<Clyybber> writing your own closures isn't that hard or bad IMO
17:33:20FromDiscord<KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2HSx
17:33:22FromDiscord<Clyybber> but the code to get the locals is probably good to share
17:33:30disruptekit could be the best solution for alloc, yes, but you still need to rewrite the control-flow.
17:33:50disruptekyeah, i plan to make it use more of the compiler's code once it stabilizes.
17:33:59FromDiscord<KingDarBoja> sent a code paste, see https://play.nim-lang.org/#ix=2HSy
17:34:02disruptekthen cps will be harder to break during compiler changes.
17:34:19FromDiscord<KingDarBoja> But AFAIK I am not reassigning inside the loop so, what's the deal with this new error?
17:34:38disruptekjust remember that with cps, the memory stuff isn't the interesting part. πŸ˜‰
17:35:16FromDiscord<dom96> oh?
17:50:38FromGitter<fish-face> so the docs seem to imply that `{.shallow.}` is unsafe - does this essentially mean you shouldn't store shallow refs
17:50:56FromGitter<fish-face> because when the original var goes out of scope it'll be GCd or so?
17:52:37miprisurprising mutation at a distance kind of memory safety
17:53:29*a_chou joined #nim
17:56:56FromGitter<fish-face> oh right
17:57:04FromGitter<fish-face> not segfault unsafety?
17:57:12*a_chou quit (Remote host closed the connection)
17:59:48FromDiscord<Clyybber> disruptek: does it pass through afterCallActions?
18:00:15FromDiscord<Clyybber> disruptek: And does it only happen when you use the macro as a pragma?
18:01:47*abm joined #nim
18:01:55miprihttps://play.nim-lang.org/#ix=2HSH - seems to copy it anyway, weird.
18:03:01FromGitter<fish-face> mipri: what version/etc do you get the arc gc?
18:04:37mipriyou mean what's the oldest version that has it? 1.2 has --gc:arc
18:07:19FromGitter<fish-face> yeah. OK, my distro gave me 1.0.4 apparently
18:09:54*thomasross joined #nim
18:11:40FromDiscord<mratsim> @fish-face it's considered unsafe as in ref are unsafe as well because of sharing updates.
18:12:02FromDiscord<mratsim> and no if the original goes out of scope it won't be collected
18:12:13FromDiscord<mratsim> it's refcounted like other nim ref types
18:14:14FromDiscord<mratsim> @dom96 @disruptek, @Clyybber, I think I missed a beat, what is Carnac, how do you custom allocate a closure is that loadCache/storeCache? and where is that lift locals code?
18:15:16FromDiscord<Clyybber> @mratsim carnac is a memoization macro that demonstrates a compiler bug that is blocking the typed cps macro
18:15:31FromDiscord<mratsim> ok
18:17:05FromDiscord<Quibono> Could you write an iOS app in Nim?
18:18:45FromDiscord<dom96> yep
18:22:25FromDiscord<Quibono> Lol is it a PITA?
18:23:57FromDiscord<Quibono> Trying to decide if I just need to learn swift.
18:26:40miprithat's obviously going to be where the resources, frameworks, tooling, tutorials, Q&A, etc. are.
18:27:53miprithis is one of those questions where asking the question is your answer. You don't know the platform well enough to say if you could do an app in Nim, so you need all that stuff, so you can't do an app in Nim.
18:28:22FromDiscord<Quibono> Yeah fair.
18:29:51FromDiscord<Quibono> Working on this thing that my father thinks should be an app, I’d rather just have it in a webpage but he wants it to function offline lol
18:30:43FromDiscord<mratsim> Someone wrote a game on iOS that was omewhat popular
18:31:01*PMunch joined #nim
18:31:37FromDiscord<Quibono> In Nim? Huh.
18:31:50disruptekhttps://github.com/disruptek/nimph/issues/143
18:31:51disbotβž₯ nimph is racist
18:32:13disruptekc'mon people, get a fucking grip.
18:34:23*leorize quit (Ping timeout: 240 seconds)
18:40:20leorize[m]lol are you referring about nimph not understanding default branches other than master?
18:40:45mipriit's really useful to be aware of what other people are psyching themselves up to do, because they're so prepared to do that thing that they'll do it when it doesn't make sense, or on the slightest stimuli
18:41:06miprikind of like how you can hear almost pure static and then turn your head to see who just called your name. Nobody called your name; you're just super prepared to hear it.
18:41:39miprithese people are psyching themselves up to solve all the world's problems by delivering an inspiring speech in front of a crowd that will start clapping really slowly and then speed up.
18:43:15mipri(so if you want them to go away one tactic is to just applaud them for their wise words and then not do anything.)
18:46:09leorize[m]disruptek: how's IC going? is it stable enough to start writing tooling around packed ast?
18:48:06disruptekyes.
18:48:51disruptekthe word `master` doesn't appear in the nimph source.
18:49:55disruptekmaybe i'll just close this issue and let a legit user report a bug, if one is discovered.
18:50:25voidpior wait until april's 1 to put it on
18:50:29FromDiscord<UNIcodeX> "master" and "slave" are terms that are used in other industries with no malice intended. One example is a "slave cylinder" in a car.
18:50:50disruptekleorize[m]: the main problem you'll run into is that only araq is working on ic and he doesn't really collaborate. 😁
18:50:57FromDiscord<Daniel> What about color words, like white, black, green, red, ....etc↡In a way, you could label everything as racist , or some other format of conflict.
18:51:09disruptekit's ridiculous, of course.
18:51:11FromDiscord<UNIcodeX> also... slavery is not something that affects a singular race. It's an issue that plagues all of humanity; people from all walks of life.
18:51:20FromDiscord<Daniel> In this context fish a racist, for example big white shark
18:51:24FromDiscord<UNIcodeX> therefore... not "racist" as asserted
18:51:28FromDiscord<Daniel> (edit) "a" => "are"
18:51:59*leorize joined #nim
18:52:08FromDiscord<Daniel> exactly, slavery is bad, no mater what living organism it applies to
18:52:26FromDiscord<UNIcodeX> succinctly, yes. indeed.
18:54:55disruptekdon't knock it until you've tried it.
18:55:21disrupteksexual slavery has its ups and downs, and for some it's a hard, hard life. for others, it's orgasmic.
18:55:49disruptekbut this has nothing to do with anything.
18:56:00disruptekthe point is, you can't let an ideology own your language.
18:56:44FromDiscord<UNIcodeX> I mean. some people get down like that, but that's their business. πŸ™‚
18:57:12FromDiscord<UNIcodeX> (edit) "business." => "business (if they like being commanded, etc..)."
18:57:15FromDiscord<Daniel> (edit) exactly, (forced) slavery is bad, no mater what living organism it applies to
18:57:46FromDiscord<Daniel> (edit) exactly, (forced) slavery is bad, no mater what living organism it is applied to
19:00:51FromDiscord<Quibono> I mean I think it’s a small change to make people feel included.
19:00:56*vesper11 quit (Ping timeout: 256 seconds)
19:01:01FromDiscord<Quibono> But yeah you can take it too far
19:05:59FromDiscord<Quibono> And @disruptek we all let ideology control our language, you just happen to disagree with this one.
19:12:27FromDiscord<de_inferno> Okay then let's rename all functions and variables into non existant words to confuse everyone instead, profit
19:20:26FromDiscord<UNIcodeX> These conversations typically don't end well anyway so maybe we should move on.
19:21:57Zevvnarimiran: you made that up yourself?
19:22:07narimiranZevv: yes
19:22:11Zevvpfff
19:22:18narimiranafter two hours of pain
19:22:40Zevvhow long does it take
19:23:03narimiranto run? less then 1ms
19:23:08Zevvi don't even understand why it works I guess :)
19:23:15ZevvI spent an hour and gave up
19:24:02*MightyJoe quit (Quit: I'm out!)
19:28:53*fredrikhr joined #nim
19:31:44PMunchHurrah, I figured out day two :)
19:32:30Zoom[m]Didn't you have the stars for D2 already?
19:32:41PMunchWhat do you mean?
19:33:43*fredrikhr quit (Read error: Connection reset by peer)
19:35:14narimiranZevv: i knew immediately about CRT, but the last time i encountered it was in 2017 (also AOC). so i knew what to search for, but not how to implement it
19:35:38narimiranZevv: so i went to solve some simple examples on pen and paper, and then it dawned on me
19:36:14Zoom[m]I mean you have the starts, you solved it already
19:36:47Zoom[m]narimiran: the same for me! Forgot about CRT completely, even though I heard of it
19:37:05ZevvWell, I got the basics, buses being obviously prime, tried something smart with math.lcm
19:37:19Zevvbut I must admit CRT is not in my ready-cookbook
19:37:23narimiranyeah, LCM of primes is..... well.......
19:37:38Zoom[m]The thing is, it's not necessary to solve it
19:37:45narimiranZoom[m]: exactly
19:38:12Zoom[m]I'm pretty pleased with how I figured this one and path searching for adapters
19:38:23Zevvyeah but that one I got in a few mins
19:39:16Zoom[m]My version for today is still 2x loc over narimiran's. Although I have tests
19:39:57Zevvi'm reading mirans, but i don't see it
19:40:04Zevvnevermind, tomorrow's a new day
19:40:05Zevv:)
19:44:04Zoom[m]By the way, if I want to pass some distinct type, such as a named tuple, as an expression, how can I specify the type?
19:44:38FromDiscord<fwsgonzo> is there GDB support for Nim?
19:44:39PMunchZevv, mine is similar, but easier to read :P
19:44:52PMunch@fwsgonzo, yes
19:45:58ZevvPMunch: I look at yours and still don't know why it works
19:47:32PMunchYou start stepping with the first bus' offset, then when the next bus matches you know that the next such match can only occur at the current offset * this bus' number.
19:47:40FromDiscord<lqdev> @Zoom wdym?
19:47:50FromDiscord<lqdev> you can try doing `x: type YourType`
19:48:15Zoom[m]No variable
19:48:46FromDiscord<lqdev> it only works with proc/template/macro params
19:48:53Zoom[m]I mean to specify the type on the "sending side", such as the end of a block
19:49:01FromDiscord<lqdev> oh
19:49:06PMunchSo you loop with this as your offset, until you find the third bus that matches. You know that the next time they all match is as current offset * this bus' number so you continue looping with this as your offset
19:49:09ZevvPMunch: ah right, how elegant
19:49:11FromDiscord<lqdev> i don't think that's possible
19:49:19FromDiscord<lqdev> at the end of a block
19:49:19PMunchZevv, yeah it's pretty neat :)
19:49:21FromDiscord<lqdev> though maybe
19:49:34Zevvfunny I totally was not able to think of that myself
19:50:00FromDiscord<lqdev> @Zoom it totally works https://play.nim-lang.org/#ix=2HTm
19:50:00Zevvy'all much smarter anyways
19:50:02PMunchI was just throwing ideas on the wall until something stuck :P
19:51:18Zoom[m]@lqdev eh, this is probably not what I want
19:52:40Zoom[m]@lqdev I have a named tuple and I want to end an expression with it, specifying it's a distinct tuple
19:52:53*abm quit (Read error: Connection reset by peer)
19:53:32Zoom[m]That's used all the time for basic FP style ops, like map
19:53:53FromDiscord<lqdev> https://play.nim-lang.org/#ix=2HTo
19:56:15Zoom[m]That probably should work, and I'm not sure why it didn't. Probably I was doing something wrong
19:57:29Zoom[m]Or I was looking for a way to do it without full type construction (it could be tedious with large number of fields), and just add some tick to the tuple, as we can do with number literals
20:09:16*narimiran quit (Ping timeout: 256 seconds)
20:10:53*Jesin quit (Quit: Leaving)
20:11:05*fredrikhr joined #nim
20:12:40*Jesin joined #nim
20:15:14*PMunch quit (Quit: leaving)
20:23:48*hnOsmium0001 joined #nim
20:26:37*nyaayaya joined #nim
20:31:56*habamax quit (Ping timeout: 240 seconds)
21:04:04FromDiscord<kodkuce> i wanted to fallow result thing insted using return but i get Error: undeclared identifier: 'result'
21:04:17FromDiscord<kodkuce> hmm, wtf am i doing wrong
21:04:47FromDiscord<kodkuce> oh i know i am tard i dident declere retrun value in proc def
21:39:02*nyaayaya quit (Remote host closed the connection)
21:39:19*disruptek throbs.
21:40:13disruptekclyybber: does carnac work now?
21:40:36FromDiscord<Clyybber> disruptek: dunno?
21:40:47FromDiscord<Clyybber> disruptek: Did you see my earlier questions
21:41:00FromDiscord<Clyybber> does it only happen when you use the macro as a pragma?
21:41:59disrupteki dunno what afterCallActions is.
21:41:59disrupteki haven't tried it otherwise.
21:42:37disruptekit's in the wrong scope if i pass it to the macro as an argument.
21:42:41FromDiscord<kodkuce> hmm am back doing advent of code so am at day 4, i have question can i split on double newlines, like want to split when row is empty to get pasport groups
21:42:56disrupteksplitWhitespace from strutils
21:44:48FromDiscord<Clyybber> disruptek: WDYM?
21:44:52FromDiscord<kodkuce> that splits on any whities, i wanted to split only when row is empty
21:45:08FromDiscord<kodkuce> guess will just for loop it or something
21:45:20FromDiscord<kodkuce> or read and process
21:45:25FromDiscord<Clyybber> disruptek: Can you try calling the macro normally
21:47:14disruptekthe nodes aren't tagged as nfSem.
21:47:45disrupteki will try calling it "normally" now.
21:47:48FromDiscord<19> is copyMem == memcpy ?
21:48:33disruptekthat compiles, at least.
21:48:55FromDiscord<Clyybber> disruptek: So it works?
21:49:00FromDiscord<Clyybber> @19 yeah
21:50:18disruptekyeah, that seems fine, but it doesn't work because the proc isn't in the same scope as its invocation.
21:50:47disruptekhttp://ix.io/2HUa/nim
21:51:52disruptekcodegen looks fine.
21:52:29disruptekyou can remove my testes from your end if you want.
21:52:53disrupteki mean, if it helps you finish.
21:54:23FromDiscord<Clyybber> disruptek: I haven't started yet
21:54:32FromDiscord<Clyybber> just trying to tickle out what exactly the issue is
21:55:26FromDiscord<Clyybber> disruptek: I don't know what you mean with it isn't in the same scope
21:55:54FromDiscord<Clyybber> doesn't testes return a proc definition for fib1 ?
21:56:34disruptekwell, the code i pasted doesn't work because fib2 is not defined at the point of invocation.
21:57:08disruptektestes doesn't rewrite the procs, really, but again, you can remove my testes; s/testes:/when true:/
21:57:24FromDiscord<Clyybber> ok
21:57:51FromDiscord<Clyybber> and what does carnac do?
21:58:02FromDiscord<Clyybber> it returns a proc definition right?
21:58:08disruptekyeah.
21:58:42FromDiscord<Clyybber> and that proc is fib2?
21:58:45disruptekit's commented, but you can just read the "manual" version which compiles and runs correctly.
21:58:56disruptekyes, fib2.
21:59:05FromDiscord<Clyybber> so it should be in scope
22:00:10disruptekhmm, with expandMacros it /is/ in scope, but i get a nil deref at compile-time.
22:00:36*disruptek removes his testes.
22:01:14disruptekit's running now. time to find out if it works this way.
22:01:26disruptekhow did you know pragmas would be special?
22:01:34FromDiscord<Clyybber> intuition
22:01:41FromDiscord<Clyybber> and I skimmed the code once I think
22:02:07disrupteksucks.
22:02:27disruptekno runtime error. now i have to instrument it to see if it actually does its carnac magic.
22:02:36disruptekah, it doesn't.
22:02:59disruptekyeah, it's not rewriting it.
22:03:47disruptekoh, it doesn't think it's a func.
22:04:19disruptekah, because it's a stmtlist.
22:04:21disruptekfun fun fun
22:04:29FromDiscord<Clyybber> heh
22:04:42FromDiscord<Clyybber> I assumed your macro can deal with that :D
22:05:09disruptekokay, still a nil deref at ct.
22:05:28disrupteksame place as the pragma.
22:05:51disruptekso. problem unchanged from the pragma invocation, after all.
22:06:25*pbb_ quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
22:06:51*pbb joined #nim
22:12:48FromDiscord<Clyybber> ok
22:16:16*idf31 quit (Ping timeout: 240 seconds)
22:19:11*Vladar quit (Quit: Leaving)
22:23:52*kenran quit (Quit: leaving)
22:35:20*tane quit (Quit: Leaving)
22:35:57disruptekit's my testes that drag it out of scope; because it's not part of the same block, so testes assumes it can capture it as a separate test.
22:36:02disruptekdamn testes.
22:37:41disruptekeasily fixed.
22:37:47disrupteksnip, snip.
22:42:16FromDiscord<19> can someone tell me what this means: https://i.imgur.com/yh008Ky.png
22:42:48FromDiscord<19> recursion too deep?
22:47:37FromDiscord<Clyybber> disruptek: but the carnac issue remains
22:47:39FromDiscord<Clyybber> right?
22:47:48FromDiscord<Clyybber> and its a codegen issue, right?
22:48:01disruptekyes.
22:48:04disrupteki'm not a miracle worker.
22:48:04disruptekwell, i am, but only in the bedroom.
22:48:19FromDiscord<Clyybber> but the nil deref is gone
22:48:21FromDiscord<Clyybber> ?
22:48:33disruptekit's a front-end issue afaict.
22:48:33disruptekno.
22:49:41disruptekthe scope issue had nothing to do with anything. turns out pragmas aren't to blame, either.
22:49:45disruptekscope issue was just me using my testes incorrectly, yet again.
22:50:25FromDiscord<Clyybber> ok
22:51:06FromDiscord<Clyybber> I'm not at my PC atm, but I would start from afterCallActions
22:51:20FromDiscord<Clyybber> its in semexprs afair
22:51:26disruptekokay, thanks.
22:55:20FromDiscord<acek7> hello beautiful
22:56:53FromGitter<deech> In `sequtils` the proc `all` and the template `allIt` default to `true` for an empty list. I found this surprising what is the reasoning behind that?
22:57:11FromDiscord<Clyybber> it makes sense, no?
22:58:46FromDiscord<ElegantBeef> There are no items to check so there for all items meet the predicate
22:58:54FromDiscord<ElegantBeef> therefore even
22:59:42FromGitter<deech> Do all the elements in an empty list pass some predicate? I guess I could see it ... I would have expected `false` or `Option[bool]` maybe.
23:00:01FromDiscord<kodkuce> how to create an empty dict
23:00:21FromDiscord<kodkuce> initTable[string, string]() dident work :( Error: cannot instantiate: 'Table[A, B]'; Maybe generic arguments are missing
23:00:54FromDiscord<ElegantBeef> `var a = initTable[string, string]()` or `var a: Table[string, string]` should work
23:01:04FromDiscord<ElegantBeef> Did you `import tables`?
23:01:09FromDiscord<kodkuce> yes
23:01:20FromDiscord<kodkuce> var passport : Table = initTable[string, string]()
23:01:46FromDiscord<ElegantBeef> You need to give that type annotation the generic types
23:01:48FromDiscord<kodkuce> removed : Table
23:01:53FromDiscord<kodkuce> and it works now
23:02:10FromDiscord<kodkuce> var passport Table[string,string]
23:02:15FromDiscord<ElegantBeef> `var a: Table[string, string] = initTable[string, string]()` would work
23:02:16FromDiscord<kodkuce> (edit) "var passport ... Table[string,string]" added ":"
23:02:21FromDiscord<kodkuce> yep got it
23:02:22FromDiscord<kodkuce> my bad
23:02:24FromDiscord<kodkuce> ty
23:02:47FromDiscord<ElegantBeef> Use of generics like that are only usable in procs, but not really suggested
23:08:55FromDiscord<kodkuce> hmm tard question but i used wile loop for some reason is there some way to check if next row is endoffile wihout reading it?
23:09:03FromDiscord<ElegantBeef> peek
23:09:40FromDiscord<ElegantBeef> I assume you're reading aoc input data, imo it's just easier to do `data.split('\n')`
23:09:47FromDiscord<ElegantBeef> Although that makes a new string, so be warned πŸ˜›
23:11:09FromDiscord<kodkuce> ye i did split for old ones but for some reason i wanted to be perf better and wanted to do wile myinput != endoffile. but now i have issue cuz last line is not blank and cuz of that i get -1 value :(
23:12:08FromDiscord<kodkuce> from whered does peek come
23:12:12FromDiscord<kodkuce> sequtils or what?
23:12:35FromDiscord<kodkuce> rror: attempting to call undeclared routine: 'peek'
23:13:03FromDiscord<kodkuce> oh streams
23:13:06FromDiscord<kodkuce> hope it works
23:13:30FromDiscord<kodkuce> but expression 'my_input' is of type: File noooooooooo
23:13:36FromDiscord<ElegantBeef> fileStreams exist
23:14:05FromDiscord<kodkuce> oh ye easy fix
23:20:36FromDiscord<kodkuce> beh i just added 1 new line to input dont want to waste time on this
23:27:01FromDiscord<kodkuce> beh fixed it tough tarded way
23:27:19FromDiscord<kodkuce> just runed 1 more check after while loop ends
23:29:16FromDiscord<kodkuce> is in range only way to 1 line check in number inbetwin
23:57:54FromDiscord<kodkuce> hmm if i have try statment but i dont need any info from except what do i put in excapt
23:58:00FromDiscord<kodkuce> cuz i cant leave blank row