00:08:35 | FromDiscord | <ElegantBeef> `discard` |
00:11:54 | FromDiscord | <Avatarfighter> Hello hello everyone |
00:17:30 | FromDiscord | <nikki> ๐ |
00:17:50 | FromDiscord | <nikki> wrote some nim again today after 3 weeks and it feelsgoodman.jpg |
00:18:34 | FromDiscord | <Avatarfighter> @nikki im getting nim to run on my robot rn, the compiler errors feel so nice to see |
00:18:59 | FromDiscord | <nikki> nice |
00:19:25 | FromDiscord | <nikki> i disabled nimsuggest / nimlsp in my editor for now cuz i saw it take a lot of cpu a few times and i'm also tryna see if i can just remember everything |
00:19:55 | FromDiscord | <nikki> i have a terminal open with a watch-build cycle usually so i see the build output immediately and the errors from that are often better than from nimsuggest anyways |
00:20:14 | FromDiscord | <ElegantBeef> Writing Nim without suggestions when it has a ufcs, way to live wild ๐ |
00:20:44 | FromDiscord | <nikki> i feel like suggestions get wilder with ufcs haha |
00:21:04 | FromDiscord | <nikki> the watch-build window is helpful tho |
00:25:55 | * | mbomba joined #nim |
00:26:46 | FromDiscord | <Quibono> Psst, @shadow. has a question |
00:27:43 | FromDiscord | <Avatarfighter> @ElegantBeef what is ufcs? |
00:28:06 | FromDiscord | <ElegantBeef> The unform function calling syntax, or as it's listed in the manual, the method call syntax |
00:28:13 | FromDiscord | <Avatarfighter> oh |
00:28:24 | FromDiscord | <Avatarfighter> I keep forgetting the meaning |
00:28:45 | FromDiscord | <Avatarfighter> i think ive genuinely asked 4 times in the span of a month on what it meant ๐ญ |
00:29:29 | FromDiscord | <shadow.> lmao |
00:29:47 | FromDiscord | <shadow.> f(a, b) == a.f(b) == a.f b |
00:30:03 | FromDiscord | <Avatarfighter> yeah i know what it is I just meant the meaning of "ufcs" ๐ |
00:30:08 | FromDiscord | <shadow.> haha fair |
00:31:55 | FromDiscord | <Quibono> See, part of me just likes f(a,b) a.f b looks kinda... |
00:34:16 | FromDiscord | <ElegantBeef> I mean it depends on the proc for me |
00:39:00 | FromDiscord | <Quibono> Fair. |
00:39:47 | FromDiscord | <Avatarfighter> I really enjoy putting all the possible call syntax in a chain of methods lol |
00:39:56 | FromDiscord | <Quibono> ... please no. |
00:40:06 | FromDiscord | <Quibono> Also, the Nim hate in other spaces drives me nuts |
00:40:15 | FromDiscord | <Avatarfighter> nim hate!? |
00:40:33 | FromDiscord | <shadow.> ive never heard anyone hate on nim |
00:40:54 | FromDiscord | <Avatarfighter> well |
00:41:04 | FromDiscord | <shadow.> tbh the only thing ppl dislike is eco and thats a chicken and the egg type of thing |
00:41:11 | FromDiscord | <Quibono> Just had someone say it was a one off that will die in a few years, lol. |
00:41:12 | FromDiscord | <Avatarfighter> I know some rust users have stronger feelings than most |
00:41:16 | FromDiscord | <Quibono> F that. |
00:44:37 | FromDiscord | <ElegantBeef> Nim gets a lot of hate due to being so different when it comes to system programming languages |
00:45:02 | FromDiscord | <ElegantBeef> It doesnt have namespaces, it doesnt enable strict oop, and it encourages UFCS |
00:46:07 | FromDiscord | <JSGRANT> @Avatarfighter https://external-preview.redd.it/Ikj0dtD2q1f70pJtxZEJahFAJH0LkkcdtNuxMWT8Dl0.jpg?width=960&crop=smart&auto=webp&s=a8f8318d25569318691e6347b5d844db5fafee6a it's a meme but I remember pre-1.x and that vibe was real and only became more real after a bit -- RIIR (rewrite it in rust!) was "the catchphrase" in that community for a LOOOOONG time much to the behest of a lot of 3rd-party opensource contributors. lol |
00:47:24 | FromDiscord | <ElegantBeef> I've seen people dislike that it's "transpiled" and also disbelieve it can be as fast as Rust if not faster |
00:49:06 | FromDiscord | <JSGRANT> @ElegantBeef Well it's also categorically 'hard' to place. It "looks" like Python; So people expect it to basically be in the same relationship Crystal has with Ruby... even though most actual users know it's (I think rather obviously) more Pascaly all-in-all. A lot think a GC is disqualifying for a systems-programming language without looking into and/or listening about "the good word" (lol) about ARC/ORC, etc. |
00:51:04 | FromDiscord | <JSGRANT> Transpiled felt weird initially; Pretty much all on me -- and my expectations of it being "more pure" if the IR was LLVM or something. Got over that quickly, when I realized the first-class FFI Nim has ... that I'm not convinced you'd also "get for free" if we went LLVM :^P |
00:51:34 | FromDiscord | <himu> Oh. man . FFI was so easy for even a noob like me. |
00:51:41 | FromDiscord | <Avatarfighter> the issue is that a lot of people dont actually try out the language which sucks because they judge nim by its syntax. |
00:53:28 | FromDiscord | <ElegantBeef> Well ARC is an issue cause people see it and think it's like swifts and not like Rust's GC |
00:54:13 | FromDiscord | <Avatarfighter> yeah |
00:54:30 | FromDiscord | <Avatarfighter> that's just because of the name ๐ญ |
00:54:31 | FromDiscord | <JSGRANT> @ElegantBeef re: Perception of it not being "as fast"; Think a lot it has to do is people view Rust "as a C++ replacement" and as-said, I think wrongly Nim "as a Python replacement" so it's unfortunate but expected people also draw these comparisons in terms of performance. A "faster Python" ... I mean, a 2x - 3x speedup would be a BIG DEAL; They think it's at this tier -- marginally better ... not that Nim beats the ever-loving ssssss ( |
00:57:14 | FromDiscord | <JSGRANT> Beeeeiiiilllve me; I feel like I talk about Lisp a lot in here (I do. lol) but yeah, sadly most people take a quick glance at the syntax of a language and make WIDE assumptions based on it. |
00:57:43 | FromDiscord | <Avatarfighter> yeah |
00:58:30 | FromDiscord | <JSGRANT> And really they just overhear certain things; Don't even look into it AT ALL. And repeat these (actually wrong) truisms ad naseum -- the amount of times I've heard people call LISP ('Common Lisp') a functional-language .... loooooool |
00:58:53 | * | krux02 quit (Remote host closed the connection) |
00:59:55 | FromDiscord | <JSGRANT> That being said being syntactically similar enough to Python where you have more eyes on Nim just because people assume it's a "Python-like 'systems language' " is not the WORST problem to have. |
01:00:18 | FromDiscord | <Quibono> Yeah I initially came over because it was fast python lol |
01:00:34 | FromDiscord | <Avatarfighter> The issue I see is that because people assume its a Python-like language they assume we're running the latest and greatest interpreter from 2010 and think we're slow ๐ฆ |
01:00:36 | FromDiscord | <JSGRANT> Retention rate might be somewhat low -- but that doesn't matter if there's a lot more people looking into it generally. |
01:03:06 | FromDiscord | <ElegantBeef> I think that is a slight issue as it isnt "fast python", atleast in my view |
01:03:58 | FromDiscord | <Avatarfighter> Does anyone have nimterop experience ? |
01:04:08 | FromDiscord | <Avatarfighter> if so may I borrow your knowledge for a bit |
01:04:37 | FromDiscord | <JSGRANT> This is about what I was going to say; it depends who we were going after -- and I think this (people who get into Nim as a "faster python") is a secondary market at best. |
01:07:56 | FromDiscord | <himu> sent a long message, see http://ix.io/2HWF |
01:08:35 | FromDiscord | <ElegantBeef> I mean you can do recursive module imports, you just have to do it properly |
01:09:11 | leorize[m] | once ic is out recursive modules might be implemented |
01:09:24 | FromDiscord | <Avatarfighter> I remember when I had a circular import with python I think that took a week to figure out why |
01:09:45 | FromDiscord | <himu> what's ic? |
01:09:50 | FromDiscord | <ElegantBeef> Incremental compiler |
01:09:51 | FromDiscord | <Avatarfighter> incremental compilation |
01:10:13 | FromDiscord | <Avatarfighter> https://en.wikipedia.org/wiki/Incremental_compiler |
01:10:29 | leorize[m] | it has little to do with the feature but more to do with the massive refactoring of the backend |
01:10:31 | FromDiscord | <JSGRANT> sent a long message, see http://ix.io/2HWJ |
01:11:14 | FromDiscord | <himu> okay. that would be a great thing. |
01:11:25 | FromDiscord | <ElegantBeef> Well you cannot really ever say "It's nim all the way down" due to the fact no one is going to rewrite Opengl/vulkan in pure nim ๐ |
01:11:45 | FromDiscord | <himu> it also improves compile times I guess? |
01:12:12 | FromDiscord | <Avatarfighter> yeah, if you have a big project it'll only compile the parts that were updated instead of the whole project each time you compile @himu |
01:12:39 | FromDiscord | <JSGRANT> @ElegantBeef Well .... you can do some cool DSLs there to hide some the more ugly stuff; Also don't challenge @disruptek loooool |
01:13:05 | FromDiscord | <Avatarfighter> disruptek is nimginer |
01:13:16 | FromDiscord | <Avatarfighter> (edit) "nimginer" => "nimgineer" |
01:13:45 | FromDiscord | <JSGRANT> @ElegantBeef Since you mentioned it earlier; I forgot to ask -- is your opinion still that namespaces in Nim would be a "good thing โข๏ธ " ? |
01:15:00 | FromDiscord | <ElegantBeef> I'm very adamant about writing non repetitive code, so i dont really want namespaces as much as a way to easily make a module that has imports/exports without manually making it |
01:15:33 | FromDiscord | <ElegantBeef> That view is the whole reason `devel` now has `scanTuple` ๐ |
01:15:49 | FromDiscord | <ElegantBeef> Using scanf during aoc caused me to want something that could infer the types |
01:18:09 | FromDiscord | <JSGRANT> Also that reminds me ... I completely forgot until now; I forked NimSL like 2-3 months ago and literally haven't even made a single commit to it. Was going to use it to learn GLSL generally. Wish I had one of these "wow I'm bored" Covid experiences -- so many stuff I wanted to get to this year, but have just been exhausted .... had a friend literally contact me yesterday and complained about how boooored he was watching Anime marathons fo |
01:19:05 | * | rockcavera joined #nim |
01:19:22 | FromDiscord | <Avatarfighter> is anyone able to build the most recent version of nimterop? |
01:19:44 | FromDiscord | <Avatarfighter> getting `Error: find has no param matching "help" key "recurse"` when building |
01:19:54 | FromDiscord | <JSGRANT> @ElegantBeef I think that's fair; Guess you could make a "prelude" styled import cabal everytime ... but yeah, seems like overkill. Not sure if you could reasonably do the eqv for exports |
01:20:26 | FromDiscord | <ElegantBeef> If you say shashlick three times avatar someone might appear ๐ |
01:20:52 | FromDiscord | <himu> one more thing I wanted to ask is how does Nim handle lambda lifting and C FFI? |
01:20:59 | FromDiscord | <Avatarfighter> I don |
01:21:15 | FromDiscord | <Avatarfighter> I wanna say shasklick shasklick shasklick but I'm unsure if it'll work ๐ |
01:21:34 | FromDiscord | <ElegantBeef> Well nim's compiler doesnt compile modules that arent imported so the "namespace" thing is pretty much impossible to implement gracefully |
01:21:45 | FromDiscord | <Avatarfighter> just rewrite the compiler /s |
01:21:53 | FromDiscord | <Avatarfighter> (edit) "just rewrite the compiler ... /s" added "again" |
01:47:20 | FromDiscord | <Quibono> If anyone algotrades I'm writing a SDK for Alpaca. |
01:49:45 | * | astronavt joined #nim |
01:50:07 | FromDiscord | <Quibono> Probably going to do one for Oanda too but it's painful and slow lol |
02:11:50 | Evolver | Quibono: Alpaca sounds great. What's the URL? |
02:12:13 | FromDiscord | <Quibono> https://github.com/QuixoticValentine/Nimpaca |
02:12:17 | FromDiscord | <Quibono> PRs more than welcome. |
02:13:00 | FromDiscord | <Quibono> right now my paper-trading keys are in there just for ease of testing |
02:13:24 | Evolver | I would .gitignore .DS_Store |
02:13:29 | FromDiscord | <19> its weird i am building an executable in debug mode it throws some depth exceptions for recursions but in release mode it keeps running forever |
02:13:48 | FromDiscord | <19> (edit) "its weird i am building an executable in debug mode it throws some depth exceptions ... for" added "and crashes" |
02:14:08 | Evolver | Maybe it can only debug so much |
02:14:45 | FromDiscord | <19> so i am forever limited in debug mode? |
02:15:06 | FromDiscord | <19> im using some funky sdl2 callback. maybe thats what's causing the recursions |
02:15:34 | FromDiscord | <19> i mean, its a game loop that's supposed to go on and on |
02:15:36 | FromDiscord | <Quibono> I feel like we need a finance community section |
02:17:13 | FromDiscord | <Quibono> Also if anyone has comments on making the API SDK better I'd appreciate it |
02:17:16 | leorize[m] | @himu c ffi is done by basically compiling to c :p |
02:18:39 | leorize[m] | and I'm pretty sure in the compiler source there's something called liftlocals.nim that do the lambda processing |
02:58:03 | * | tiorock joined #nim |
02:58:03 | * | tiorock quit (Changing host) |
02:58:03 | * | tiorock joined #nim |
02:58:03 | * | rockcavera quit (Killed (beckett.freenode.net (Nickname regained by services))) |
02:58:03 | * | tiorock is now known as rockcavera |
02:58:09 | disruptek | circular imports can happen in 1.8, in theory. i think it's a pretty minor feature that could go in earlier but it would probably confuse the ic testing too much to mix the two. |
03:11:32 | * | mbomba quit (Quit: WeeChat 3.0) |
03:20:11 | * | a_chou joined #nim |
03:32:23 | disruptek | clyybber: afterCallActions doesn't get called after my macro, so, yeah, that's a bummer. i am looking at pragma processing now, even though we know it's not pragmas per se that are the problem. |
03:50:14 | Evolver | Can I have a leading underscore in a module name? If I can, how do I import it? |
03:56:27 | disruptek | no. |
03:59:02 | FromDiscord | <Rika> you cannot |
04:01:00 | disruptek | rude. |
04:02:05 | FromDiscord | <Rika> lol |
04:02:32 | * | spiderstew_ joined #nim |
04:03:13 | FromDiscord | <ElegantBeef> Leading underscore makes me think you come from python |
04:03:18 | disruptek | clyybber: it does get called after `carnac:` form, but weirdly, that doesn't help. i tried wrapping in a couple typed macro blocks and it /still/ doesn't sem those identifiers. |
04:03:20 | FromDiscord | <Rika> lmao |
04:04:43 | * | leorize quit (Ping timeout: 240 seconds) |
04:05:37 | * | spiderstew quit (Ping timeout: 246 seconds) |
04:05:50 | FromDiscord | <ElegantBeef> also i dont know what the issue is `leadingunderscoremodule` is a valid name ๐ |
04:06:01 | * | supakeen quit (Quit: WeeChat 2.9) |
04:06:32 | * | supakeen joined #nim |
04:20:22 | * | thomasross quit (Ping timeout: 260 seconds) |
04:22:19 | * | leorize joined #nim |
04:26:17 | disruptek | clyybber: carnac works, but for all the wrong reasons. |
04:26:47 | disruptek | clyybber: look at this: https://github.com/disruptek/carnac/blob/master/tests/test.nim#L35 |
04:27:06 | FromDiscord | <Avatarfighter> damn this disruptek kid sure has a lot of libraries |
04:27:39 | disruptek | that guy is an asshole. |
04:28:00 | FromDiscord | <Avatarfighter> i bet he uses linux what a need |
04:28:02 | FromDiscord | <Avatarfighter> Nerd |
04:28:02 | FromDiscord | <Avatarfighter> fuck |
04:28:22 | FromDiscord | <Rika> Need |
04:28:49 | disruptek | i have a /need/. |
04:28:54 | disruptek | a /need/ to use linux. |
04:30:20 | Evolver | Is there a way to write this more succinctly: if foo == "x" or foo == "y" |
04:30:20 | Evolver | Should I write it as: if foo in ["x", "y"] |
04:35:34 | FromDiscord | <Rika> you can yeah |
04:35:44 | FromDiscord | <Rika> prolly negligible difference in performance |
04:36:16 | disruptek | i write it the second way because it's easier to read. |
04:38:16 | FromDiscord | <ElegantBeef> should write it `{"x", "y"}` |
04:38:33 | FromDiscord | <ElegantBeef> Whoops as chars |
04:39:27 | FromDiscord | <ElegantBeef> Atleast if it's an ordinal that's capable of being placed in a built-in set |
04:39:28 | Evolver | OK. My actual values are of another type. |
04:40:04 | Evolver | but I guess I'll keep the set in mind for a bigger number of items |
04:45:05 | * | a_chou quit (Remote host closed the connection) |
04:45:25 | disruptek | builtin sets hold ordinals up to 16bit. IntSets hold ints. other types go into HashSets. |
04:45:47 | disruptek | PackedSets are a generic form of IntSets for any ordinal. |
04:46:49 | disruptek | the set syntax that's useful is {x, y, z} == {0} or such... |
04:47:20 | disruptek | sets compose /really/ nicely with nim's enums. |
04:47:55 | Evolver | I see |
04:51:35 | * | narimiran joined #nim |
04:56:32 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
05:00:09 | * | spiderstew joined #nim |
05:02:25 | * | spiderstew_ quit (Ping timeout: 240 seconds) |
05:18:26 | * | a_chou joined #nim |
05:34:11 | * | a_chou quit (Quit: a_chou) |
05:34:37 | * | a_chou joined #nim |
05:34:46 | * | a_chou quit (Client Quit) |
06:55:38 | * | habamax joined #nim |
07:40:14 | * | krux02 joined #nim |
07:47:42 | Zevv | I tried to optimize sets once becasue Npeg uses them extensively |
07:47:52 | Zevv | I failed. The are utterly optimized already. |
07:57:44 | FromDiscord | <ElegantBeef> Well they're bitsets, i dont know how you can do much better |
07:57:59 | FromDiscord | <ElegantBeef> Short of being more efficient on memory but using ranges |
07:58:08 | FromDiscord | <mratsim> There is already a topic about this, it all depends on what you need |
07:58:10 | FromDiscord | <ElegantBeef> (edit) "but" => "bye" |
07:58:15 | FromDiscord | <ElegantBeef> god damn i cannot type |
07:58:47 | FromDiscord | <mratsim> for memory, unless you care about 1 byte vs 2-byte they are optimal |
07:58:55 | FromDiscord | <mratsim> for speed, also |
07:59:16 | FromDiscord | <mratsim> for random pop they aren't so if random sampling from a set is important you need tow rite your own. |
07:59:32 | FromDiscord | <mratsim> different tradeoffs. |
07:59:44 | FromDiscord | <mratsim> Also they are threadsafe which is quite interesting. |
08:00:01 | FromDiscord | <mratsim> and they work at compile-time |
08:02:04 | * | PMunch joined #nim |
08:03:23 | ForumUpdaterBot | New thread by Archnim: Nim for mobile, see https://forum.nim-lang.org/t/7251 |
08:14:52 | * | Zoom[m] quit (Ping timeout: 260 seconds) |
08:15:00 | * | Zoom[m] joined #nim |
08:16:54 | * | supakeen quit (*.net *.split) |
08:16:54 | * | rockcavera quit (*.net *.split) |
08:16:54 | * | oculux quit (*.net *.split) |
08:16:54 | * | clemens3_ quit (*.net *.split) |
08:16:54 | * | bozaloshtsh quit (*.net *.split) |
08:16:54 | * | nickster quit (*.net *.split) |
08:16:54 | * | bacterio quit (*.net *.split) |
08:19:30 | * | idf31 joined #nim |
08:22:20 | * | supakeen joined #nim |
08:22:20 | * | rockcavera joined #nim |
08:22:20 | * | oculux joined #nim |
08:22:20 | * | clemens3_ joined #nim |
08:22:20 | * | bozaloshtsh joined #nim |
08:22:20 | * | nickster joined #nim |
08:22:20 | * | bacterio joined #nim |
08:24:25 | FromDiscord | <kenran> I found a couple of topic regarding this but nothing that looks recent: do you know of any existing freetype bindings (or anything else that's performant if I want to render text in OpenGL) for Nim? |
08:31:27 | * | kenran joined #nim |
08:45:42 | FromDiscord | <kenran> Or would it be easy to write bindings to just the functions I need maybe.. gotta find out |
08:52:31 | PMunch | @kenran: https://nimble.directory/search?query=freetype |
08:55:06 | kenran | PMunch: ah yes, I stumbled over that one, but https://forum.nim-lang.org/t/4898 mentions that it "does not work", whatever it means. I might try and see how to use it anyway (which might result in more newbie questions here...) |
08:56:40 | PMunch | Ah, yeah I see that the last commit was 4 year ago.. |
08:57:33 | FromDiscord | <mratsim> When csize is removed, all bindings from before 2019 will stop working |
08:58:33 | PMunch | Will that happen anytime soon? And is there a switch to bring it back? |
09:02:33 | FromDiscord | <mratsim> The only reasonable thing to do is only remove it on Nim 2.0 |
09:05:39 | kenran | I used {.importc: "some_function", header: "<stdlib.h>".} to import some POSIX functions that were not already present. Can I do the same for freetype when it is installed, or is stdlib.h a special example? |
09:06:21 | PMunch | No you can do that with anything |
09:11:16 | * | letto quit (Ping timeout: 256 seconds) |
09:15:34 | * | letto joined #nim |
09:19:00 | * | hnOsmium0001 quit (Quit: Connection closed for inactivity) |
09:35:34 | Araq | kenran: thereare also pure Nim font rendering libraries around |
09:35:48 | Araq | iirc fidget uses one, please check it out |
09:36:24 | Araq | also SDL2 works with openGL and offers some primitive font rendering |
09:39:58 | FromDiscord | <kenran> Araq, thanks, I didn't even think to search for one! It seems to use https://github.com/treeform/typography which looks great. Let's see if I manage to use it, since I have no idea of this stuff yet. But pure Nim is surely easier to use than C stuff. |
09:43:12 | PMunch | I don't think typography does direct OpenGL rendering though |
09:43:18 | PMunch | I was about to suggest it earlier |
09:43:55 | FromDiscord | <ElegantBeef> Well it draws to images so draw ontop of the opengl frame buffer ๐ |
10:25:45 | * | Q-Master quit (Ping timeout: 240 seconds) |
10:25:52 | ForumUpdaterBot | New thread by Giga84: IS there any beginner friendly tutorial for nim with examples like "Python crash course" etc.?, see https://forum.nim-lang.org/t/7252 |
10:34:35 | FromDiscord | <sealmove> @PMunch hey, can you explain the stuff with fixed-length strings? |
10:35:08 | FromDiscord | <sealmove> I don't get it, why`s: myString[10]` instead of `s80: myString`? the latter works |
10:36:55 | PMunch | Currently the way binaryparse works is that strings are always 8 bit per character, and you specify the amount of characters to read by the [] notation. |
10:37:27 | FromDiscord | <sealmove> oh, ok I completely changed this. New implementation doesn't need arrays for this. |
10:37:45 | PMunch | I would expect s80: myString to read a one character string where the character uses some fictional 80-bit character literals |
10:38:31 | FromDiscord | <sealmove> but isn't this confusing? why not keep same rules for strings as other fields? |
10:39:13 | PMunch | It is the same rule |
10:39:37 | PMunch | The number sets the size of the unit, the brackets sets the length to read of that unit |
10:40:57 | PMunch | A string is basically just an array of characters |
10:41:36 | FromDiscord | <sealmove> :S then you would do `u8: myString[10]` |
10:41:57 | FromDiscord | <sealmove> string is a string, not seq[char] |
10:42:00 | PMunch | u8? That would be to read 10 unsigned 8-bit integers |
10:42:56 | PMunch | Well string isn't always a string. Many formats uses fixed length strings, but maybe it's a NULL-terminated string |
10:43:21 | FromDiscord | <lqdev> btw pmunch |
10:43:31 | FromDiscord | <lqdev> how do you parse a length-prefixed string |
10:43:35 | PMunch | For example what if my format has a u8: strLen field and then a s: myStr[strLen] |
10:43:42 | FromDiscord | <lqdev> didn't see that in your readme |
10:43:48 | PMunch | lqdev, like that ^ |
10:43:50 | FromDiscord | <sealmove> well i find the design you are describing confusing. currently [] notation is used for producing a seq[] of whatever is on the left side |
10:43:52 | FromDiscord | <lqdev> oh cool |
10:43:59 | FromDiscord | <sealmove> and `s` means string |
10:44:20 | PMunch | Which is a sequence of characters |
10:44:32 | FromDiscord | <sealmove> `s` without size is null-terminated, `s` with size (for example `s80`) is string of that length in bits |
10:44:56 | FromDiscord | <sealmove> yes sure it's a seq[char] but to Nim it maps to `string`, isn't this more natural? |
10:44:56 | PMunch | But easier to compare against other strings that = @['h', 'e', 'l', 'l', 'o'] |
10:45:44 | PMunch | But now you can't do the kind of length-prefixed strings lqdev just asked about.. |
10:47:48 | FromDiscord | <sealmove> oh, so it's useful because you can use size as a value (potentially found in prev fields), i understand now |
10:48:01 | PMunch | Yup |
10:48:10 | FromDiscord | <sealmove> ok, i'll have to think about this |
10:48:35 | PMunch | I used this when parsing DNS for example |
10:48:43 | PMunch | It uses length-prefixed strings |
10:49:57 | PMunch | We could theoretically also support s7: oldString[10] to read pre-ASCII strings |
10:50:29 | FromDiscord | <Clyybber> disruptek: Hmm, so why does it work? |
10:51:10 | FromDiscord | <sealmove> ok, so the implementation for strings needs work, but I still don't like using [] notation for this. it's simply used to make a seq out of your type, and it working differently for strings will be confusing |
10:51:19 | PMunch | Well not really pre-ASCII, it was originally 7 bits long as well |
10:51:38 | PMunch | It's not really working differently, and IMO is the most intuitive |
10:51:56 | FromDiscord | <sealmove> what if you want seq of strings? |
10:52:01 | PMunch | No one has complained about this yet :P |
10:52:16 | PMunch | Then you need a sub-parser |
10:53:15 | PMunch | But I haven't come across any formats with multiple strings after each other |
10:53:44 | PMunch | Well, DNS does it, but with length-prefixed strings, so it would've needed a sub-parser anyways |
10:53:58 | PMunch | And it has it's weird compression scheme |
10:54:30 | PMunch | Most often strings are used as small fixed-size magic elements |
10:55:26 | * | Q-Master joined #nim |
10:55:35 | PMunch | Or length-prefixed strings |
10:57:37 | FromDiscord | <sealmove> ok so basically a good implementation is `s: x[10]` to work in similar way as: string( `u8: x[10]`) |
10:58:07 | PMunch | Yeah that's pretty much how it works now |
10:58:13 | FromDiscord | <sealmove> and `s: x[]` for null terminated? |
10:58:18 | PMunch | Yup |
10:58:25 | FromDiscord | <sealmove> good good, I'll fix it ๐ |
10:58:32 | PMunch | Great :) |
10:58:54 | FromDiscord | <sealmove> thx for the review btw |
10:59:18 | PMunch | Of course, I always review PRs to my repos .) |
10:59:23 | PMunch | :)* |
11:02:24 | FromDiscord | <sealmove> about seqs that are terminated on specific value... do you think we need to have a way to allow user to either include or discard the matched value? |
11:02:40 | PMunch | Ah yes, I meant to discuss this as well |
11:02:47 | PMunch | The current system allows this |
11:02:53 | FromDiscord | <sealmove> how? |
11:03:21 | PMunch | u8: mySeq[]; u8: magicEnd = 255'u8 |
11:03:27 | PMunch | u8: mySeq[]; u8: _ = 255'u8 |
11:03:30 | PMunch | Like that |
11:04:02 | FromDiscord | <sealmove> but magicEnd is not included in the seq? but given as separate field? |
11:04:16 | PMunch | Ah yes, it's a separate field |
11:04:47 | PMunch | But that is the thing I wanted to discuss, I find the current way easier to reason about |
11:05:02 | FromDiscord | <sealmove> we can do better, currently `{}` is used for terminating on arbitary condition (and include last elem). we could use for example `()` for doing the same but excluding last elem |
11:05:32 | PMunch | You can simply read the lines one by one and have an idea for how many bytes will be read. With the until syntax I need to also read the end of sequence statements to see if they have an until condition |
11:07:48 | FromDiscord | <sealmove> can you elaborate? |
11:09:50 | PMunch | Well currently if I'm translating a spec it's often written as a diagram of the fields. This maps nicely to the DSL where each line is a field. With the until syntax this pattern breaks and I can now technically have a "hidden" field in the magic. |
11:10:25 | FromDiscord | <sealmove> so basically you want it as separate field |
11:10:48 | PMunch | I find it more intuitive to read at least |
11:11:09 | PMunch | Besides, with the previous system you could have a magic of another size that the element size |
11:11:23 | PMunch | s/that/than |
11:12:19 | FromDiscord | <sealmove> hmm ok i see |
11:12:34 | PMunch | s: myString[]; u1: _ = 1 for example would read a string only as long as the low 7 bits where used, and stop when any character higher than 127 was found |
11:13:43 | PMunch | I've never come across this though, so keeping that behaviour isn't super-important |
11:14:07 | PMunch | You can also do s: myString[]; s: _ = "END" for example |
11:14:33 | FromDiscord | <sealmove> we can both do this and keep the {} until syntax |
11:14:39 | * | Vladar joined #nim |
11:14:46 | FromDiscord | <kodkuce> am i retarded or duno how to write regex for nim, i just want 0-9 a-f |
11:15:18 | FromDiscord | <kodkuce> i tryed [0-3] and gived "32425" and it give me true wtf i have 4 and 5 |
11:15:25 | PMunch | @sealmove, that is true |
11:15:54 | PMunch | Try ^[0-3]*$ |
11:16:12 | PMunch | @kodkuce ^ |
11:16:43 | FromDiscord | <sealmove> PMunch this is not specific to strings right? |
11:16:48 | PMunch | [0-3] matches the '3' in "32425", so it does match, just not the whole string |
11:17:06 | PMunch | @sealmove, nope, this is true for all arrays |
11:17:35 | PMunch | When the next field is magic then it will peek that before adding things to the array |
11:18:02 | FromDiscord | <sealmove> oh wait, so you do add it to the array |
11:18:13 | FromDiscord | <kodkuce> yep i think i dont know this regex magic does $ mean each letter? |
11:18:17 | FromDiscord | <sealmove> but what if it's can't be added (different type) |
11:18:19 | FromDiscord | <kodkuce> (edit) "letter?" => "char?" |
11:18:59 | FromDiscord | <sealmove> @kodkuce `` means '0 or more times' |
11:19:02 | PMunch | @sealmove, no it isn't added |
11:19:27 | PMunch | @kodkuce, the $ means the end of the string |
11:19:35 | FromDiscord | <kodkuce> ^ << front |
11:19:46 | FromDiscord | <kodkuce> so from from to end :) |
11:19:51 | FromDiscord | <kodkuce> ty |
11:20:26 | PMunch | ^[0-3]*$ breaks down to ^: start of string, [0-3]: any character in the range 0-3, *: zero or more times, $: end of string |
11:20:57 | PMunch | Note that it also matches the empty string |
11:21:17 | PMunch | If you want at least one character you can do ^[0-3]+$ |
11:22:20 | FromDiscord | <sealmove> ok. last but not least, about bit-endian. unaligned data really don't have the concept of regular endian, because regular endian has to do with byte ordering |
11:22:22 | * | Torro joined #nim |
11:23:08 | PMunch | Well if the data is byte-sized it would still apply |
11:23:36 | PMunch | u4: start; lu32: littleEndian; u4: stop |
11:24:06 | PMunch | That for example, the littleEndian number there is still 4 bytes long and can have byte ordering just fine |
11:24:07 | FromDiscord | <sealmove> i guess in theory yes |
11:24:56 | FromDiscord | <sealmove> but in practice is this ever the case? when ppl use regular endian they have aligned bytes |
11:26:05 | PMunch | Not necessarily |
11:26:25 | FromDiscord | <sealmove> i mean, in the case you are describing, using little bit-endian will weird the same result |
11:26:59 | FromDiscord | <sealmove> mixing the concept of normal is and bit endian is very confusing for no reason i think |
11:27:04 | PMunch | If I was on a small endian machine I could simply do bit-shifting like I would normally do and end up with a little-endian number in that format |
11:27:26 | PMunch | TBF I have never seen other bit-endianes |
11:27:31 | PMunch | Only byte-endianes |
11:30:31 | FromDiscord | <sealmove> PMunch, applying little bit-endianness to a 32-bit long unaligned bitfield will give you the same little endian number you would get if it was aligned |
11:31:02 | PMunch | Uhm, no it wouldn't |
11:31:47 | PMunch | Little endian is DCBA instead of ABCD where the letters are bytes that are ordered the same way in both cases |
11:38:39 | FromDiscord | <sealmove> hmm yes you are right. my previous statement is completely wrong ๐ so you are saying we shouldn't assume a number is a bitfield instead of a byte-sized number based on alignment |
11:39:05 | FromDiscord | <sealmove> well, kaitai for example uses `b` notation for bitfields and `u` for integers |
11:39:06 | PMunch | Correct |
11:39:23 | FromDiscord | <sealmove> so you would write `b32` and it would be different |
11:39:25 | PMunch | I typically parse my bitfields into separate u1's |
11:40:12 | FromDiscord | <sealmove> would you like to use `b` also? it would simply things a lot since bit fields map to different read proc |
11:40:21 | FromDiscord | <sealmove> simplify |
11:41:12 | PMunch | Why are they different? |
11:41:56 | FromDiscord | <sealmove> the underlying reads? |
11:42:02 | PMunch | I'm not sure if I understand what you mean by bitfields.. |
11:45:55 | FromDiscord | <sealmove> well, here is the situation. aligned reads use `streams` modules regular reads, so `readUInt32` etc. These are wrapped by procs like `readUint32Be` and `readUint32Le` which just swap endianness or not based on your system's endiannes. For unaligned data special procs are used. There is `readBitsBe` and `readBitsLe`. |
11:47:30 | FromDiscord | <sealmove> so an aligned 32bit int will be mapped to a different read proc compared to a 32bit unaligned int |
11:48:07 | PMunch | Aha |
11:48:18 | PMunch | In my original implementation everything went through the same read procs |
11:48:56 | PMunch | And it basically just know the current bit offset and made sure to read the right about and shift it around |
11:50:01 | FromDiscord | <sealmove> is it possible to keep track of the offset even when custom parsers are used? |
11:50:26 | PMunch | No those need to be aligned I think |
11:50:37 | PMunch | I mean it would be possible to allow it |
11:50:52 | FromDiscord | <sealmove> i don't keep track of offset within the compiler at all. it's taken care by the bistream structure |
11:51:04 | PMunch | I thought that was what your bitstream thing did |
11:51:23 | FromDiscord | <sealmove> yes, but it's external to the compiler |
11:51:28 | PMunch | I thought that would just expose an API of "read N bits" and it would handle the rest |
11:51:51 | PMunch | External to the compiler? |
11:52:58 | FromDiscord | <sealmove> i mean binaryparse has no info about offset, it's considered at runtime by bitstream object. no, bitstream doesn't expose 1 generic read proc, although it could. |
11:53:25 | PMunch | Ah I see what you mean |
11:55:18 | FromDiscord | <sealmove> so basically, although not necessary, it would help if the user specify `b` to indicate a special kind of read... |
11:56:01 | PMunch | But as far as the user is concerned there's nothing special about that field |
11:56:19 | PMunch | Besides, 'b' is already used for big-endian |
11:57:11 | FromDiscord | <sealmove> oh right lol |
12:01:27 | FromDiscord | <sealmove> hmm ok so basically the implementation I am using assumes big byte endian for unaligned data i guess, and we need to support little endian too, then allow the use of l/b along with n/r |
12:05:24 | FromDiscord | <sealmove> no, it uses system's endianness |
12:06:01 | * | supakeen quit (Quit: WeeChat 2.9) |
12:06:32 | * | supakeen joined #nim |
12:10:11 | FromDiscord | <sealmove> ok, if this is true, it's just a matter of detecting if it's byte-sized, and then using `swapEndian` if needed. |
12:10:52 | PMunch | Pretty much |
12:16:39 | FromDiscord | <sealmove> what about bit-endian on aligned reads? does it still make sense in that context? |
12:17:49 | PMunch | Why wouldn't it? |
12:18:11 | PMunch | In as far that it makes sense to begin with |
12:18:16 | FromDiscord | <sealmove> standard reads use big bit-endian? |
12:18:27 | * | xet7 quit (Remote host closed the connection) |
12:19:07 | FromDiscord | <sealmove> readUInt32 for example is big bit-endian + `cpuEndian` byte-endian? |
12:19:22 | PMunch | I think so |
12:24:37 | FromDiscord | <sealmove> ok... damn these stuff are so confusing to me :S |
12:28:07 | PMunch | There's a reason why I wanted to put this all in a library |
12:28:15 | PMunch | So that i wouldn't have to worry about it later :P |
12:35:45 | * | xet7 joined #nim |
12:35:58 | FromDiscord | <sealmove> Well now they are in a library ;) |
12:35:59 | FromDiscord | <kodkuce> lol i was like wtf why is my aoc not working and just now saw i put 0-8 in regrex insted 0-9 life sux |
12:36:00 | * | FromDiscord quit (Remote host closed the connection) |
12:36:18 | * | FromDiscord joined #nim |
12:40:12 | * | natrys joined #nim |
12:46:07 | mipri | \d |
12:48:30 | PMunch | @kodkuce, should've used npeg ;) |
12:48:33 | PMunch | Or \d I guess |
13:01:03 | * | opal quit (Ping timeout: 240 seconds) |
13:03:02 | * | opal joined #nim |
13:18:30 | * | haxscramper joined #nim |
13:19:19 | haxscramper | narimiran: can you please also merge my other package https://github.com/nim-lang/packages/pull/1747 ? |
13:19:20 | disbot | โฅ Add package htsparse |
13:19:51 | narimiran | haxscramper: of course |
13:26:42 | * | fanta1 joined #nim |
13:28:46 | * | lritter joined #nim |
13:37:57 | * | nyaayaya joined #nim |
13:39:01 | * | nyaayaya quit (Client Quit) |
13:39:24 | * | nyaayaya joined #nim |
13:43:40 | narimiran | hey AoC-ers, does anybody have some fast technique for part 2? my converting to string and back zillion times is meh |
13:47:28 | mipri | I just straightforwardly turned everything to numbers when reading the input. The challenge for part 2 is that the part 1 example is extremely scary (2^34 addresses for the one mask) but the actual input and the part 2 examples are much more tractable |
13:49:01 | mipri | part2 was just: loop over the 'X'es in the mask: loop over the addresses so far: set the corresponding X bit to 1 and then add a new address with that same bit set to 0 |
13:50:52 | narimiran | mipri: recursion? |
13:50:58 | mipri | no, just two loops |
13:51:16 | narimiran | mipri: do you have your code in some repo? |
13:56:41 | mipri | no, for the inner loop I loop over indices, so I can safely mutate (to set 1 bits) and extend (to add copies with 0 bits) it for that 'X' |
14:02:46 | * | idf31 quit (Ping timeout: 256 seconds) |
14:13:49 | mipri | so the inner loop doubles the length of the array each time it's run, which is once per 'X', with the original member of the array the modified value from the input. |
14:28:25 | * | Torro quit (Quit: bye) |
14:28:36 | FromDiscord | <hugogranstrom> I did something similar to @pietroppeter I think. Feels nice to learn about the nitty gritty bitops. Knew nothing about them before AoC this year |
14:31:48 | FromDiscord | <pietroppeter> yeah, I knew just bitops existed before today ๐ |
14:31:51 | kenran | Hum, one thread mentioned the freetype bindings wouldn't work. I've at least gotten it to compile and init with it. So let's see if it's possible to actually render anything. |
14:35:15 | FromDiscord | <hugogranstrom> That's really all one needs, to know of something. 'Cause then you can learn it. Yesterday I hadn't even heard of CRT before so I was lucky someone mentioned it ๐ |
14:36:03 | FromDiscord | <hugogranstrom> Next step with bitops is not using `setBit` and `clearBit` all the time I guess |
14:37:43 | FromDiscord | <shadow.> lol |
14:37:58 | FromDiscord | <shadow.> i do setBit with `num = num and not (1 shl bit)` |
14:38:03 | FromDiscord | <shadow.> nvm |
14:38:04 | FromDiscord | <shadow.> thats clear bit |
14:38:15 | FromDiscord | <shadow.> set bit is `num = num or (1 shl bit)` |
14:38:26 | FromDiscord | <hugogranstrom> wow ๐ฎ |
14:38:41 | FromDiscord | <hugogranstrom> that's a bit of magic |
14:38:45 | FromDiscord | <shadow.> eh not really |
14:38:55 | FromDiscord | <shadow.> 1 is 1 |
14:38:58 | FromDiscord | <shadow.> so when you shl |
14:39:01 | FromDiscord | <shadow.> by the amount of bits |
14:39:06 | FromDiscord | <shadow.> index of bit |
14:39:08 | FromDiscord | <hugogranstrom> that's a BIT of magic ๐ |
14:39:11 | FromDiscord | <shadow.> ahhh |
14:39:12 | FromDiscord | <shadow.> i see |
14:39:14 | FromDiscord | <shadow.> lol |
14:39:32 | FromDiscord | <hugogranstrom> hehe ๐ |
14:39:36 | FromDiscord | <mratsim> 0b00000001 shl 3 is 0b00001000. |
14:39:42 | FromDiscord | <shadow.> yeah |
14:39:45 | FromDiscord | <hugogranstrom> yeah |
14:39:50 | FromDiscord | <shadow.> so then when you do the or mask |
14:39:59 | FromDiscord | <shadow.> it essentially forces the nth bit to be 1 because 1 or anything is 1 |
14:40:07 | FromDiscord | <shadow.> does that make sense lol? |
14:40:17 | FromDiscord | <hugogranstrom> Okay thanks ๐ makes sense ๐ |
14:40:20 | FromDiscord | <shadow.> haha ye |
14:40:29 | FromDiscord | <shadow.> idk that's how i figured it in my head, idk if there's a better way tho |
14:41:12 | FromDiscord | <mratsim> Most calculators on Linux have a "programming" mode where you can play with shifts and see the bit representation |
14:41:17 | FromDiscord | <shadow.> oo |
14:41:30 | FromDiscord | <shadow.> im still tryna understand part two |
14:41:35 | FromDiscord | <hugogranstrom> Oh so that's what it's for ๐ฎ |
14:41:40 | FromDiscord | <shadow.> i can already tell it's going to need recursion / frontier usage lmao |
14:42:32 | FromDiscord | <mratsim> Bitsets are basically application or setBit clearBit and getting if a bit is 0 or 1 |
14:42:40 | FromDiscord | <shadow.> ohhh nice |
14:42:53 | FromDiscord | <hugogranstrom> Some sort of loopy thing at least. I made an iterator |
14:43:04 | FromDiscord | <hugogranstrom> Oh |
14:43:05 | FromDiscord | <shadow.> ah fair fair |
14:43:10 | FromDiscord | <shadow.> i needa understand this better lmfao |
14:44:42 | FromDiscord | <hugogranstrom> Is it the floating part that's tricky? |
14:44:55 | FromDiscord | <shadow.> ye i mean i can do that but |
14:45:01 | FromDiscord | <shadow.> im not really |
14:45:06 | FromDiscord | <shadow.> too focused rn bc im also in class |
14:45:11 | FromDiscord | <shadow.> so its hard to rly grasp the problem rn lol |
14:46:06 | FromDiscord | <hugogranstrom> hahaha xD |
14:46:18 | FromDiscord | <hugogranstrom> Perhaps good that you don't grasp it yet |
14:46:50 | FromDiscord | <hugogranstrom> Would've coded instead of doing classy things ๐ |
14:47:18 | FromDiscord | <shadow.> welll |
14:47:25 | FromDiscord | <shadow.> we're doing essay planning for an essay i've already started |
14:47:29 | FromDiscord | <shadow.> so it's not important |
14:47:33 | FromDiscord | <shadow.> but i can't exactly mute it yk |
14:49:07 | Araq | bah I'm an idiot |
14:49:22 | Araq | nested two for loops with 'i' counters |
14:49:37 | Araq | :-/ |
14:49:50 | FromDiscord | <mratsim> that's why you should use map/fold/filter. |
14:50:05 | FromDiscord | <mratsim> embrace Haskell |
14:50:11 | FromDiscord | <mratsim> no more loop problems |
14:50:29 | Araq | I could also make my compiler complain about nesting |
14:50:55 | FromDiscord | <hugogranstrom> @shadow. oh I see, better make use of the time then lol |
14:51:11 | FromDiscord | <mratsim> wasn't there a related discussion on shadowing and it was chosen to only warn for "result" ? |
14:51:17 | Araq | problem is that I also often re-use identifiers in order to avoid bugs (cannot accidentically use the other version) |
14:51:32 | FromDiscord | <shadow.> ye, just tryna comprehend the problem rn i suppose |
14:51:42 | FromDiscord | <sealmove> if I have a uint32 and i only care for the 24 least significant bits, can I cast it to a seq[byte] of size 3 without losing info? |
14:52:05 | FromDiscord | <mratsim> casting to a GC-ed type is a recipe for disaster |
14:52:07 | FromDiscord | <shadow.> casting to byte seqs are weird |
14:52:10 | FromDiscord | <shadow.> try an array instead |
14:52:15 | FromDiscord | <mratsim> cast to array[4, byte] yes |
14:52:25 | FromDiscord | <shadow.> or `array[3, byte]` should also work |
14:52:30 | FromDiscord | <shadow.> iirc |
14:52:30 | FromDiscord | <sealmove> unfortunately i don't know the length i care about at CT |
14:52:34 | FromDiscord | <shadow.> ahh i see |
14:52:37 | FromDiscord | <mratsim> only on little-Ednian platforms |
14:52:43 | FromDiscord | <shadow.> but you said you only care about the 24 bits, no? |
14:53:07 | FromDiscord | <mratsim> cast[ptr UncheckedArray[byte]](myInt.addr) |
14:53:12 | FromDiscord | <sealmove> yes, i want to cast to array/seq so i can use reverse() on it, but it must have the correct size, so i don't reverse 0 bytes |
14:53:20 | Araq | dom96, shashlick, I love 'nimble develop'. :-) |
14:53:59 | PMunch | sealmove, I doubt that'll work very well.. |
14:54:02 | FromDiscord | <mratsim> use generics and cast[array[sizeof(MyInt), byte]](myInt) |
14:54:18 | Araq | I know it's a rather old by now, but it's excellent, thanks again for this feature |
14:54:26 | FromDiscord | <mratsim> or use swapBytes from the endians module. |
14:54:26 | PMunch | I think swapEndian and shifting is probably your best option |
14:54:36 | FromDiscord | <hugogranstrom> Good idea, it's always a bad idea to run straight into AoC problems without understanding what you're doing. Better to write correct code from the beginning then trying to find the bugs in a faulty code |
14:54:43 | FromDiscord | <sealmove> swapEndian only works for 16, 32, and 64 bit ints |
14:55:01 | FromDiscord | <sealmove> ah shift, hmm |
14:55:05 | PMunch | Yeah, that's why you should shift it afterwords ;) |
14:55:13 | PMunch | Or before |
14:55:36 | PMunch | By the way, new AoC stream in a little while :) |
14:55:51 | FromDiscord | <mratsim> Find implementation to I2OS and OS2I in any good cryptographic library, they basically do that :p |
14:56:01 | PMunch | People seem to have struggled a bit on this one, so I'm curious >_< |
14:56:19 | FromDiscord | <shadow.> i mean |
14:56:21 | FromDiscord | <shadow.> part two a lil bit |
14:56:23 | FromDiscord | <shadow.> part one was quite eas |
14:56:24 | FromDiscord | <shadow.> (edit) "eas" => "easy" |
14:56:43 | FromDiscord | <mratsim> here is mine @sealmove: https://github.com/mratsim/constantine/blob/master/constantine/io/io_bigints.nim#L64-L118 |
14:59:20 | FromDiscord | <hugogranstrom> Yeah part1 is usually easy but if you're lucky you can reuse parts of it in part2 as well |
14:59:33 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2I1U |
15:00:44 | FromDiscord | <sealmove> it works ๐ |
15:03:43 | FromDiscord | <shadow.> @pietroppeter you ever tried npeg? |
15:03:48 | FromDiscord | <shadow.> your solution could prolly be much more concise with it haha |
15:04:11 | PMunch | Stream is live: https://www.twitch.tv/pmunche https://www.youtube.com/watch?v=4WpHK4U_Jvc |
15:06:43 | FromDiscord | <hugogranstrom> Npeg is the deal! โญ |
15:07:08 | FromDiscord | <shadow.> yessir |
15:08:07 | FromDiscord | <sealmove> PMunch, endianness is fixed already ๐ mixing byte and bit endianness is possible for ints that are multiples of a byte! |
15:08:10 | FromDiscord | <pietroppeter> shadow: I like npeg a lot but still do not know it enough for using in AoC. Also I like to have more control for debugging and I am not aiming at conciseness. I split stuff also to test them separately. |
15:08:16 | FromDiscord | <shadow.> fair |
15:08:29 | FromDiscord | <shadow.> my npeg was something like |
15:08:30 | FromDiscord | <shadow.> `maskSet <- "mask = " >36:` |
15:08:34 | FromDiscord | <shadow.> `memSet <- "mem[" >+Digit "] = " >+Digit:` |
15:08:38 | FromDiscord | <shadow.> obvi more than that but that's the core |
15:08:45 | Zevv | send me money |
15:08:45 | Zevv | lots |
15:08:46 | FromDiscord | <pietroppeter> yeah, btw I was surprised you could do >36 |
15:08:54 | FromDiscord | <shadow.> gotchu |
15:08:56 | FromDiscord | <pietroppeter> I did not find it in docs... |
15:09:00 | FromDiscord | <shadow.> really? |
15:09:03 | FromDiscord | <shadow.> n |
15:09:05 | FromDiscord | <shadow.> matches n characters |
15:09:10 | FromDiscord | <shadow.> i think thats in docs haha |
15:09:14 | FromDiscord | <sealmove> oh great, aoc is more bits and bytes lol |
15:09:19 | FromDiscord | <pietroppeter> ah yeah, did not look for it that well then ๐ |
15:09:23 | FromDiscord | <shadow.> haha |
15:09:33 | * | waleee-cl joined #nim |
15:10:31 | FromDiscord | <pietroppeter> see, I know too little npeg yet to use it now and I have already my plate full with aoc and nimib to start learning it now. But I enjoy looking at solutions using it (like yours :)); it's a way to start learning... |
15:11:43 | FromDiscord | <pietroppeter> for example when I tried npeg on day6 I was stuck here and quickly changed gears: https://github.com/pietroppeter/adventofnim/blob/master/2020/day06npeg.nim |
15:13:32 | FromDiscord | <pietroppeter> but I keep it as an issue open on my repo ๐ https://github.com/pietroppeter/adventofnim/issues/1 |
15:13:33 | disbot | โฅ Regexes? no, learn Npeg! |
15:17:55 | FromDiscord | <shadow.> true |
15:18:13 | FromDiscord | <shadow.> tbh npeg shouldn't be too hard if you put your mind to it |
15:18:21 | FromDiscord | <shadow.> i learned it on aoc day 7 lol |
15:18:23 | FromDiscord | <shadow.> been using it ever since |
15:23:48 | FromDiscord | <pietroppeter> well, can you tell me what's wrong here? https://play.nim-lang.org/#ix=2GP3 |
15:32:35 | FromDiscord | <shadow.> lemme take a look |
15:33:50 | FromDiscord | <pietroppeter> thanks! |
15:34:55 | FromDiscord | <shadow.> hmm |
15:35:14 | FromDiscord | <shadow.> i have not used the builtin peg macro, is it any different? |
15:37:19 | FromDiscord | <Quibono> So npeg is regex without the evil? |
15:37:32 | FromDiscord | <shadow.> well |
15:37:35 | FromDiscord | <shadow.> regex but |
15:37:37 | FromDiscord | <shadow.> - more readable |
15:37:41 | FromDiscord | <shadow.> - nim code can be embedded |
15:37:44 | FromDiscord | <shadow.> - uses macro instead of string |
15:37:44 | FromDiscord | <Quibono> Lol so without the evil. |
15:37:58 | FromDiscord | <Quibono> _wants npeg tutorial_ |
15:38:00 | FromDiscord | <shadow.> - capture groups are referenceable |
15:38:01 | FromDiscord | <shadow.> lmao |
15:38:51 | FromDiscord | <shadow.> which problem was this? |
15:38:54 | FromDiscord | <shadow.> i can find my npeg for this one |
15:39:08 | FromDiscord | <pietroppeter> shadow: not sure what you mean, I see peg used in one of the solution you shared earlier. Take into account that was my first try with npeg after reading about it the day before. |
15:39:17 | FromDiscord | <pietroppeter> day6 |
15:39:51 | FromDiscord | <shadow.> hmm ok |
15:39:58 | FromDiscord | <shadow.> do you want to try making one for day 7? |
15:40:03 | FromDiscord | <shadow.> might be easier to help on that since ive already made one for it |
15:40:04 | FromDiscord | <shadow.> lol |
15:40:20 | FromDiscord | <pietroppeter> not at the moment ๐ |
15:40:22 | FromDiscord | <shadow.> rip |
15:41:12 | FromDiscord | <shadow.> https://play.nim-lang.org/#ix=2I2h |
15:41:15 | FromDiscord | <shadow.> is this what you wanted? |
15:42:19 | FromDiscord | <pietroppeter> yes! |
15:42:32 | FromDiscord | <hugogranstrom> `` is tricky |
15:42:34 | FromDiscord | <shadow.> haha yeah |
15:42:42 | FromDiscord | <shadow.> use + when you can, it's more readable imo |
15:42:53 | FromDiscord | <shadow.> i think it's because you did any amount of answers |
15:42:57 | FromDiscord | <shadow.> when answers should be 1 |
15:43:07 | FromDiscord | <hugogranstrom> sent a code paste, see https://play.nim-lang.org/#ix=2I2j |
15:43:19 | FromDiscord | <pietroppeter> damn I thought was 1 one or more and + was zero or more while it is the other way around... |
15:43:23 | FromDiscord | <shadow.> haha yeah |
15:44:01 | * | Cthalupa quit (Ping timeout: 264 seconds) |
15:44:02 | FromDiscord | <shadow.> you've done today's already right? |
15:44:05 | FromDiscord | <pietroppeter> (I did associate and + with their identity operator-wise) |
15:44:12 | FromDiscord | <pietroppeter> yes I did |
15:44:19 | FromDiscord | <shadow.> sent a code paste, see https://play.nim-lang.org/#ix=2I2k |
15:44:19 | FromDiscord | <shadow.> npeg really helped here |
15:44:21 | FromDiscord | <pietroppeter> anyway thanks for the catch |
15:44:38 | FromDiscord | <shadow.> idk how i woulda done it without it lol |
15:44:48 | FromDiscord | <shadow.> maybe a mix of strscans, regex, split, and strutils |
15:44:57 | FromDiscord | <shadow.> or even indexing lmfao |
15:44:58 | * | Cthalupa joined #nim |
15:44:59 | FromDiscord | <pietroppeter> yeah, altough I would probbly never do the job in the parsing blocks. I would always output some parse structure |
15:45:03 | FromDiscord | <shadow.> fair |
15:45:19 | FromDiscord | <pietroppeter> oh, well yeah it was a very simple parsing with startswith and scanf for the mem part |
15:45:29 | FromDiscord | <shadow.> fair fair |
15:45:43 | FromDiscord | <shadow.> idk i kinda like having structure in my parsing |
15:45:51 | FromDiscord | <shadow.> and i feel like when i throw various methods together it doesn't feel as organized |
15:45:54 | FromDiscord | <shadow.> so i stick with npeg |
15:47:46 | FromDiscord | <pietroppeter> I know my solutions are not sexy at all (and they are very verbose), but I can tell when they do not work. ๐ I actually put echos for unexpected stuff that would not match so I get a warning (not bothering with raising error since this is throwaway code anyway) https://github.com/pietroppeter/adventofnim/blob/master/2020/day14.nim#L46 |
15:47:54 | FromDiscord | <shadow.> fair |
15:48:03 | FromDiscord | <shadow.> my answers are typically quite sexy but not the easiest to debug |
15:48:05 | FromDiscord | <pietroppeter> anyway that helped reinstate a bit more confidence on my understanding of npeg ๐ |
15:48:11 | FromDiscord | <shadow.> ofc |
15:48:34 | FromDiscord | <shadow.> gotta say i kinda love my solution for yesterday lol |
15:48:35 | FromDiscord | <shadow.> https://github.com/shadowninja55/aoc-2020/blob/main/13/day13.nim |
15:49:35 | FromDiscord | <hugogranstrom> it's so small ๐ฎ |
15:50:02 | FromDiscord | <shadow.> haha yeah that's generally how i do stuff |
15:50:20 | FromDiscord | <shadow.> i finally got to use defer lol |
15:50:22 | FromDiscord | <pietroppeter> yep, looks very nice, congrats! |
15:50:32 | FromDiscord | <shadow.> thanks! |
15:50:32 | FromDiscord | <shadow.> https://github.com/shadowninja55/aoc-2020/blob/main/03/day3.nim |
15:50:36 | FromDiscord | <shadow.> this one was just ridiculous- |
15:52:06 | FromDiscord | <hugogranstrom> haha |
15:52:15 | Araq | I still wish we copied Python's with statement instead of Go's defer |
15:52:43 | FromDiscord | <hugogranstrom> Not having the tests does make all mine seem much smaller as well ๐ค |
15:53:07 | FromDiscord | <shadow.> lmfao yeah i have like |
15:53:09 | FromDiscord | <shadow.> zero asserts |
15:53:12 | FromDiscord | <shadow.> do the minimum possible |
15:53:18 | FromDiscord | <shadow.> it's the most awful code ever |
15:53:21 | FromDiscord | <shadow.> but it sure looks pretty |
15:53:41 | FromDiscord | <hugogranstrom> haha yeah sure do |
15:53:54 | FromDiscord | <hugogranstrom> And Nim code always looks pretty ๐ |
15:53:56 | FromDiscord | <shadow.> day 12 was sexy too |
15:54:03 | FromDiscord | <shadow.> swapping y and x then y -1 |
15:54:08 | FromDiscord | <shadow.> was a nice discovery |
15:54:27 | Zevv | npeg is just a tool. it's not magic and you can do without |
15:54:42 | Zevv | it makes some things easier, and some things not |
15:54:48 | Zevv | so, hey, pick your poison |
15:55:55 | FromDiscord | <hugogranstrom> that's clever, I made it much more verbose... Using complex numbers would probably have been even sexier |
15:56:04 | FromDiscord | <shadow.> haha |
16:03:24 | * | hnOsmium0001 joined #nim |
16:04:59 | Araq | if I import 'x as y' should 'x' still be in the scope? |
16:05:57 | PMunch | @shadow., pfft, part2 wasn't that hard |
16:06:40 | FromDiscord | <Quibono> Like should you be allowed to do import random as r and then reference random? |
16:06:49 | Araq | yeah |
16:06:55 | FromDiscord | <Quibono> Iโd say no |
16:07:07 | * | krux02 quit (Remote host closed the connection) |
16:07:08 | Araq | https://play.nim-lang.org/#ix=2I2x yeah |
16:07:28 | Araq | ok, so that's the cause of my regression |
16:07:40 | FromDiscord | <myphs> Are there any resources on how to get into win32 programming with Nim or maybe a lib? |
16:08:08 | FromDiscord | <Quibono> Like why specify โasโ it youโre just going to try and use it the original way. |
16:08:36 | Araq | there are nimble packages, myphs, but iirc they are bad |
16:08:58 | Araq | "bad" because not idiomatic Nim code, emulating VB or something |
16:08:58 | FromDiscord | <shadow.> @PMunch well i still havent done it ๐ ] |
16:09:23 | FromDiscord | <shadow.> myphs winim isnt that bad |
16:09:33 | Araq | you should start with reading the stdlib's winlean.nim module. while not perfect, it's a start |
16:09:33 | FromDiscord | <shadow.> but yeah its not nimion |
16:10:49 | * | matthias_ joined #nim |
16:11:53 | PMunch | @shadow. well it's a bit tricky if you aren't used to a lot of bit-stuff |
16:12:27 | FromDiscord | <shadow.> im use to that, just the recursion part is hard to understand for me lol |
16:12:28 | FromDiscord | <shadow.> ill get it soon |
16:12:32 | FromDiscord | <shadow.> once im not thinking of class too |
16:12:38 | FromDiscord | <Quibono> Beyond the basic style guide, is there a move towards a more expansive style guide? |
16:13:28 | PMunch | Recursion? |
16:13:36 | FromDiscord | <myphs> We'll look into that. Thanks guys! |
16:14:33 | FromDiscord | <shadow.> some people said recursion was needed idek |
16:14:35 | FromDiscord | <shadow.> lmao |
16:14:39 | FromDiscord | <shadow.> or maybe it was nested loops |
16:14:40 | FromDiscord | <shadow.> im not sure |
16:15:15 | matthias_ | Is it idiomatic to call one macro from another, and is there a way to pass along values (in this case, a symbol)? E.g. `let foo = macroOne(SomeObj)` and then `macroOne` calls `macroTwo(SomeObj)` which receives the original `SomeObj` nnkSym. |
16:19:04 | FromDiscord | <Klaufir> sent a code paste, see https://play.nim-lang.org/#ix=2I2F |
16:19:15 | FromDiscord | <Klaufir> (edit) "https://play.nim-lang.org/#ix=2I2H" => "https://play.nim-lang.org/#ix=2I2G" |
16:19:23 | FromDiscord | <Klaufir> (edit) "https://play.nim-lang.org/#ix=2I2G" => "https://play.nim-lang.org/#ix=2I2I" |
16:20:41 | FromDiscord | <Rika> @Quibono what would you like to see in the style guide |
16:21:47 | FromDiscord | <Quibono> Mhmm, just more clarity on exactly what is Nim-ish |
16:22:00 | FromDiscord | <Rika> Like for what constructs I mean |
16:22:51 | FromDiscord | <lqdev> sent a code paste, see https://play.nim-lang.org/#ix=2I2M |
16:23:18 | FromDiscord | <Quibono> Like is UFCS the default or just a nice thing sometimes? |
16:23:26 | FromDiscord | <shadow.> default when applicable |
16:23:37 | FromDiscord | <shadow.> for instance `a.high` over `high(a)` |
16:23:43 | FromDiscord | <Rika> What do you mean, UFCS is a feature |
16:23:46 | FromDiscord | <Quibono> Disruptekโs style guide is kinda what I mean, like itโs super opinionated |
16:23:47 | FromDiscord | <Rika> Not a syntax style |
16:24:00 | FromDiscord | <Rika> It is composed of multiple syntax styles |
16:24:04 | FromDiscord | <Quibono> But which features we use and when |
16:24:04 | FromDiscord | <shadow.> i think he means is it more idiomatic to `a.f` instead of `f(a)` |
16:24:08 | FromDiscord | <shadow.> and other stuff like that |
16:24:09 | FromDiscord | <Quibono> Yeah |
16:24:11 | FromDiscord | <Rika> It depends |
16:24:13 | FromDiscord | <Quibono> That. |
16:24:14 | FromDiscord | <shadow.> yeah |
16:24:26 | FromDiscord | <shadow.> depends on how complex the function is, if it has side effects, stuff like that |
16:24:31 | FromDiscord | <Rika> Nim is not a language that imposes a lot of stylistic opinions |
16:24:39 | FromDiscord | <shadow.> yeah it's really flexible |
16:24:46 | FromDiscord | <shadow.> so it's kinda whatever you think looks good lol |
16:24:49 | FromDiscord | <Rika> And I believe it's intentional |
16:24:56 | mipri | although it does completely eliminate the eternal problem of C programmers putting { on its own line |
16:25:03 | FromDiscord | <Klaufir> thank you! |
16:25:04 | FromDiscord | <shadow.> lmfao yeah |
16:25:10 | FromDiscord | <Quibono> Lol i guess I just want a benchmark for โgoodโ Nim. |
16:25:44 | FromDiscord | <Rika> Why would it have UFCS and partial style insensitivity if it were to just restrict that with a style guide anyway |
16:27:00 | FromDiscord | <Rika> Good nim is nim that can be read easily. |
16:27:07 | FromDiscord | <Rika> And that is dependent on the person |
16:27:10 | Araq | Rika: because the community demands it |
16:27:20 | FromDiscord | <Rika> Beauty in the eye of the beholder ig |
16:27:40 | FromDiscord | <haxscramper> ~disrupstyle |
16:27:41 | disbot | disrupstyle: 11tips for writing code that won't provoke ๐ rants ๐คฌ on irc: https://gist.github.com/disruptek/6d0cd6774d05adaa894db4deb646fc1d |
16:28:15 | FromDiscord | <Rika> Araq well I guess that makes sense now that I've thought about it for a while |
16:28:33 | FromDiscord | <haxscramper> But more extensive style guide will basically mean there will be non-stop opinion sharing |
16:28:39 | FromDiscord | <Quibono> Lol Like I donโt love how Black styles Python code but I use it because standardization. |
16:28:56 | FromDiscord | <Rika> Eh |
16:28:58 | Araq | method call syntax and SI were introduced before Golang came along to show us the light, fascism is superior, nothing else "scales" as well |
16:29:14 | FromDiscord | <haxscramper> Instead of actually writing code, so you should just stick to whatewher you like, as long as it stays withing this value 'use common sense' boundaries |
16:29:14 | FromDiscord | <Quibono> Araq +1 for you dictatorially writing a style guide and enforcing your will. |
16:29:29 | FromDiscord | <Quibono> ++1 for fascism in syntax. |
16:29:43 | FromDiscord | <Rika> I am having difficulty distinguishing sarcasm |
16:29:47 | FromDiscord | <Rika> Right now |
16:29:59 | FromDiscord | <haxscramper> No sacrasm |
16:30:13 | Araq | I'm glad programmers have little political power |
16:30:34 | Araq | their way of thinking is utterly broken. |
16:30:48 | FromDiscord | <haxscramper> works for me (TM) |
16:31:09 | FromDiscord | <Quibono> @Rika Iโm being serious, I prefer like a The Elements of Style approach to programming. |
16:31:38 | Araq | oh no, somebody used an old word that I don't understand, I'm confused, we must purge the world of code from this word |
16:31:56 | FromDiscord | <haxscramper> But on the topic of style guide - I mysefl still have troubles remembering what style I like, so I just write code that looks like adjacent code on the screen |
16:32:05 | FromDiscord | <Quibono> Lol, fair |
16:32:50 | Araq | oh no, somebody painted his roof blue, all roofs must be red, inconsistent! I cannot live in this city |
16:33:31 | FromDiscord | <Quibono> Lol so Araq is this your way of saying Nim is antifa in itโs syntax? :p |
16:33:38 | FromDiscord | <shadow.> its |
16:33:39 | FromDiscord | <shadow.> ๐,, |
16:33:45 | FromDiscord | <shadow.> inconsistent. |
16:33:49 | FromDiscord | <shadow.> shall i make an english grammar style guide? |
16:33:50 | FromDiscord | <Quibono> Fascist! |
16:33:54 | FromDiscord | <Quibono> Lol |
16:36:47 | * | NimBot joined #nim |
16:37:15 | FromDiscord | <Quibono> But yeah my bad on the its. |
16:39:00 | FromDiscord | <shadow.> how big is default int? |
16:39:17 | FromDiscord | <shadow.> i was being facetious |
16:39:42 | FromDiscord | <shadow.> my point is that with something like grammar where that was actually incorrect people can still understand you |
16:39:48 | FromDiscord | <shadow.> so with something like style that makes no actual difference |
16:39:53 | FromDiscord | <shadow.> who cares what you stylize it as |
16:39:56 | FromDiscord | <shadow.> as long as you can read it it works |
16:42:12 | FromDiscord | <Quibono> But grammar is just an artificial style |
16:42:12 | FromDiscord | <Quibono> Like ainโt is only wrong because we think AAVE is non-standard. |
16:42:12 | FromDiscord | <lqdev> hm ARC doesn't seem to like my value representation |
16:42:57 | FromDiscord | <shadow.> try writing it an essay on why it should like it |
16:43:51 | FromDiscord | <lqdev> 1. it works on --gc:refc |
16:43:56 | FromDiscord | <lqdev> end of essay |
16:44:43 | FromDiscord | <lqdev> something seems to cause corruption |
16:44:50 | Araq | lqdev: report it on github. |
16:44:57 | FromDiscord | <lqdev> easier said than done |
16:45:04 | FromDiscord | <lqdev> i'll try making it reproducible first |
16:45:05 | Araq | and avoid the system.add that takes an openArray |
16:45:11 | FromDiscord | <lqdev> oh? |
16:45:18 | Araq | it's broken and I'm sorry it made it into 1.4.2 this way |
16:45:19 | FromDiscord | <lqdev> is it broken? |
16:45:39 | Araq | yes |
16:45:51 | * | rockcavera quit (Remote host closed the connection) |
16:45:54 | FromDiscord | <lqdev> ok i'll try rewriting some of my code that uses it |
16:46:07 | Araq | create a PR instead please |
16:46:15 | Araq | revert it to the old non-sink version |
16:47:28 | Araq | we're still discussing internally what 'sink openArray' actually means :-/ |
16:48:07 | FromDiscord | <Avatarfighter> Hello everyone how are you all? |
16:49:02 | Araq | fine |
16:49:36 | FromDiscord | <Rika> coarse |
16:50:31 | FromDiscord | <Avatarfighter> damn thats rough |
16:51:12 | FromDiscord | <Rika> of coarse |
16:52:21 | FromDiscord | <ache of head> XDDD |
16:52:47 | FromDiscord | <shadow.> does anyone know pmunch's github? |
16:53:05 | FromDiscord | <shadow.> nvm got it |
16:53:44 | FromDiscord | <Rika> congratulations |
16:53:46 | FromDiscord | <lqdev> damn my VM really screws up with ARC/ORC :/ |
16:54:02 | FromDiscord | <lqdev> i'll debug it some but first i'll do that un-sinking PR |
16:54:55 | FromDiscord | <lqdev> Araq: the docs don't seem to mention that the `openArray` version accepts a `sink openArray` |
16:55:28 | FromDiscord | <lqdev> ah |
16:55:33 | FromDiscord | <lqdev> it's only for destructors-based GCs |
16:56:13 | FromDiscord | <shadow.> wait a minute... |
16:56:19 | FromDiscord | <shadow.> to generate every binary combination for n bits |
16:56:23 | FromDiscord | <shadow.> isnt it just like |
16:56:31 | FromDiscord | <shadow.> every number from 0b0 to 0b1(n) |
16:56:38 | * | thomasross joined #nim |
16:56:53 | FromDiscord | <shadow.> like for 3 bits every number between 0 and 0b111? |
16:59:48 | FromDiscord | <lqdev> Araq: should i just remove the `when defined` branch for gcDestructors completely, or do sth like `when false`, orโฆ? |
17:00:48 | Araq | 'when false', eventually a variant of it will be implemented |
17:01:30 | FromDiscord | <lqdev> ok |
17:01:59 | Araq | there is also some arc test that then will start to fail |
17:02:09 | Araq | you need to disable that one too and reopen the original issue |
17:04:18 | FromDiscord | <lqdev> are you referring to #15511 ? |
17:04:19 | disbot | https://github.com/nim-lang/Nim/issues/15511 -- 3[ARC] Crash when adding openArray proc argument to a local seq ; snippet at 12https://play.nim-lang.org/#ix=2zYW |
17:04:24 | FromDiscord | <lqdev> that's the only one i could find |
17:04:43 | mipri | shadow., yeah, it's 2^n where n=number of X bits, in part 2 |
17:07:30 | Araq | lqdev: iirc there was another one but ok |
17:10:10 | * | Vladar quit (Quit: Leaving) |
17:10:21 | FromDiscord | <lqdev> anyways, now to get rid of choosenim because i can't run tests. |
17:12:04 | FromDiscord | <ache of head> yeah, i think that's how it works |
17:13:11 | Araq | narimiran, https://gist.github.com/haxscramper/ad781ebd5a343b53197bf538a1252f83 another one coming from a native language lacking articles |
17:13:11 | FromDiscord | <lqdev> ah shit |
17:13:20 | FromDiscord | <haxscramper> How exactly `const QIcon &icon` should be mapped to nim types? |
17:13:24 | FromDiscord | <lqdev> how can i temporarily change my Nim to the one from git |
17:13:29 | FromDiscord | <haxscramper> For wrappers |
17:13:39 | FromDiscord | <haxscramper> Just ` icon: QIcon` is enough, or there is more to it |
17:13:54 | Araq | haxcramper: make the QIcon *type* .byref |
17:14:45 | FromDiscord | <haxscramper> `QIcon` is a wrapper for `C++` object, and it might be used without `&` as well |
17:15:57 | FromDiscord | <haxscramper> Or this won't make a difference, and `impl(const QIcon &icon)` and `impl(QIcon icon)` would be handled correctly? |
17:15:58 | Araq | yeah .byref and .bycopy is insufficient, we need even better wrapping support |
17:16:20 | FromDiscord | <shadow.> lit |
17:16:31 | Araq | for now it's not too bad as .importcpp means Nim uses the C++ header |
17:16:48 | Araq | and C++ linking is type safe |
17:17:01 | Araq | getting it a little bit wrong doesn't matter. for now :-) |
17:17:29 | * | Vladar joined #nim |
17:17:38 | FromDiscord | <haxscramper> Alright, then I will just leave `icon: QIcon` for now |
17:18:33 | FromDiscord | <haxscramper> I decided to just leave fully-automatic full-project wrapping implementation `hcparse` and just wrap things one-by-one |
17:18:55 | FromDiscord | <haxscramper> And now finally starting qt wrapper |
17:19:53 | Araq | so ... afterwards we will have a high quality, type-safe Nim wrapper? madness |
17:20:49 | FromDiscord | <haxscramper> I'm hoping to do this. I've added support for custom post-processing pass on wrappers, where you can plug in custom logic that operates on generated nim code |
17:21:02 | FromDiscord | <haxscramper> in addion to working on PNode instead of string codegen |
17:21:20 | * | matthias_ quit (Quit: matthias_) |
17:21:22 | Araq | that's what c2nim does too, some postprocessing |
17:21:29 | Araq | on the PNode structure |
17:21:58 | Araq | please at least copy its code if you cannot use/patch c2nim |
17:22:14 | FromDiscord | <haxscramper> I made second layer of abstraction on top of this, so you can do things like `procDecl.exported = true` |
17:22:34 | FromDiscord | <haxscramper> Instead of messing with `nnkPrefix(ident(""))` all over the place |
17:23:42 | Araq | *cough* |
17:23:54 | Araq | I was young |
17:24:17 | FromDiscord | <haxscramper> And postprocessing callbacks work on these objects, which have about ten trillion knobs and switches for different things |
17:24:28 | Araq | couldn't be bothered to create an API that makes sense :P |
17:24:55 | * | muffindrake joined #nim |
17:25:02 | FromDiscord | <haxscramper> Well, actually, after writing this "nim ast wrapper" I'm not so sure it really that much better in general case |
17:25:08 | ForumUpdaterBot | New thread by HJarausch: One more "collect" question (bug?), see https://forum.nim-lang.org/t/7253 |
17:25:30 | Araq | back then the question was "can this work at all". I was happy when I proved this to be true. |
17:26:25 | Araq | (this was before Elixir, Haxe and Rust existed...) |
17:27:22 | FromDiscord | <haxscramper> It is really convenient to use for codegen, but it is that much more complex API, I mean nim object declaration turned into three separate types, mutually recursive, with cases all over the place |
17:28:25 | Araq | yeah, your stuff is likely worse :P |
17:33:39 | * | azed joined #nim |
17:40:15 | FromDiscord | <sealmove> @PMunch I updated README demonstrating proposed design for the features we discussed. Let me know if it looks good to you. |
17:50:58 | * | habamax quit (Ping timeout: 265 seconds) |
17:51:48 | * | Vladar quit (Quit: Leaving) |
17:51:55 | FromDiscord | <XxDiCaprioxX> how do I append something at the end of a sequence? |
17:52:48 | PMunch | @sealmove, I'm off to go climbing right now. Will look at it later today or tomorrow |
17:53:04 | PMunch | @shadow., haha well you can guess once what my GitHub is :P |
17:55:01 | FromDiscord | <InventorMatt> @XxDiCaprioxX the .add proc |
17:55:28 | * | PMunch quit (Quit: leaving) |
17:56:49 | FromDiscord | <XxDiCaprioxX> Are variables of types always immutable? |
17:57:53 | FromDiscord | <XxDiCaprioxX> sent a code paste, see https://play.nim-lang.org/#ix=2I3n |
17:58:15 | FromDiscord | <XxDiCaprioxX> I cant manipulate that variable after initializing a variable to that type |
17:58:33 | FromDiscord | <lqdev> you need to do `var x = Foo()` |
17:58:37 | FromDiscord | <lqdev> `let` makes it immutable |
17:59:01 | FromDiscord | <lqdev> also, FYI to avoid confusion simply refer to these "object variables" as "fields" |
17:59:48 | FromDiscord | <XxDiCaprioxX> okay, i didnt know that was the term for it |
18:00:21 | * | fredrikhr quit (Read error: Connection reset by peer) |
18:00:36 | FromDiscord | <XxDiCaprioxX> but that doesnt work, I have `var x = Foo()` and then I try `x.bar += "something"` and it wont let me change that |
18:01:28 | FromDiscord | <lqdev> ah |
18:01:37 | FromDiscord | <lqdev> in nim you use `x.add("something")` to append to strings |
18:01:41 | FromDiscord | <lqdev> or `x &= "something"` |
18:01:47 | FromDiscord | <lqdev> if you prefer operators |
18:02:24 | FromDiscord | <XxDiCaprioxX> no, I just wrote that out of routine cuz I did Java for some time and got used to that |
18:02:28 | disruptek | use add; it's more performant. |
18:02:44 | FromDiscord | <XxDiCaprioxX> I actually have `x.bar.add("something)` but still it won't work |
18:03:04 | FromDiscord | <lqdev> what's the error? |
18:03:07 | * | rockcavera joined #nim |
18:03:54 | FromDiscord | <XxDiCaprioxX> type mismatch, required seq[T] but seq[T] is immutable |
18:03:59 | FromDiscord | <shadow.> wait wt |
18:04:01 | FromDiscord | <shadow.> wtf |
18:04:03 | FromDiscord | <shadow.> part two was so easy |
18:04:14 | FromDiscord | <shadow.> i thought it wanted to branch out from each index that branched out from the first one LMAO |
18:04:19 | FromDiscord | <shadow.> i didnt realize it was one-depth |
18:04:21 | disruptek | your x is immutable. |
18:04:42 | FromDiscord | <InventorMatt> @XxDiCaprioxX does yours look something like this https://play.nim-lang.org/#ix=2I3p ? |
18:04:56 | FromDiscord | <XxDiCaprioxX> yes |
18:05:46 | FromDiscord | <InventorMatt> that runs so I don't know what would cause the error on your end then |
18:05:56 | * | abm joined #nim |
18:06:01 | FromDiscord | <XxDiCaprioxX> I have seq[T] not string ,would that change anything? |
18:07:02 | FromDiscord | <Avatarfighter> Has anyone recently tried building nimterop and has had issues with it failing to install? |
18:07:36 | FromDiscord | <InventorMatt> @XxDiCaprioxX it shouldn't make a difference https://play.nim-lang.org/#ix=2I3s |
18:08:41 | FromDiscord | <XxDiCaprioxX> maybe because my seq is of a type that inherits from object? |
18:09:16 | dom96 | <Araq> dom96, shashlick, I love 'nimble develop'. :-) |
18:09:18 | FromDiscord | <lqdev> are you sure that `x` is a var and not a let? |
18:09:18 | dom96 | yay |
18:09:48 | dom96 | Although I do wonder why you need it now that local deps is a thing |
18:09:51 | FromDiscord | <XxDiCaprioxX> FOUND MY MISTAKE |
18:09:56 | FromDiscord | <lqdev> what was it |
18:10:08 | FromDiscord | <XxDiCaprioxX> I have x initialized in a proc that comes after where I try to change it |
18:10:24 | FromDiscord | <XxDiCaprioxX> nvm |
18:10:27 | FromDiscord | <XxDiCaprioxX> still not working |
18:13:03 | Araq | dom96, in my branch plenty of "important packages" are failing and I do 'nimble develop packageX' |
18:13:16 | Araq | to reproduce locally, works fine |
18:13:21 | FromDiscord | <shadow.> is there any package (stl or nimble) that handles bitsets? |
18:13:25 | FromDiscord | <shadow.> like setBit clearBit |
18:13:31 | FromDiscord | <shadow.> using bitops rn is kinda hard to read |
18:13:32 | FromDiscord | <lqdev> yeah |
18:13:34 | FromDiscord | <lqdev> `set[T]` |
18:13:53 | Araq | for sets these are incl/excl, the 'in' operator etc |
18:14:05 | FromDiscord | <lqdev> https://nim-lang.org/docs/manual.html#types-set-type |
18:14:05 | FromDiscord | <shadow.> but does it have the necesarry operations? like how can i convert `5` to a bitset |
18:14:10 | FromDiscord | <lqdev> cast |
18:14:21 | FromDiscord | <shadow.> hm |
18:14:24 | FromDiscord | <shadow.> and setBit? |
18:14:32 | FromDiscord | <nikki> incl |
18:14:37 | FromDiscord | <shadow.> OHH |
18:14:48 | Araq | dom96, in this case local deps have not yet been required |
18:14:51 | dom96 | Araq, ahh so it's for quick testing, nice |
18:15:01 | FromDiscord | <shadow.> so a bitset would just be set[anything]? |
18:15:12 | FromDiscord | <shadow.> nvm |
18:15:13 | FromDiscord | <shadow.> set[int] |
18:15:25 | FromDiscord | <nikki> yeah some large enough ordinal |
18:15:26 | Araq | use HashSet[int] instead |
18:15:33 | FromDiscord | <shadow.> why's that? |
18:15:43 | * | krux02 joined #nim |
18:15:53 | FromDiscord | <shadow.> i thought generally set[int] > IntSet > HashSet[int] |
18:16:12 | Araq | well 'set[int]' doesn't even compile |
18:16:30 | FromDiscord | <shadow.> should i use intset then? |
18:18:25 | FromDiscord | <nikki> if you want 5 bits you can do set[0..4] |
18:18:28 | FromDiscord | <lqdev> `set[int16]` is the maximum you can use |
18:18:42 | FromDiscord | <shadow.> ah i need 36 bits for this problem |
18:18:48 | FromDiscord | <ElegantBeef> Ah aoc |
18:18:53 | FromDiscord | <shadow.> yup |
18:19:18 | FromDiscord | <ElegantBeef> Used sets + bitops for pt1 |
18:19:21 | FromDiscord | <shadow.> i was just using |
18:19:25 | FromDiscord | <shadow.> yeah |
18:19:33 | FromDiscord | <shadow.> i just used like uint64 + bitops |
18:20:09 | FromDiscord | <ElegantBeef> well i make a `set[0..35]`, then cast it to an int then use the `setMasked` and `clearMasked` |
18:20:22 | disruptek | of course. what else? |
18:20:35 | FromDiscord | <shadow.> ahh fair enough beef |
18:22:39 | * | leorize quit (Quit: WeeChat 2.9) |
18:23:18 | FromDiscord | <shadow.> ohh yeah that works well |
18:24:05 | * | Vladar joined #nim |
18:25:50 | FromDiscord | <shadow.> is there any elegant way to do int powers, or do you just have to cast args to float64 then cast result to int |
18:26:10 | FromDiscord | <ElegantBeef> `(1 shl i)` |
18:26:39 | FromDiscord | <Avatarfighter> is there a way to upgrade all nimble packages? |
18:27:00 | Araq | math.`**` also exists, not sure |
18:27:13 | disruptek | shhh |
18:27:16 | disruptek | this is more fun. |
18:27:39 | FromDiscord | <shadow.> ohh ok |
18:28:26 | FromDiscord | <shadow.> wait `` exists? |
18:29:01 | FromDiscord | <shadow.> `2 i` how would i do that with bitops? |
18:29:13 | FromDiscord | <ElegantBeef> it's literally `1 shl i` |
18:29:18 | FromDiscord | <shadow.> oh lmfao- |
18:29:32 | FromDiscord | <shadow.> ah right because |
18:29:34 | FromDiscord | <shadow.> times 2 i amount of times |
18:29:38 | FromDiscord | <shadow.> since binary is base 2 |
18:29:40 | FromDiscord | <shadow.> got it |
18:29:58 | FromDiscord | <ElegantBeef> Well you're moving the 1 into the i's place |
18:30:31 | FromDiscord | <shadow.> yeah |
18:30:58 | FromDiscord | <shadow.> but shifting 1 to the left by 1 is the same as multiply 1 by base, no? |
18:31:14 | FromDiscord | <shadow.> so 1 shl i is 1 base, i times |
18:31:22 | FromDiscord | <shadow.> (edit) "1" => "`1" | "i" => "i`" |
18:31:36 | FromDiscord | <ElegantBeef> No |
18:31:52 | FromDiscord | <ElegantBeef> 1 = 2^0, 2 = 2^1, 4 = 2^2 |
18:32:57 | FromDiscord | <ElegantBeef> it's the same as shifting the 1 left in base 10, 10 ^ 0 = 1, 10^1 = 10, 10^2 = 100 |
18:35:05 | FromDiscord | <Clyybber> disruptek: for what wrong resaons does carnac work |
18:36:20 | * | habamax joined #nim |
18:41:50 | FromDiscord | <fwsgonzo> does Nim have parameter packs? |
18:42:23 | FromDiscord | <ElegantBeef> What does that mean, are they like wolves? |
18:44:14 | FromDiscord | <fwsgonzo> sent a code paste, see https://play.nim-lang.org/#ix=2I3R |
18:44:20 | disruptek | clyybber: look at the README.md or the test.nim |
18:44:47 | disruptek | note the comments. i had to build up symbols to get the sem to work over the entire proc body. |
18:45:02 | FromDiscord | <fwsgonzo> but I'm not really after all of that, even if it would be nice to be able to say that Nim really does everything, I'm just after anything that is close enough |
18:45:13 | FromDiscord | <ElegantBeef> we've got `varargs` ๐ |
18:46:08 | * | azed quit (Read error: Connection reset by peer) |
18:46:11 | FromDiscord | <fwsgonzo> (edit) "enough" => "enough.โตThe code above takes a function call, prepends an argument to it, and then repacks the type so it can be called with something else. That's the short version." |
18:46:30 | FromDiscord | <ElegantBeef> But that requires homogeneous types, you can make a macro to emulate it |
18:46:38 | disruptek | clyybber: btw, afterAllWhatever seems to only run in carnac: but not .carnac. |
18:48:52 | FromDiscord | <fwsgonzo> doesn't look like varargs will work in this case |
18:49:27 | * | azed joined #nim |
18:49:53 | FromDiscord | <fwsgonzo> maybe the worst thing that still works is something like calling a C function that takes a function pointer and ...โต`void (void() (), ...)` |
18:50:44 | FromGitter | <fish-face> is there a version of `foldl` for iterators? and similar things in general? |
18:50:54 | FromDiscord | <ElegantBeef> Well yea i said it requires homogeneous values, you can make a `injectTypes` macro which will replace the args of procs declared below it with the types requested of it |
18:51:35 | FromDiscord | <ElegantBeef> you can `toSeq(iter)` but i dont think there are sequtil variants that work on iterators, although that'd be nice |
18:51:40 | FromDiscord | <fwsgonzo> looks like Nim supports a varargs pragma that lets you call it like printf |
18:51:57 | disruptek | gonzo: this seems pretty easy for a macro. |
18:52:28 | FromDiscord | <fwsgonzo> so the thing I really want is to check that the arguments you pass to ... fits the function you pass to void () () |
18:52:37 | FromDiscord | <fwsgonzo> (edit) "()" => "(), that is, type-checking the arguments against the functions type" |
18:52:46 | FromGitter | <fish-face> Yeah I know the `toSeq` thing but that's not lazy :P |
18:53:01 | FromGitter | <fish-face> no need to instantiate the entire seq unnecessarily |
18:53:19 | FromDiscord | <ElegantBeef> Well if you dont want to be lazy start to make sequtils that works on iterators ๐ |
18:53:34 | FromDiscord | <fwsgonzo> (edit) "..." => "`...`" | "void" => "`void" | "(), that is," => "()` <-.- can be a Nim function too, I suppose, then" |
18:54:04 | disruptek | gonzo: a nim macro can read the types of procs, etc. |
18:54:04 | FromDiscord | <ElegantBeef> Eventually we might be capable of `iterator[T]` so using templates for this kinda stuff might go away |
18:55:15 | FromGitter | <fish-face> yes, it seems difficult to treat iterators as types given that as I understand it they are implemented as templates |
18:55:46 | FromDiscord | <ElegantBeef> Well i've done it, so if i can anyone can ๐ |
18:55:55 | haxscramper | I want to specify retyn type of the generic based on argument type, but do so using custom expression with `when` e.g. `when arg is int: string else: int`. I tried https://play.nim-lang.org/#ix=2I3U , but actual type of the `arg` when specifying return type is `GenericParam` - https://play.nim-lang.org/#ix=2I3V . I can use `auto`, but since I have **exactly two** possible return types I would like to have some more constrained solution |
18:55:58 | FromDiscord | <ElegantBeef> Actually i misunderstood that |
18:56:16 | FromGitter | <fish-face> I see someone else was looking for `<<` above - what is the reason it is spelt as `shl` in nim? |
18:56:56 | * | Fish-Face joined #nim |
18:57:06 | Fish-Face | ah that's better |
18:57:11 | FromDiscord | <ElegantBeef> If you havent noticed most operators are shortened english, so probably stolen from a language that did as such |
18:57:13 | disruptek | thank you. |
18:57:25 | * | azed quit (Ping timeout: 246 seconds) |
18:57:27 | disruptek | haxscramper: seems a waste of time. |
18:57:37 | FromDiscord | <fwsgonzo> I'm not too familiar with macros in Nim, but I'm looking at them now |
18:57:51 | disruptek | haxscramper: use a template for your proc body impl. |
18:58:15 | FromDiscord | <Avatarfighter> disruptek: does nimph allow the mass upgrade of installed packages? |
18:58:20 | disruptek | yes. |
18:58:25 | Fish-Face | I only know of like... tcl which does that |
18:58:34 | FromDiscord | <Avatarfighter> You've converted me disruptek |
18:58:52 | disruptek | doubtful. |
18:59:59 | FromDiscord | <ElegantBeef> Well free pascal also uses `shl` and `shr` |
19:00:02 | disruptek | to restate, it lets you upgrade your /requirements/ within the project's net-net acceptable version ranges. |
19:00:39 | FromDiscord | <Avatarfighter> disruptek: that's still fine by me ๐ |
19:00:42 | FromDiscord | <Avatarfighter> thanks ! |
19:00:57 | disruptek | see `update` and `upgrade` subcommands. |
19:01:05 | disruptek | er, `outdated` and `upgrade`. |
19:01:11 | FromDiscord | <Avatarfighter> ill check it out once nimph is installed |
19:01:18 | disruptek | GLWT |
19:01:37 | disruptek | pretty sure it doesn't build anymore due to nimterop. |
19:02:49 | FromDiscord | <Avatarfighter> does nimterop not build for you either? |
19:03:31 | FromDiscord | <Avatarfighter> well it does build https://media.discordapp.net/attachments/371759389889003532/788118989658259476/Screen_Shot_2020-12-14_at_11.03.21_AM.png |
19:03:36 | FromDiscord | <Avatarfighter> nimph does |
19:03:39 | disruptek | nice. |
19:03:55 | * | mbomba joined #nim |
19:07:20 | FromDiscord | <inv> Hi. Any recomendations on decimal lib for nim? I know nimble search, but, like with mongo - probably better to ask ๐ |
19:07:35 | disruptek | i think people like decimal128. |
19:07:45 | FromDiscord | <inv> thx! |
19:07:54 | FromDiscord | <inv> thx! |
19:08:00 | disruptek | see what you think and report back, please. |
19:08:03 | disruptek | !repo decimal128 |
19:08:05 | disbot | https://github.com/JohnAD/decimal128 -- 9decimal128: 11A Decimal128 IEEE 754 2008 number library for the Nim programming language. 15 16โญ 1๐ด |
19:13:24 | Zevv | soo disruptek, arq is sitting behind his keyboard waiting for you to tell him what bugs to fix! |
19:16:57 | disruptek | he thinks the carnac demo's bug is due to the result sym; addResult() in semstmts. i don't see how, but that's the latest word from the mountaintop. |
19:17:34 | disruptek | i'm working on finding a job. no time to code. |
19:17:38 | Zevv | right so! |
19:18:06 | disruptek | what do you make of his rfc comments? |
19:18:11 | Zevv | lemme read up |
19:18:19 | Zevv | I like the "Enough of the talking" part |
19:19:29 | Zevv | not sure if I like weave to be pulled in as the appointed scheduled |
19:19:43 | disruptek | i told him you'd say that. |
19:19:45 | Zevv | feels a bit over the top to start with, but it'll make a nice test case |
19:20:10 | Zevv | i wonder if you and I can work together with mratsim; he kind of lives on another plane, not sure if he has the patience to deal with us |
19:20:29 | disruptek | i say we just make him write a dispatcher and call it good. |
19:20:38 | Zevv | right. *a* dispatcher |
19:20:46 | disruptek | right. |
19:21:08 | Zevv | because I'm not sure if weave will run on pmunch's atmega32 |
19:21:20 | disruptek | this is really araq's problem. |
19:21:41 | Zevv | and still I don't see how seqs and strings will fit in here |
19:21:50 | Zevv | but that's just me not understanding basic essential stuff |
19:22:25 | disruptek | eh they are fine but, look, weave's channels aren't csp. |
19:22:48 | disruptek | let's not lose sight of the real conceptual goal here. |
19:23:12 | Zevv | *your* goal |
19:23:15 | disruptek | seqs/strings are fine because isolate. |
19:23:15 | Zevv | is not by goal, boi |
19:23:19 | Zevv | yeah, that |
19:23:22 | Zevv | "because of isolate" |
19:23:30 | Zevv | will that look like a magic wand |
19:23:35 | Zevv | doing *poof* and everything is ok? |
19:23:44 | disruptek | it's pretty simple, yes. |
19:23:48 | Zevv | i don't understand it |
19:23:59 | disruptek | it's /really/ simple. |
19:24:05 | Zevv | if you weren't hunting jobs, you could explain to me as if I'm 5yo |
19:24:07 | disruptek | !rfc isolate |
19:24:08 | disbot | https://github.com/nim-lang/RFCs/issues/244 -- 3'isolated' data for Nim 7& 2 more... |
19:24:21 | Zevv | where's the mutex |
19:24:27 | disruptek | just, make sure the memory graph is /isolated/ from other memory graphs. |
19:24:35 | disruptek | that's it. |
19:24:42 | Zevv | we want to pass a string from thread a to thread b |
19:24:46 | Zevv | or is that not what wer'e doing here |
19:24:54 | disruptek | you can do that, yes. |
19:24:58 | Zevv | where's the mutex |
19:25:04 | disruptek | there is none. |
19:25:11 | Zevv | then you can't pass a string from thread a to thread b |
19:25:14 | disruptek | you don't /need/ one. |
19:25:16 | Zevv | the police will come |
19:25:19 | Zevv | and will take you away |
19:25:20 | FromDiscord | <Clyybber> Zevv: Its a move |
19:25:28 | FromDiscord | <Clyybber> it won't be shared |
19:25:34 | Zevv | doesn't matter |
19:25:36 | Zevv | you need a mutex |
19:25:37 | Zevv | point |
19:25:40 | disruptek | no. |
19:25:43 | Zevv | dudes |
19:25:46 | disruptek | dude. |
19:25:50 | FromDiscord | <Clyybber> only one thread can have it at a time |
19:25:53 | Zevv | you have data on a core. with NUMA memory, cache lines, whatever |
19:25:57 | Zevv | you want to pass it to antoher thread |
19:26:14 | Zevv | the mutex takes care of making sure the memory is actually valid & available at the other core |
19:26:22 | Zevv | you can not just do that without a memory barrier or mutex |
19:26:22 | Zevv | really |
19:26:32 | disruptek | that's not part of isolate. |
19:26:41 | Zevv | right |
19:26:51 | Zevv | that clears it up for me. |
19:26:57 | disruptek | okay ๐ |
19:27:16 | Zevv | so isolate makes sure that thread a gives it away to thread b, and then isn't even *able* to have a reference to it anymore |
19:27:19 | Zevv | that's it right |
19:27:25 | disruptek | yes. |
19:27:36 | Zevv | ok. I think I understand that |
19:27:38 | disruptek | it's a box that seals completely. |
19:27:40 | FromDiscord | <Clyybber> yep |
19:27:45 | disruptek | simple. |
19:27:48 | Zevv | ok. but then someone needs to have the mutex :) |
19:27:55 | disruptek | yes, but this is a dispatcher problem. |
19:28:05 | Zevv | not really. thread a creates a strings, writes in it |
19:28:12 | Zevv | it should hold the mutex while doing that |
19:28:26 | Zevv | then release it, give it to b. b holds the mutex, and only then can read the string |
19:28:42 | disruptek | only the rz needs a mutex. |
19:28:46 | Zevv | so while writing the data, you already need to know you will be passig it to another thread later on |
19:28:54 | disruptek | why? |
19:28:57 | Zevv | that's how it works |
19:29:05 | Zevv | i recently had 2 seniors fired over exactly this |
19:29:06 | FromDiscord | <Clyybber> the writes have to be finished |
19:29:13 | disruptek | you can have a barrier. |
19:29:19 | Zevv | there you go |
19:29:27 | FromDiscord | <Clyybber> but thats not an Isolate problem |
19:29:36 | Zevv | Clybber: true |
19:29:37 | disruptek | again, you only need to worry about this at the rz. |
19:30:00 | Zevv | what is rz |
19:30:07 | disruptek | rendezvous |
19:30:32 | disruptek | i think it's french for `fucking`. |
19:30:39 | Zevv | aah |
19:30:56 | FromDiscord | <Avatarfighter> Hey ! That's not true |
19:31:00 | Zevv | but still. memory barriers are expensive as hell, as you're not saying *what* you are barriering |
19:31:06 | Zevv | so that is where the mutex typically comes in |
19:31:13 | Zevv | but mratsim is the only one truly understanding this stuff |
19:31:14 | disruptek | look, "i don't care." |
19:31:21 | disruptek | it's not part of my design. |
19:31:24 | Zevv | true, true |
19:31:29 | Zevv | (reading time) |
19:32:04 | FromDiscord | <Avatarfighter> So what type of job are you looking to get disruptek? |
19:32:15 | FromDiscord | <19> does anyone know a nice Valgrind alternative for windows for nim? |
19:32:19 | disruptek | hooking is hard in the midst of a pandemic. |
19:32:28 | disruptek | 19: no. |
19:32:57 | FromDiscord | <19> k thx |
19:33:42 | disruptek | 19: let me put it this way, araq uses valgrind on linux to find leaks... and he's a windows user. |
19:33:47 | FromDiscord | <Clyybber> Zevv: This could also be the job of channels |
19:33:51 | FromDiscord | <Clyybber> I think |
19:34:02 | disruptek | clyybber: yes, this is the role for csp. |
19:34:16 | FromDiscord | <19> imma get a virtual machine then |
19:34:44 | FromDiscord | <19> thanks disruptek |
19:34:53 | disruptek | hope it helps. |
19:35:54 | FromDiscord | <Clyybber> or atomics |
19:36:33 | * | Jesin quit (Remote host closed the connection) |
19:36:39 | FromDiscord | <mratsim> I don't suppose there is a way to cast openarray[char] to openarray[byte] in a manner that works at compileTime :? |
19:37:20 | FromDiscord | <mratsim> @Zevv @disruptek sure i can write a dispatcher for IO, I wanted to write a WeaveIO anyway. |
19:37:47 | * | Jesin joined #nim |
19:37:52 | disruptek | yay ๐ |
19:37:55 | disruptek | job done. |
19:38:11 | FromDiscord | <Clyybber> :D |
19:38:34 | FromDiscord | <Clyybber> @mratsim don't think so |
19:38:37 | disruptek | i want to just look for IOEffect and CPSify the calls. |
19:38:44 | disruptek | simple. |
19:46:43 | disruptek | clyybber: whaddya think about user-supplied expr pragmas? |
19:47:53 | Zevv | clyybber: right, channels seems like the only way |
19:48:15 | Zevv | so we share nothing. |
19:48:35 | FromDiscord | <shadow.> nah |
19:48:37 | Zevv | this is one thing that still confuses me after years |
19:48:46 | FromDiscord | <shadow.> it's easy to setup a linux subsys on windows |
19:48:51 | FromDiscord | <shadow.> just do that |
19:48:53 | FromDiscord | <shadow.> way easier than a vm lmao |
19:49:08 | Zevv | I have two threads. A creates and writes to an object, while not holding any locks. How can A pass this memory safely to B |
19:52:58 | disruptek | let me ask you a question by way of answer. |
19:53:22 | disruptek | what makes you think it's unsafe for B to access this data? so what if the memory is already in the core's cache. |
19:53:52 | Zevv | there are no guarentees the memory is available to B. The compiler might have reordered stuff. |
19:53:58 | Zevv | you need a memory barrier |
19:54:02 | Zevv | but these are expensive as hell |
19:54:24 | disruptek | if it's not available, fetch it. |
19:54:38 | FromDiscord | <19> @shadow. i read somewhere that valgrind doesnt work with wsl |
19:54:40 | FromDiscord | <19> ill check it out |
19:54:46 | FromDiscord | <shadow.> ohhh |
19:54:52 | FromDiscord | <shadow.> might be the case then |
19:54:55 | FromDiscord | <mratsim> You know that my talk from June addresses this @ Zevv |
19:55:09 | Zevv | refresh my bookmarks mratsim |
19:55:23 | FromDiscord | <shadow.> i think it should work tbh |
19:55:25 | Zevv | I still feel stupid because I keep having these discussions with people, and they all think I'm mad |
19:55:35 | FromDiscord | <shadow.> i dont see why it wouldnt |
19:55:47 | FromDiscord | <mratsim> is your data a machine word at most? |
19:55:54 | ForumUpdaterBot | New thread by Mantielero: C++ Smart pointers 101 and FFI, see https://forum.nim-lang.org/t/7254 |
19:55:57 | disruptek | look, you're not wrong, but i think you might be applying some assumptions that aren't necessarily correct. |
19:56:10 | FromDiscord | <mratsim> in that case you can use atomics to ensure that you don't have torn read |
19:56:17 | Zevv | mratsim: My data is complex data. Say a seq of strings |
19:56:25 | Zevv | just real life stuff |
19:56:52 | Zevv | nim allocated, for simplicity, say we're running arc |
19:57:28 | FromDiscord | <mratsim> then you need some way to synchronize the thread |
19:57:34 | FromDiscord | <mratsim> tell them that the data is ready |
19:57:37 | Zevv | right |
19:57:41 | FromDiscord | <mratsim> the default should be a channel |
19:57:49 | FromDiscord | <mratsim> and otherwise locks |
19:57:52 | FromDiscord | <19> @shadow. looks like it does.. ill give it a shot |
19:57:53 | FromDiscord | <mratsim> and otherwise atomics |
19:58:05 | Zevv | but with locks, you _need_ to take the lock _before_ modifying the data from A, right? |
19:58:13 | FromDiscord | <mratsim> and otherwise there is a way to have a critical section without lock or atomics. |
19:58:22 | FromDiscord | <shadow.> gl |
19:58:25 | FromDiscord | <mratsim> like the Pederson lock or the lamport Bakery algorithm |
19:58:38 | Zevv | you know I don't know all these terms :) |
19:58:51 | FromDiscord | <mratsim> but you can wikipedia them :p |
19:59:13 | FromDiscord | <mratsim> it's basically a lock for platforms that don't support locks, like say the Playstation 2 Cell CPU |
19:59:21 | Zevv | yeah no, one step back |
19:59:28 | Zevv | the writer _holds the lock while writing the data_ |
19:59:33 | FromDiscord | <mratsim> yes |
19:59:46 | Zevv | but what if A has data that was written while not holding the lock |
19:59:53 | Zevv | and later decides it wants to share the data with B |
20:00:07 | Zevv | obvious is tkae a lock, *copy* the data, and send that to B |
20:00:13 | Zevv | but if you don't want the copy |
20:00:17 | disruptek | if you copy the data, you don't need the lock. |
20:00:25 | Zevv | right. but you don't want that. We want a move |
20:00:52 | disruptek | move is a misnomer. |
20:01:15 | FromDiscord | <mratsim> IDon't use a seq, use a linkedlist that hold strings? |
20:01:27 | Zevv | No, you're evading the answer |
20:01:29 | disruptek | doesn't matter. |
20:01:37 | FromDiscord | <mratsim> because if your seq needs to be resized in a new buffer, you will have a thread that points to invalid memory |
20:01:43 | FromDiscord | <myphs> Sorry for this probably nooby question, but nim's error message doesn't help me: So I wanted to try out `wNim`, but it says `C:\nim-1.4.0\lib\windows\winlean.nim(14, 8) Error: cannot open file: utils` when installing it and I can't find anything leading to this issue. Any hints? |
20:01:54 | disruptek | the memory will be invalidated already. |
20:02:14 | Zevv | mratsim: but ok, let's take just a plain solid memory block of bytes |
20:02:17 | Zevv | A writes there without holdign the lock |
20:02:22 | Zevv | and now wants B to have the data |
20:02:39 | Zevv | what is the primitive needed to make this safe, under all circumstances |
20:02:46 | FromDiscord | <mratsim> a channel |
20:02:46 | disruptek | yes, this is a problem we /do/ need to solve. |
20:02:54 | * | vicfred joined #nim |
20:02:57 | Zevv | mratsim: so, what *is* a channel |
20:03:01 | disruptek | but what is this mythical channel. |
20:03:06 | FromDiscord | <mratsim> but a channel basically encapsulate a solution to this problem |
20:03:10 | Zevv | yeah |
20:03:11 | Zevv | nice |
20:03:12 | Zevv | dude |
20:03:13 | disruptek | but what /it is/ |
20:03:17 | * | sirn quit (Ping timeout: 260 seconds) |
20:03:29 | Zevv | I don't wnat to encapsulate. I want to *understand* |
20:03:35 | Zevv | because to me, a channel is a thing that actually *copies* data |
20:03:37 | disruptek | i don't want our existing channels, which are just copies. |
20:03:43 | Zevv | right |
20:03:44 | Zevv | so |
20:03:44 | FromDiscord | <mratsim> It's a way to transfer either a data or ownership (represented by a sinked pointer) from thread to thread. |
20:03:49 | * | kwilczynski quit (Read error: Connection reset by peer) |
20:03:49 | Zevv | yeaaaah |
20:03:49 | Zevv | but |
20:05:42 | Zevv | how does it |
20:05:42 | Zevv | wok |
20:05:42 | Zevv | rk |
20:05:42 | disruptek | lol |
20:05:42 | FromDiscord | <mratsim> Weave uses ownership channels internally to avoid copies |
20:05:42 | * | sirn joined #nim |
20:05:42 | Zevv | are you trolling me :) |
20:05:42 | disruptek | jesus. |
20:05:42 | * | kwilczynski joined #nim |
20:05:42 | Zevv | what primitives does it rely on |
20:05:42 | Zevv | what makes it tick |
20:05:42 | FromDiscord | <mratsim> A channel is queue, except that the producer(s) and consumer(s) are in different thread |
20:05:42 | disruptek | assume you can move the pointer for free, what about the data? |
20:05:42 | FromDiscord | <mratsim> you assume that the pointer was the only way to access the data |
20:05:42 | Zevv | mratsim: ok, but what makes it safe for B to read the memory that was written by A |
20:05:42 | Zevv | there might be caching involved, or reordering |
20:05:42 | disruptek | how can you ensure the entire block is invalidated on B's cache? |
20:05:42 | FromDiscord | <mratsim> the pointer sinked into the channel is the only way to read:write the data |
20:05:53 | Zevv | yes but mratsim please |
20:05:59 | FromDiscord | <mratsim> the channel uses locks or atomics inside |
20:06:08 | Zevv | ok, so there is a lock on the *pointer* |
20:06:13 | Zevv | but there was never a lock on the original data |
20:06:16 | Zevv | right? |
20:06:19 | FromDiscord | <mratsim> This is the simplest channel you can have: https://github.com/mratsim/weave/blob/master/weave/cross_thread_com/channels_spsc_single_ptr.nim#L13-L45 |
20:06:21 | FromDiscord | <mratsim> no |
20:06:30 | Zevv | how can that work then? what do I miss? |
20:06:31 | disruptek | i don't see how this can work. |
20:06:35 | disruptek | lol |
20:06:45 | FromDiscord | <mratsim> no as in you're right no lock on the original data |
20:06:47 | disruptek | Zevv: ima walk the dog. i don't think you need me for this. ๐ |
20:06:56 | FromDiscord | <mratsim> the yes/no between countries is a bit strange |
20:07:22 | FromDiscord | <mratsim> https://github.com/mratsim/weave/blob/master/weave/cross_thread_com/channels_spsc_single_ptr.nim#L70-L109 |
20:07:43 | FromDiscord | <mratsim> the trySend and tryRecv transfer a pointer that represent the ownership over the data transferred |
20:08:06 | FromDiscord | <mratsim> you take a lock or atomics just to put or remove that from the channel |
20:08:11 | Zevv | but there is no memory barrier involved. I think I have a mental problem at some level |
20:08:27 | Zevv | I have done embedded work on arm cores, where share things really requires me to flush my dcaches |
20:08:28 | FromDiscord | <mratsim> https://github.com/mratsim/weave/blob/master/weave/cross_thread_com/channels_spsc_single_ptr.nim#L82 |
20:08:53 | FromDiscord | <mratsim> moAcquire and moRelaxed are reordering barrier and also forces the CPU to sync the core caches |
20:09:02 | Zevv | rrriight |
20:09:08 | Zevv | /that/ was the thing I was looking for |
20:10:02 | FromDiscord | <mratsim> if you have time, the talk from Herb Sutter, Weapons of <Atomic> destruction is good. |
20:10:13 | FromDiscord | <mratsim> or <std::Atomic> |
20:10:26 | FromDiscord | <mratsim> but it's 2 part 1h30 per part :p |
20:10:27 | Zevv | I will watch that tonight |
20:11:09 | FromDiscord | <mratsim> and this is a channel that copy in its buffer: https://github.com/mratsim/weave/blob/master/weave/cross_thread_com/channels_spsc_single.nim#L45-L47 |
20:11:33 | Zevv | sure, that makes sense |
20:11:57 | FromDiscord | <mratsim> it can only hold one item, if you want more you need either a bounded array or a way to reallocate while multiple threads read:write the data |
20:12:26 | Zevv | ok |
20:12:52 | * | opal quit (Remote host closed the connection) |
20:12:54 | FromDiscord | <mratsim> and so there are many types of channels/queues:โตmulti producer, multi consumer, single producer, single consumer, linked list based, array based. |
20:13:14 | FromDiscord | <mratsim> mix all together: http://www.1024cores.net/home/lock-free-algorithms/queues |
20:13:34 | * | opal joined #nim |
20:13:58 | FromDiscord | <mratsim> and then you have the progress guarantees (lock-based, lock-less, obstruction-free, lock-free, wait-free) |
20:15:03 | * | narimiran quit (Ping timeout: 256 seconds) |
20:19:33 | FromDiscord | <19> @shadow. valgrind online wsl |
20:20:23 | FromDiscord | <shadow.> nice |
20:21:58 | * | habamax quit (Ping timeout: 260 seconds) |
20:24:32 | * | vicfred quit (Ping timeout: 256 seconds) |
20:28:35 | Zevv | sure mratsim, but I only wanted to know what these are built on |
20:28:44 | Zevv | so its either locks or barriers |
20:33:48 | * | fanta1 quit (Quit: fanta1) |
20:43:17 | * | vicfred joined #nim |
20:46:46 | disruptek | locks don't help afaict. |
20:49:49 | FromDiscord | <mratsim> they do |
20:49:56 | FromDiscord | <mratsim> locks or atomics |
20:50:47 | disruptek | but how does the lock affect stale data in the receiving core? |
20:50:48 | FromDiscord | <mratsim> This one is lock-based and plenty fast: https://github.com/mratsim/weave/blob/v0.1.0/unused/channels/channels_legacy.nim#L31 |
20:51:34 | disruptek | i don't have the bandwidth to use github. |
20:52:15 | disruptek | anyway, i'm not worried about speed. ๐ |
20:52:55 | FromDiscord | <mratsim> When you read data, your CPU will check if there is a cache reload needed. |
20:53:24 | FromDiscord | <mratsim> The lock implementation in the kernel should trigger the "invalidate all cache" primitive. |
20:53:27 | disruptek | just based on whether the lock has tainted? |
20:53:31 | FromDiscord | <mratsim> which is a memory barrier |
20:53:37 | disruptek | okay, that makes sense. |
20:53:53 | disruptek | i would say that i'm in favor of locks, then. |
20:54:22 | disruptek | they are fast and reliable. |
20:54:30 | FromDiscord | <mratsim> If you use heavy data structures like seq of strings, lock are much eaier to reason about. |
20:54:38 | disruptek | yes. |
20:54:46 | FromDiscord | <mratsim> but the risk is that deadlocks can happen. |
20:55:01 | disruptek | we can code those out eventually. |
20:55:05 | FromDiscord | <mratsim> atomics are a pain to get right, but deadlocks can't happen |
20:55:23 | FromDiscord | <mratsim> As a general purpose, Nim should use locks first |
20:55:38 | disruptek | agree. |
20:55:40 | FromDiscord | <mratsim> and use atomics in very specific cases with a well tested implementation |
20:56:01 | FromDiscord | <mratsim> As an example it took me a month + formal verification to get my channels right. |
20:56:29 | FromDiscord | <mratsim> well, single consumer single producer channel are easy to do, there are only 2 threads to synchronize so using atomics is very easy |
20:56:48 | disruptek | what we can do to help weave's dispatcher is include some CPS metadata in the generated procs. |
20:56:50 | FromDiscord | <mratsim> but the multi producer that enqueue data and single consumer ... that was a time sink |
20:57:47 | disruptek | i think it will be MPMC to start. at least, that's what araq is working on with isolate. |
20:58:31 | FromDiscord | <mratsim> Basically I encapsulate what I send to other core in a Task data structure, it has: a proc {.nimcall.} of the code block to execute, a environment (max 144 bytes) and the rest is metadata for Weave scheduler (loop counter, start, stop, parent task, ...) |
20:58:33 | disruptek | if you tell me what you'd want to know about the continuation, i can include it in the procdef. |
20:59:00 | disruptek | so you want the originating call? |
20:59:06 | FromDiscord | <mratsim> so really, the only thing I need is that the continuation is proc {.nimcall.} + an environment to execute |
20:59:19 | FromDiscord | <mratsim> I can call the continuation from CPS |
20:59:29 | disruptek | can the environment just be a pointer or does it have to be a complete value? |
20:59:33 | FromDiscord | <mratsim> as long as it ends up executing the code block |
21:00:38 | FromDiscord | <mratsim> It can but I prfer it to be a complete value because the way I do it, the environment and Task metadata are put together in a 256 bytes memory block |
21:00:54 | FromDiscord | <mratsim> and I use a memory pool to allocate:deallocate those in a fast manner. |
21:01:51 | Zevv | problem is mratsim, that all of the stuff you are doing is soo way overoptimized for the "normal" use cases. people just want to share nim data |
21:02:00 | FromDiscord | <mratsim> Also I use the first 8 bytes of the environment to put a pointer to a channel/future/flowvar that can be waited to get a result. |
21:02:05 | Zevv | we can't sell this stuff if you have to pointer case your way out of the nim allocators |
21:02:12 | Zevv | s/case/cast/ |
21:02:17 | disruptek | so maybe we have a "large" env and a "fast" env. |
21:02:38 | FromDiscord | <mratsim> Well as I said multiple times, Weave doesn't fit the IO usecase |
21:02:43 | disruptek | the alloc and pooling stuff doesn't bother me, but we will need to disambiguate. |
21:03:03 | FromDiscord | <mratsim> if you have a large env, put it on the heap and a pointer to it. |
21:03:06 | Zevv | mratsim: right. So who will tell araq. |
21:03:09 | FromDiscord | <mratsim> in the "fast env |
21:03:23 | Zevv | because I feel the same thing. |
21:03:25 | disruptek | do you keep a pointer to the exceptions? |
21:03:26 | FromDiscord | <mratsim> What I can do is make Weave able to execute the continuations |
21:03:34 | disruptek | exactly; this is what we're working on. |
21:03:45 | FromDiscord | <mratsim> but it shouldn't be the main executor |
21:03:52 | FromDiscord | <mratsim> because CPS primary use case is async/IO |
21:03:55 | Zevv | ok, so we're all on the same page |
21:04:07 | Zevv | but CPS /can be/ a nice addition to weave |
21:04:16 | disruptek | when you say, "first 8 bytes", do you mean "first object field" or do you literally mean "first 8 bytes of the alloc"? |
21:04:42 | FromDiscord | <mratsim> also Weave doesn't have any way to ensure latency fairness, it focus on expediting the total work, but the first one to enqueue the work might very well be the last to get a response |
21:04:51 | disruptek | don't care. |
21:05:02 | FromDiscord | <mratsim> my Task object are type erased |
21:05:08 | FromDiscord | <mratsim> so the environment is just raw bytes. |
21:05:09 | disruptek | okay. |
21:05:40 | Zevv | so |
21:05:42 | disruptek | this will be challenging to make work but i think we can do it. |
21:05:50 | FromDiscord | <mratsim> which makes it a bit of a pain to organize the code so that the type are kept in the public API. |
21:05:56 | disruptek | yeah. |
21:06:14 | FromDiscord | <mratsim> but Nim Flowvars have the same issue. |
21:06:42 | Zevv | long story short. weave should be able to cooperate with CPS by executing its continuations. So for certain use cases that will be cool. |
21:07:17 | disruptek | yes, but it will need a special weave-friendly continuation type that both works with CPS and works with weave. |
21:07:27 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#ix=2I4J |
21:07:39 | disruptek | that will be good for us, because it will force us to keep the interface correct. |
21:08:11 | FromDiscord | <mratsim> It must be a stack object and N <= 144. If there are more bytes in the environment, it's likely a good idea to have some heap alloc anyway |
21:08:12 | Zevv | disruptek: let me start nagging about this once more: you insist on your concepts, but what does that bring for now, in practical terms |
21:08:27 | Zevv | because in practice, a continuation is an *object* with a proc and data. Why the abstracion |
21:08:39 | Zevv | mratsim: what is magic about 144? |
21:09:02 | FromDiscord | <mratsim> It leaves me 112 bytes of metadata for Weave ๐ |
21:09:04 | disruptek | it brings the fact that a weave Task could be a continuation even if it doesn't look like our typical Env types. |
21:09:28 | disruptek | the main thing is that it lets the user define their continuation types. |
21:09:31 | FromDiscord | <mratsim> And 256 bytes is a nice power of 2 for a memory allocator |
21:09:44 | FromDiscord | <mratsim> I don't mind the concept. |
21:13:00 | FromDiscord | <mratsim> It would be nice if the C++ folks always output nice PDF instead of text: but I guesss it would be easy on disruptek data: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html |
21:13:19 | disruptek | Zevv: let me start nagging about this once more: you insist on your `fn` but what does that bring, in a world where calls are invoked against static types? |
21:13:32 | FromDiscord | <mratsim> I didn't have time to read the C++ executor latest proposal but they have been thinking on the API/interface around task, async, thread for 20 years. |
21:14:28 | * | Jesin quit (Quit: Leaving) |
21:14:32 | disruptek | jesus. |
21:14:42 | FromDiscord | <mratsim> Also AFAIK from scheme, continuations (call/cc) can be used as primitives to execute closures, async, thread spawns, state machines. |
21:16:02 | FromDiscord | <mratsim> so if a continuation concept is just (fn + env) with the machinery provided by CPS. We can build plenty of things on top. |
21:16:10 | * | Jesin joined #nim |
21:16:14 | disruptek | yes, of course. |
21:16:15 | FromDiscord | <mratsim> even npeg ๐ |
21:18:22 | FromDiscord | <mratsim> anyway, I think the best way to discuss is to actually have code ๐ |
21:19:05 | disruptek | the thing is, i usually throw away most of the bullshit that these other implementations demand. |
21:19:18 | disruptek | the result is something more abstract and, to my mind, more desireable. |
21:19:26 | disruptek | but that might not be the case for everyone's application. |
21:20:06 | Zevv | disruptek: fair enough |
21:20:52 | disruptek | Zevv: what if your continuation is just an env. you run it through a function and the result is a pointer to the /next/ function. |
21:21:02 | disruptek | i don't really see the problem. |
21:21:13 | Zevv | not a problem |
21:22:04 | FromDiscord | <mratsim> I don't see a problem with something abstract here, given how core it is and also because it's rooted in theory |
21:22:17 | Zevv | true |
21:22:35 | FromDiscord | <mratsim> Abstract thing from theory have less chance of become obsolete and then causing deprecation woes. |
21:22:44 | FromDiscord | <mratsim> I mean, if haskell had to deprecate Monad ... |
21:23:25 | disruptek | well, i think the limits should be those of nim, not some design that was predicated on someone else's constraints. |
21:23:36 | FromDiscord | <mratsim> yes |
21:24:03 | FromDiscord | <mratsim> that said I have to investigate more on continuation because I thought the minimum needed was function + environment |
21:24:07 | FromDiscord | <mratsim> not just environment |
21:24:28 | disruptek | the dispatcher needs the fn but i've never cared about it. |
21:24:37 | FromDiscord | <mratsim> Ok |
21:24:40 | Zevv | disruptek was always two steps ahead of me |
21:24:52 | Zevv | on /some/ parts :) |
21:25:01 | disruptek | well, i just have a different idea about composition, i think. |
21:25:30 | Zevv | the reason I don't care about all that is that I just want concrete, working, functional CPS first |
21:25:33 | Zevv | but I don't mind |
21:25:42 | FromDiscord | <mratsim> well, the minimum a dispatcher/executor/scheduler needs is:โตa function to call, an environment to pass to that function, and a channel to communicate the result if the function has a return value. |
21:26:01 | FromDiscord | <mratsim> call that channel Flowvar or Future if you want. |
21:26:07 | Zevv | I don't get the last bit |
21:26:41 | FromDiscord | <mratsim> if you send a+b on another thread, you need a way to get that result. |
21:26:54 | disruptek | look at how we do the `let x = result-of-CPS()`. we just create a new env that contains `x` with the value of `result-of-CPS` and we invoke it whenever, wherever. |
21:27:01 | FromDiscord | <mratsim> solution a: the user put that on shared memory and deal with synchronization |
21:27:49 | FromDiscord | <mratsim> solution b: you have a way to safely pass data between threads, you use it (a channel), but you call that what everyone calls it, i.e. a future |
21:28:22 | Zevv | solution c: treat the return value as part of the environment and just pass it around like before |
21:28:58 | FromDiscord | <mratsim> it's actually the same because you need to pass the channel address to the function. |
21:29:09 | FromDiscord | <mratsim> or at least Weave uses b+c |
21:29:12 | Zevv | sure, but re-uses the same mechanism |
21:29:34 | FromDiscord | <mratsim> the first 8 bytes of the environment are the channel address |
21:30:26 | FromDiscord | <mratsim> so this means that Weave and CPS use the same return value mechanism |
21:31:28 | disruptek | we can, but i hope to get to a point where CPS's processes are implemented entirely statically, in the type system. |
21:31:44 | Zevv | what do you mean by "processes" |
21:31:53 | disruptek | process == "channel address" |
21:32:23 | Zevv | right |
21:32:53 | disruptek | anyway, the action item is to make Task a CPS-able continuation. |
21:33:04 | FromDiscord | <mratsim> I'm unsure we can, because we likely have to type-erase the environment and so the return type. |
21:33:04 | disruptek | also, to make typed CPS work. |
21:33:19 | Zevv | that, especially |
21:33:25 | FromDiscord | <mratsim> or we can make task embed CPS continuation. |
21:33:26 | Zevv | because untyped it is not usable |
21:33:40 | disruptek | i am not sure return type is a thing, but i could be wrong about that. |
21:34:00 | disruptek | like, i'm not sure it /ever/ means anything to me. |
21:34:08 | Zevv | I'm hopping out ppl, dump any conclusions in the RFC thread, if you find any |
21:34:13 | disruptek | aight, peace. |
21:34:16 | FromDiscord | <mratsim> but Task has to be untyped because I need to be able to enqueue Tasks from various proc calls/envs |
21:34:35 | disruptek | untyped? |
21:34:40 | FromDiscord | <mratsim> so high-level is typed and low-level that is dispatched is untyped. |
21:34:45 | FromDiscord | <mratsim> type erased |
21:34:49 | disruptek | oh, of course. |
21:40:09 | FromDiscord | <mratsim> hoho, found the C++ PoC for unified executors: https://github.com/facebookexperimental/libunifex, https://www.youtube.com/watch?v=tF-Nz4aRWAM |
21:44:45 | FromDiscord | <Quibono> Is there a good pointers for dummies resource? |
21:46:07 | Zevv | Quibono: using or understanding? |
21:46:54 | FromDiscord | <Quibono> I get that pointers are memory references, but not really why the hell id use them or how. |
21:47:27 | Zevv | http://zevv.nl/nim-memory/ |
21:47:44 | Zevv | what's your background, what languages do you come from? |
21:47:58 | FromDiscord | <Quibono> Python loll |
21:48:12 | Zevv | in python, everything is a point[D[D[D[D[D[D[Der |
21:48:41 | Zevv | so you have a var a pointing to something |
21:48:44 | Zevv | you do 'b = a' |
21:48:52 | Zevv | now you have two pointers to the same thing |
21:49:31 | FromDiscord | <Quibono> Okay, so when I assign something in python Iโm really just referencing it, not copying |
21:49:40 | FromDiscord | <Quibono> Right? Or am I off already |
21:49:58 | * | natrys quit (Ping timeout: 246 seconds) |
21:50:04 | Zevv | that's it |
21:50:12 | Zevv | so in nim, you would use a "ref" for that |
21:50:35 | Zevv | which means "A pointer managed by nim" |
21:52:11 | FromDiscord | <Quibono> Okay. |
21:52:43 | Fish-Face | pointer fun with binky? |
21:52:45 | FromDiscord | <mratsim> Maybe it's clearer if instead of reference you use the term location? |
21:53:03 | FromDiscord | <mratsim> a pointer is the location of some data in memory. |
21:53:40 | FromDiscord | <Quibono> So, I guess my question is, why use pointers directly for anything? |
21:53:44 | FromDiscord | <mratsim> If you want people to enjoy that data, either you share the location (copy the reference) or you copy the data. |
21:54:21 | FromDiscord | <mratsim> It's an escape hatch for low-level programming, because deep down, everything is either data or location of data |
21:55:14 | FromDiscord | <mratsim> I'm not joking. In assembly, all instructions either take add(data, data) or add(memory, data) or add(data, memory) |
21:55:30 | FromDiscord | <mratsim> with data being a CPU register at hardware level. |
21:55:43 | FromDiscord | <Quibono> Right. Iโve heard using pointers can be used to make code faster? |
21:56:00 | disruptek | if you don't have to copy data to share it, yes, that's faster. |
21:56:03 | FromDiscord | <mratsim> it's not magic |
21:56:29 | FromDiscord | <mratsim> Nim ref object avoid copy as well. |
21:56:58 | FromDiscord | <mratsim> Another way to make them faster is because pointers are completely unchecked, meaning if there is a bug you are alone to find it. |
21:56:59 | FromDiscord | <Quibono> So if I say B = C, am I copying data by default? |
21:57:19 | FromDiscord | <mratsim> if B is an integer, yes, if it's an array yes, if it's a ref object no |
21:57:45 | FromDiscord | <mratsim> the difference is captured by the term "value semantics vs reference semantics" |
21:59:01 | * | mbomba quit (Quit: WeeChat 3.0) |
22:04:03 | FromDiscord | <kenran> sent a code paste, see https://play.nim-lang.org/#ix=2I50 |
22:04:10 | FromDiscord | <kenran> (edit) |
22:05:10 | FromDiscord | <kenran> I'm not really sure if I'm using `ortho` correctly, following the tutorial code at https://github.com/JoeyDeVries/LearnOpenGL/blob/master/src/7.in_practice/2.text_rendering/text_rendering.cpp |
22:05:19 | FromDiscord | <kenran> (edit) "following" => "trying to follow" |
22:07:26 | FromDiscord | <kenran> ah shit, already see my error. my `glUseProgram` came too late |
22:12:40 | * | Vladar quit (Quit: Leaving) |
22:29:38 | * | mbomba joined #nim |
22:35:39 | * | mbomba quit (Quit: WeeChat 3.0) |
22:37:33 | FromDiscord | <shadow.> you can break on `case`, right? |
22:42:57 | * | haxscramper quit (Remote host closed the connection) |
22:43:27 | FromDiscord | <dom96> Every day I get closer and closer to making my own version of `black` for Nim |
22:43:38 | disruptek | what? |
22:43:46 | * | kenran quit (Remote host closed the connection) |
22:49:01 | FromDiscord | <Quibono> ... ๐ |
22:49:09 | FromDiscord | <Quibono> @dom96 +1 |
22:52:19 | FromDiscord | <Quibono> Disruptek Black is basically Python's version of your coding syntax guide, it controls all the minutiae of your code formatting |
22:52:39 | FromDiscord | <Quibono> Super opinionated and washes everything in its goodness. |
22:53:53 | disruptek | that's harder to impl then you might think, and i certainly don't think it's worthwhile as long as it's easy to write (and rewrite) code to whatever style you like. |
22:54:42 | disruptek | i don't rewrite a lot of my code to whatever my current style is, and i don't rewrite much compiler code that i work on. |
22:54:51 | disruptek | it's far more important that the code works. |
22:55:48 | FromDiscord | <Quibono> It just adds to readability and consistency |
22:56:01 | FromDiscord | <Quibono> Any python project that uses Black, has similar looking source code. |
22:56:19 | disruptek | yeah, it sounds nice. if it were free, i'd use it. |
22:57:17 | FromDiscord | <Quibono> Yeah I mean I certainly wouldn't write it |
22:57:45 | FromDiscord | <Quibono> But I'd use it |
22:58:09 | disruptek | anyone have any feedback about my style shit? |
22:58:26 | disruptek | i don't think i've heard any + or - on any of it. |
22:59:12 | FromDiscord | <Quibono> Mhmm, I'd love it if you rewrote the guide to be more... IDK, clear? It feels like rules come up randomly. |
22:59:31 | FromDiscord | <Quibono> _is going to go back to reading it and will comment._ |
23:00:22 | disruptek | yes, they were added randomly. there's a lot of bleed between return/result and the preceding section. but that's not easy to avoid. |
23:01:30 | disruptek | commenting on the gist itself might not be a bad idea, either. |
23:02:15 | FromDiscord | <Quibono> Can you relink it? |
23:03:13 | disruptek | ~disrupstyle |
23:03:13 | disbot | disrupstyle: 11tips for writing code that won't provoke ๐ rants ๐คฌ on irc: https://gist.github.com/disruptek/6d0cd6774d05adaa894db4deb646fc1d -- disruptek |
23:04:50 | FromDiscord | <Quibono> So why are you against ending with result = x? |
23:05:08 | disruptek | i'm not. |
23:05:15 | FromDiscord | <Quibono> Lol then carry on |
23:05:34 | FromDiscord | <dom96> huh, guess I'm new to Nim |
23:06:09 | disruptek | hi! |
23:07:08 | FromDiscord | <Quibono> So Dom when do you start? ๐ฎ |
23:13:41 | Fish-Face | My rust friend beat my for speed on AoC :( |
23:21:01 | FromDiscord | <juan_carlos> Some people say that continue and break are just a named GOTO. |
23:21:15 | disruptek | they are. |
23:21:50 | FromDiscord | <j-james> crabs are fast little buggers |
23:22:19 | disruptek | they all die in the kerosene, though. |
23:23:32 | FromDiscord | <Quibono> Napalm disruptek, it's gotta start with N |
23:24:17 | disruptek | i'm not putting napalm on my junk; i don't care how reliable it is. |
23:25:22 | FromDiscord | <Quibono> ... you're putting kerosene on your junk? |
23:25:31 | FromDiscord | <Quibono> Dude you've got more problems then I thought lol |
23:25:31 | disruptek | best way to get rid of crabs. |
23:25:50 | FromDiscord | <Quibono> I think they've got meds for that. |
23:26:10 | disruptek | i don't have healthcare. |
23:26:13 | disruptek | you know what i have? |
23:26:15 | disruptek | kerosene. |
23:26:31 | FromDiscord | <Quibono> Lol okay but I think crabs are better than kerosene-junk |
23:26:41 | disruptek | you've never had crabs. |
23:29:09 | FromDiscord | <j-james> what's wrong with my regex here? |
23:29:13 | FromDiscord | <j-james> sent a code paste, see https://play.nim-lang.org/#ix=2I5q |
23:31:48 | FromDiscord | <Adalogic> How would one update their Nim version? I see that `choosenim` has a command for it, but I did not install using `choosenim` and attempting to install it with Nimble produces a quite indecipherable error (unless I'm not supposed to install choosenim that way and I'm just small-brain). |
23:36:03 | FromDiscord | <ElegantBeef> To install choosenim follow this https://github.com/dom96/choosenim#installation |
23:37:19 | FromDiscord | <ElegantBeef> You may also want to remove nim from however you installed it before hand as it would probably interfere |
23:38:43 | FromDiscord | <martinium> Choosenim ๐๐ฝ |
23:38:49 | FromDiscord | <martinium> Very useful |
23:39:01 | FromDiscord | <martinium> Reminds me of Rustโs rustup |
23:40:25 | FromDiscord | <ElegantBeef> Well we also have gitnim |
23:40:42 | FromDiscord | <ElegantBeef> Or w/e disrupteks version is called |
23:40:47 | disruptek | ~gitnim |
23:40:48 | disbot | gitnim: 11https://gitnim.com/ -- choosenim for choosey nimions -- disruptek |
23:41:17 | FromDiscord | <ElegantBeef> Rumour has it disruptek sits by waiting for mention of his software to pounce at the chance to show it ๐ |
23:42:08 | disruptek | and you ask me why i don't sleep at night. |
23:42:46 | disruptek | actually, gitnim is about to grow into a proper distribution. |
23:43:41 | FromDiscord | <ElegantBeef> Do you have plans to have a shippable binary to make it not require sourcing Nim before using? |
23:45:21 | disruptek | do you have plans to read the readme? |
23:46:03 | * | aHaquer joined #nim |
23:46:07 | aHaquer | Ello |
23:46:19 | FromDiscord | <dom96> that is what inspired choosenim ๐ |
23:47:02 | FromDiscord | <ElegantBeef> I mean your installation states you build it using `nim c` |
23:47:17 | * | krux02 quit (Remote host closed the connection) |
23:47:17 | disruptek | choosenim is what inspired gitnim. if it didn't suck a big donkey dick, i'd probably never have written it. |
23:47:47 | FromDiscord | <ElegantBeef> Ah didnt see that it shipped a prebuilt nim binary |
23:49:42 | * | aHaquer left #nim (#nim) |
23:50:06 | * | aHaquer joined #nim |
23:59:03 | * | aHaquer left #nim (#nim) |