00:00:12 | * | tk quit (Quit: Well, this is unexpected.) |
00:00:19 | FromDiscord | <andi-> Ok, with readData my tests pass. |
00:00:37 | * | tk joined #nim |
00:08:39 | FromDiscord | <evoalg> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=3F1s for instance": noob question time again ... I was looking at your https://play.nim-lang.org/#ix=3F1s and I'm wondering why unsafeaddr is used ... and what's Idx? |
00:09:32 | FromDiscord | <Elegantbeef> Unsafeaddr is used since `a` is passed as immutable, `Idx` is the index generic, and `T` the type generic |
00:10:06 | FromDiscord | <Elegantbeef> Remember in Nim unlike other languages arrays have a size type attached to them so `var a: array[10,int] = default(array[3, int])` is an error |
00:11:18 | FromDiscord | <Elegantbeef> `unsafeaddr` is just a way to be slightly more clear about overcoming immutable references, but there is an RFC to remove it since it implies `addr` is safe |
00:11:46 | FromDiscord | <evoalg> lol true it does! |
00:12:33 | FromDiscord | <evoalg> `addr` is a pointer? ... and not a safe pointer like a ref? |
00:13:01 | FromDiscord | <Elegantbeef> Yep `addr` can be a pointer to any addressable value |
00:13:19 | FromDiscord | <Elegantbeef> For it to be safe you need to know a few things about what you're doing |
00:14:11 | FromDiscord | <Elegantbeef> If the object is on the stack and you keep the address the address should not outlive the object. If it's a ptr to a managed type you should not mutate that type. |
00:16:05 | FromDiscord | <evoalg> and with a ref I can mutate and it'll handle it fine? |
00:29:10 | FromDiscord | <Elegantbeef> Yea cause the object will not be destroyed whilst you hold onto a reference |
00:29:15 | FromDiscord | <Elegantbeef> Example time! |
00:33:56 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3F1F |
00:34:01 | FromDiscord | <Elegantbeef> Not a great example but meh |
00:41:58 | FromDiscord | <Elegantbeef> It atleast shows the issue with a pointer to a sequences value, the latter part is pretty pointless i guess |
00:42:09 | FromDiscord | <Elegantbeef> Since if they were `ptr int` it'd be the same |
00:47:42 | FromDiscord | <evoalg> I'm trying to understand the 2nd part ... lemme stare at it for a bit longer |
00:48:20 | FromDiscord | <Elegantbeef> It's just using reference ints instead of normal ints which means there are nim managed pointers instead of integers stored in the sequence |
00:48:55 | FromDiscord | <Elegantbeef> do `echo c.repr` after it was added and you'll see what it's doing |
00:55:20 | FromDiscord | <evoalg> I went back to look at the first part ... you take the address of a[0] because a.address is a pointer to a pointer by the looks, yea I seem to remember that containers names are pointers |
00:56:04 | FromDiscord | <Elegantbeef> Not always the case but close enough |
00:56:56 | FromDiscord | <evoalg> hehehe |
00:58:20 | FromDiscord | <evoalg> btw I really like how you can explain things at my level, it makes for a great teacher |
00:59:50 | FromDiscord | <Elegantbeef> Excuse me whilst i find a textbook and tell you "If you havent read this, i cannot help you" to get the full teacher experience |
01:01:57 | FromDiscord | <evoalg> lol exactly 😉 |
01:03:39 | FromDiscord | <evoalg> That `c.add:` you do with the multi lines, I didn't know you could do that ... it looks similar syntax to a `collect:` ... here's me thinking it was a collect thing and not actual nim syntax |
01:03:51 | FromDiscord | <Elegantbeef> Yep it's for all calls |
01:03:58 | FromDiscord | <Elegantbeef> It's quite nifty |
01:04:18 | FromDiscord | <impbox [ftsf]> what? |
01:04:20 | FromDiscord | <impbox [ftsf]> i never knew this |
01:04:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F1J |
01:05:00 | FromDiscord | <Elegantbeef> forgot to call `invokeProcs()` 😛 |
01:08:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F1K |
01:17:09 | FromDiscord | <evoalg> I finally understand your addr code snippet after starting at it for 45 mins (and playing with lots of repr's) ... I'm so slow .. thank you ElegantBeef. I'm not going to try and understand that obfuscation you just posted though 😉 |
01:17:42 | FromDiscord | <Elegantbeef> That above code is just a odd syntax for anonymous procedures 😀 |
01:18:02 | FromDiscord | <Elegantbeef> it's the same as `addProc proc (a, b: int) = echo a b` |
01:37:36 | * | krux02 quit (Remote host closed the connection) |
02:30:22 | * | vicecea quit (Remote host closed the connection) |
02:30:52 | * | vicecea joined #nim |
02:56:53 | FromDiscord | <evoalg> I can't seem to use `var` or `let` in collect ... https://play.nim-lang.org/#ix=3F1Z |
02:58:32 | FromDiscord | <Elegantbeef> Why even use collect here? |
02:59:06 | FromDiscord | <evoalg> I was doing something more complicated with a for loop, but I just wanted a simple example to show |
02:59:15 | FromDiscord | <Elegantbeef> Ah |
02:59:32 | FromDiscord | <evoalg> I can put a more realistic one |
03:00:49 | * | Guest9 joined #nim |
03:02:32 | FromDiscord | <Elegantbeef> Ah the issue is the way the collect macro works |
03:03:11 | FromDiscord | <Elegantbeef> It redeclares the variables in the expression, which causes an issue |
03:04:51 | FromDiscord | <evoalg> ok ... it could be argued that if it get's complicated enough to declare vars, use a proc ... that makes sense to me |
03:05:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F26 |
03:06:04 | FromDiscord | <Elegantbeef> Using a template instead of a variable declaration cause we're barbarians 😀 |
03:07:56 | FromDiscord | <evoalg> whoa ... but seriously should I use that way or a proc? |
03:08:07 | FromDiscord | <Elegantbeef> Probably a proc |
03:08:24 | FromDiscord | <Elegantbeef> You could also write collect manually |
03:08:30 | FromDiscord | <evoalg> I guess you were hinting that using a templet there is barbaric |
03:08:35 | FromDiscord | <evoalg> oh? |
03:08:41 | FromDiscord | <evoalg> oh right yes |
03:08:42 | * | Guest9 quit (Quit: Client closed) |
03:09:17 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F27 |
03:09:24 | FromDiscord | <Elegantbeef> Not as nice as collect but it's what collect does internally |
03:09:32 | FromDiscord | <evoalg> oh! |
03:10:36 | FromDiscord | <evoalg> my more "realistic" eg: https://play.nim-lang.org/#ix=3F24 |
03:10:49 | FromDiscord | <evoalg> I can put that in a proc instead |
03:10:54 | FromDiscord | <Elegantbeef> Yep |
03:11:00 | FromDiscord | <Elegantbeef> I love me some scanf 😀 |
03:11:21 | FromDiscord | <evoalg> that's because you haven't fallen in love with regex's yet |
03:11:30 | FromDiscord | <Elegantbeef> Never! |
03:11:47 | FromDiscord | <Elegantbeef> I really love scanf since it captures variables, and the tuple variant i wrote is even nicer |
03:12:08 | FromDiscord | <evoalg> hehe ... oh tuple variant? |
03:12:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F29 |
03:13:20 | FromDiscord | <Elegantbeef> Yea there is a scantuple which does the same thing as scanf but returns a tuple |
03:14:05 | FromDiscord | <evoalg> that is nicer! |
03:16:08 | FromDiscord | <evoalg> regex's were so easy in Perl, but the symbols aren't user-friendly, Python's regex are just "ok", but nim's are more painful |
03:17:06 | FromDiscord | <evoalg> several completing regex modules, each incomplete, each difficult to use |
03:17:50 | FromDiscord | <evoalg> but I do like scanf 🙂 |
03:18:52 | FromDiscord | <Elegantbeef> I dont generally deal with arbitrary text, it's generally text that follows a simple pattern and i want the values from it in a specific format, so regex makes me do more work than scanf/PEGs |
03:24:02 | FromDiscord | <evoalg> PEGs ? |
03:30:10 | FromDiscord | <Elegantbeef> Patterns and grammars for instance https://github.com/zevv/npeg |
03:51:35 | * | Yardanico quit (Changing host) |
03:51:36 | * | Yardanico joined #nim |
03:52:13 | * | Yardanico quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
03:52:28 | * | Yardanico joined #nim |
03:53:27 | FromDiscord | <Yardanico> restarting the discord-irc bridge because of some stuff |
03:53:33 | * | FromDiscord quit (Remote host closed the connection) |
03:53:46 | * | FromDiscord joined #nim |
03:53:58 | Yardanico | 123 |
03:54:01 | FromDiscord | <Yardanico> done |
04:06:02 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:32 | * | supakeen joined #nim |
04:13:03 | * | vicfred quit (Quit: Leaving) |
04:37:33 | FromDiscord | <huantian> In reply to @Elegantbeef "Patterns and grammars for": looking at the first code snippet reminds me of haskell shivers 😛 |
04:38:40 | FromDiscord | <Rika> Haskell was fun |
04:38:51 | FromDiscord | <Rika> The speed deficits I get from using it is not lol |
04:40:57 | FromDiscord | <impbox [ftsf]> your speed or the code's speed? |
04:41:50 | FromDiscord | <impbox [ftsf]> I've never tried haskell, a lot of my old coworkers loved it |
04:48:34 | FromDiscord | <Rika> The code speed |
04:48:42 | FromDiscord | <Rika> I was fine coding in it |
04:49:01 | FromDiscord | <Rika> Speed dies if you don’t do some things specifically |
04:49:15 | FromDiscord | <Rika> Because the optimiser can’t catch some stuff |
04:49:19 | FromDiscord | <impbox [ftsf]> ahh ok |
05:07:37 | * | sagax joined #nim |
06:58:39 | * | ozzz quit (*.net *.split) |
06:58:50 | * | ozzz joined #nim |
07:04:22 | * | averell quit (*.net *.split) |
07:04:38 | * | averell joined #nim |
07:11:27 | * | PMunch joined #nim |
07:18:26 | * | sagax quit (Read error: Connection reset by peer) |
07:34:43 | * | sagax joined #nim |
08:09:47 | * | pro joined #nim |
08:43:41 | * | neurocyte0132889 joined #nim |
08:43:42 | * | neurocyte0132889 quit (Changing host) |
08:43:42 | * | neurocyte0132889 joined #nim |
08:56:07 | * | neurocyte0132889 quit (Read error: Connection reset by peer) |
08:56:47 | * | neurocyte0132889 joined #nim |
08:56:47 | * | neurocyte0132889 quit (Changing host) |
08:56:47 | * | neurocyte0132889 joined #nim |
09:18:19 | * | neurocyte0132889 quit (Quit: The Lounge - https://thelounge.chat) |
10:41:25 | * | u0_a185 joined #nim |
10:50:19 | * | neurocyte0132889 joined #nim |
10:50:19 | * | neurocyte0132889 quit (Changing host) |
10:50:19 | * | neurocyte0132889 joined #nim |
10:52:48 | * | stephane joined #nim |
10:54:09 | * | stephane is now known as Gintru |
10:54:23 | * | Gintru feel lonely |
10:54:30 | Gintru | *feels |
10:56:05 | * | Gintru quit (Client Quit) |
11:09:11 | * | neurocyte0132889 quit (Quit: The Lounge - https://thelounge.chat) |
11:12:02 | * | neurocyte0132889 joined #nim |
11:12:02 | * | neurocyte0132889 quit (Changing host) |
11:12:02 | * | neurocyte0132889 joined #nim |
11:14:45 | * | Gintru joined #nim |
11:15:13 | * | Gintru test |
11:16:28 | FromDiscord | <Rika> We didn’t receive your test message can you send it again |
11:19:31 | Gintru | a |
11:19:50 | Gintru | Rika / No. nn, sorry it is a test for me |
11:20:17 | Gintru | Rika / I evaluate an IRC client |
11:21:42 | Gintru | I should go elswhere, I didn't figure out it could be such a mess (server, user list…) I leave |
11:21:59 | Gintru | ByE / OuT O o . |
11:22:03 | * | Gintru quit (Quit: That's it for today) |
11:23:39 | FromDiscord | <Rika> I was making a joke |
11:32:34 | * | stephane joined #nim |
11:46:13 | * | u0_a185 quit (Read error: Connection reset by peer) |
11:46:29 | * | u0_a185 joined #nim |
11:53:03 | * | stephane quit (Quit: stephane) |
12:05:41 | * | Gintru joined #nim |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.3) |
12:06:32 | * | supakeen joined #nim |
12:07:00 | * | Gintru /knock |
12:08:55 | * | Gintru thinking pidgin power but absconsness |
12:09:25 | Gintru | systemdsucks: o really ? |
12:09:44 | PMunch | Am I missing a lot of chat here? |
12:09:58 | Gintru | PMunch: I don't think so |
12:10:04 | PMunch | Ah right :P |
12:10:13 | PMunch | I thought you replied to systemdsucks |
12:10:19 | Gintru | PMunch: maybe at 4pm it is more talkative |
12:10:31 | PMunch | It's usually quite a bit more active than this |
12:10:43 | PMunch | I guess Monday is taking it's toll on people :P |
12:11:05 | PMunch | This community is fairly heavily Europe-based, so a lot of people are also at work/school |
12:11:40 | Gintru | PMunch: I didn't think about that |
12:12:30 | FromDiscord | <dom96> I'm off work today o/ |
12:12:42 | PMunch | Hooray! |
12:12:47 | PMunch | Well, unless you're sick.. |
12:12:58 | Gintru | dom96: /smile/ |
12:13:11 | Gintru | dom96: congrat |
12:13:30 | * | Gintru left #nim (#nim) |
12:13:54 | * | Gintru joined #nim |
12:14:09 | * | Gintru reconnected |
12:15:34 | FromDiscord | <dom96> Nah, not sick, just decided to take this Monday off to rest |
12:17:51 | Gintru | ByE / OuT O o . |
12:17:58 | * | Gintru quit (Quit: Leaving.) |
12:41:46 | FromDiscord | <evoalg> @dom96 as new nim versions keep rolling out, do you think your book will need updating at some stage? I have nothing specific in mind, I'm just curious as to your thoughts about it? |
12:42:28 | FromDiscord | <dom96> sure, could always use an update. Question is when will be the right time. Probably after 2.0 tbh |
12:42:44 | FromDiscord | <evoalg> that makes sense, yep |
12:42:47 | FromDiscord | <dom96> (also who knows if Manning is even interested in a 2nd edition) |
12:42:53 | FromDiscord | <dom96> so no guarantees |
12:42:57 | FromDiscord | <evoalg> true |
12:43:10 | FromDiscord | <evoalg> I don't know much about that side of things |
12:43:16 | FromDiscord | <dom96> that said, it repayed the book advance so afaik that's considered a success in the book world 🙂 |
12:43:40 | FromDiscord | <evoalg> Nice! |
12:44:20 | FromDiscord | <dom96> (edit) "repayed" => "repaid" |
12:45:13 | PMunch | That is indeed a good sign |
12:45:22 | FromDiscord | <Rika> congrats |
12:49:17 | * | neurocyte0132889 quit (Quit: The Lounge - https://thelounge.chat) |
12:50:04 | * | neurocyte0132889 joined #nim |
12:50:04 | * | neurocyte0132889 quit (Changing host) |
12:50:04 | * | neurocyte0132889 joined #nim |
12:51:25 | FromDiscord | <dom96> thanks 🙂 |
12:52:34 | FromDiscord | <dom96> Speaking of which, Manning books are on sale now in case you want to take advantage of the deal (not just for my book): https://www.manning.com/?utm_source=niminaction&utm_medium=affiliate&utm_campaign=ebook&pbook_sale_11_15_21&a_aid=niminaction&a_bid=417b1389 |
12:58:33 | NimEventer | New thread by Dom96: Evolving the moderation of the Nim communities, see https://forum.nim-lang.org/t/8629 |
13:02:07 | * | kayabaNerve_ joined #nim |
13:03:19 | FromDiscord | <evoalg> @dom96 cheers - I bought your book just now |
13:03:39 | FromDiscord | <dom96> Ooh, amazing, thank you! |
13:05:11 | * | kayabaNerve quit (Ping timeout: 264 seconds) |
13:42:13 | NimEventer | New post on r/nim by SamLovesNotion: How to compile to modern JS?, see https://reddit.com/r/nim/comments/qugoik/how_to_compile_to_modern_js/ |
13:46:52 | * | pro quit (Read error: Connection reset by peer) |
14:30:04 | * | arkurious joined #nim |
14:38:46 | NimEventer | New thread by Miran: Zen of Nim, see https://forum.nim-lang.org/t/8630 |
14:44:49 | * | xet7 quit (Remote host closed the connection) |
14:45:33 | * | xet7 joined #nim |
15:08:52 | FromDiscord | <pietroppeter> I might have posted about Zen of Nim on the orange site, but you are not hearing it from me 😉 |
15:10:29 | PMunch | Wink wink nudge nudge ay, say no more, say no more |
15:11:31 | PMunch | Oh hey everyone, look at this cool article I found about Nim: https://news.ycombinator.com/item?id=29228230 |
15:11:53 | FromDiscord | <pietroppeter> oh noooo! 😛 |
15:12:07 | PMunch | Wait, does that trigger the ban as well? |
15:13:11 | FromDiscord | <pietroppeter> I think so. As far as I know, the suggestion would be not to upvote after reaching from that link, do an organic search in HN |
15:25:56 | PMunch | Ah, damn it.. |
15:27:15 | FromDiscord | <pietroppeter> no worries, I have very low expectations on HN success anyway. let's see how it goes... 🙂 |
15:30:39 | FromDiscord | <Rika> hn would probably just bash it again |
15:30:48 | FromDiscord | <Rika> repetitive argument #128946? |
15:45:07 | FromDiscord | <Zoom> It's only natural for the critics to be vocal. If you like something, telling about that each time there's a chance can be a bit off-putting. Answering to a constructive critique in a civilized and honest manner is paramount, though.↵(@Rika) |
15:47:16 | FromDiscord | <ajusa> In reply to @Zoom "It's only natural for": iirc every time Nim comes up on HN folks bash two things:↵1. whitespace sensitive↵2. case/underscore/style insensitivity |
15:47:50 | FromDiscord | <ajusa> and those are core to the language, so it's pretty difficult to answer to that criticism. All folks can provide are anecdotes of how those make the language better |
15:51:41 | FromDiscord | <Zoom> You can't really do anything with it besides repeating your points over and over again as it's really the core distinction of the language. It's the same with Rust always getting bashed for being "hard" by people who never saw a proper type in their lives. |
15:52:03 | FromDiscord | <Rika> the core issue for 2. is that they think too much choice would be bad because "the junior is gonna fuck up the uniformity of the codebase" which isnt an issue of the design but an issue of tooling |
15:52:32 | FromDiscord | <Rika> isnt rust properly difficult not for the typing but for the lifetimes? |
15:53:06 | FromDiscord | <ajusa> Yeah man Rust is the least productive language I've ever used just because of how much it yells at me for borrow/lifetimes |
15:53:19 | FromDiscord | <ajusa> (edit) "Yeah man" => "Yeah," |
15:54:01 | FromDiscord | <Zoom> Lifetimes are kind of a natural extension to the type system.↵Dunno, I like it very much and I liked being shouted at by a compiler. Though, my experience is limited of course.↵(@Rika) |
15:54:06 | FromDiscord | <Rika> imo: choice is always better than no choice because you can always restrict choice but you cant unrestrict no choice |
15:54:30 | FromDiscord | <Rika> i like being shouted at for fucking up a type (literally unsafe) |
15:54:47 | FromDiscord | <Rika> i dont like it when its lifetimes (just fucking copy or whatever, and warn instead) |
15:55:00 | FromDiscord | <Zoom> I tend to think the same way, but you can't really argue that maintaining order and following standards in the presence of multitude of choices requires resources.↵(@Rika) |
15:55:13 | FromDiscord | <Rika> that is true |
15:55:30 | FromDiscord | <Rika> its not something to argue about because there is nothing dubious |
15:56:46 | FromDiscord | <Zoom> I mean this (economy or resources) is obviously a priority in the industry, over both the user experience and dev experience. |
16:33:15 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3F4R |
16:33:20 | * | neurocyte0132889 quit (Ping timeout: 265 seconds) |
16:33:25 | * | Onionhammer quit (Quit: The Lounge - https://thelounge.chat) |
16:33:44 | * | Onionhammer joined #nim |
17:37:41 | NimEventer | New thread by Exelotl: Forbidden-by-default effects?, see https://forum.nim-lang.org/t/8631 |
17:38:55 | * | neurocyte0132889 joined #nim |
17:38:55 | * | neurocyte0132889 quit (Changing host) |
17:38:55 | * | neurocyte0132889 joined #nim |
17:43:22 | * | neurocyte0132889 quit (Read error: Connection reset by peer) |
17:43:59 | * | neurocyte0132889 joined #nim |
17:43:59 | * | neurocyte0132889 quit (Changing host) |
17:43:59 | * | neurocyte0132889 joined #nim |
18:10:27 | * | u0_a185 quit (Quit: WeeChat 3.0.1) |
18:14:19 | * | PMunch quit (Quit: leaving) |
18:39:51 | NimEventer | New thread by Mantielero: Question about memory management with bindings, see https://forum.nim-lang.org/t/8632 |
18:43:34 | FromDiscord | <hmmm> yo nimbros, is moveFile("dest") the official way to move a file to a subdir? (if it seems like a stupid question it's because it probably is) |
18:55:09 | * | krux02_ joined #nim |
19:08:09 | FromDiscord | <IsaacPaul> It's part of the standard library so I would say yes.. However, be sure to handle OSError because its not uncommon for it to raised |
19:10:11 | FromDiscord | <IsaacPaul> dest can be anything including a subdir |
19:10:26 | FromDiscord | <hmmm> hmm I'd like to get an OSError, the current situation is that the program happily compiles and then the file gets moved to the void I guess because I'm pretty sure it's not going to "dest" lol 🤔 |
19:11:17 | FromDiscord | <IsaacPaul> does dest include the file name? |
19:12:23 | FromDiscord | <hmmm> nope it's like moveFile("thingy.json", "/subdir") |
19:13:16 | FromDiscord | <hmmm> I tried checking the current working directory but it seems correct, so I have no idea where my good old friend thingy.json goes to |
19:13:20 | FromDiscord | <IsaacPaul> yea you need full paths |
19:13:27 | FromDiscord | <hmmm> oh noes |
19:13:29 | FromDiscord | <hmmm> I hate them |
19:13:48 | FromDiscord | <hmmm> why do I need them |
19:14:08 | FromDiscord | <IsaacPaul> there is no context as where the file is |
19:14:33 | FromDiscord | <hmmm> I mean there is! We are working in the current working directory so the programs knows where subdir is |
19:14:38 | FromDiscord | <Rika> cwd isnt used "automatically" in nim afaik |
19:15:32 | FromDiscord | <hmmm> I'm lazy it should work without full paths |
19:15:49 | FromDiscord | <hmmm> I bet python works with relative paths 🧐 |
19:15:56 | FromDiscord | <IsaacPaul> you can always write the way you like it |
19:15:59 | FromDiscord | <IsaacPaul> lol |
19:31:08 | FromDiscord | <hmmm> hmmm |
19:43:28 | FromDiscord | <hmmm> it worked with this monstrosity: moveFile("thingy.json", getCurrentDir() & "\\subdir\\thingy.json") |
19:44:33 | FromDiscord | <Yardanico> you can use / from os btw |
19:44:41 | FromDiscord | <hmmm> oh? |
19:44:50 | FromDiscord | <hmmm> what is /from os |
19:45:04 | FromDiscord | <Yardanico> it will concat components of the path with the OS's dir separator |
19:45:21 | FromDiscord | <Yardanico> getCurrentDir() / "subdir" / "thingy.json" |
19:45:47 | FromDiscord | <hmmm> oh |
19:45:50 | FromDiscord | <hmmm> I'll try |
19:46:03 | FromDiscord | <Yardanico> In reply to @hmmm "what is /from os": It's literally `/` from the `os` module, not `/from` :) |
19:47:08 | FromDiscord | <hmmm> it worked |
19:48:35 | FromDiscord | <hmmm> it's still pretty ugly, is there a reason our std/os doesn't do the heavy lifting and leave us with a pretty synthax? |
19:52:33 | tk | are sequences lazy? |
19:53:05 | tk | when you do things like toSeq(1..10).map(x => x * w).filter(x => x mod 6 != 0) |
19:56:52 | tk | like if I do toSeq(file.lines).map(x => parseInt(x)).foldl(a + b) will it read the entire file in first? |
19:57:43 | tk | (well, except parseInt doesn't work like that but you get the picture) |
19:58:57 | FromDiscord | <IsaacPaul> In reply to @hmmm "it worked with this": oh I guess it does use cwd lol |
19:59:13 | FromDiscord | <hmmm> really? |
19:59:30 | FromDiscord | <IsaacPaul> your first parameter is "thingy.json" without specifying the cwd |
19:59:44 | FromDiscord | <hmmm> YEA |
20:00:11 | FromDiscord | <hmmm> the reason you are called isaac is because you are genius like newton :nim1: |
20:00:28 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3F5v |
20:00:29 | FromDiscord | <hmmm> I'll try |
20:00:36 | FromDiscord | <IsaacPaul> (edit) "https://play.nim-lang.org/#ix=3F5v" => "https://play.nim-lang.org/#ix=3F5w" |
20:00:47 | FromDiscord | <IsaacPaul> (edit) "https://play.nim-lang.org/#ix=3F5w" => "https://play.nim-lang.org/#ix=3F5x" |
20:02:24 | FromDiscord | <hmmm> oi it worked |
20:02:28 | FromDiscord | <IsaacPaul> oh cool |
20:02:28 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3F5y |
20:03:04 | FromDiscord | <hmmm> damn now I should rewind and go back to what I was doing wrong to why it didn't work before |
20:03:20 | FromDiscord | <IsaacPaul> You used / in the beginning of the dest name |
20:03:21 | FromDiscord | <hmmm> I'm happy our trusty std/os knows about rel paths 🥳 |
20:03:30 | FromDiscord | <IsaacPaul> which means you're starting from the root of the filesystem |
20:03:39 | FromDiscord | <hmmm> oh ok |
20:04:42 | FromDiscord | <hmmm> isaac saved the day, that's why he was crowned king of england :nim1: |
20:09:03 | FromDiscord | <Schelz> Hi, I try to compile a file as 32bit dll but I get error at compiling (only when try to compile with --cpu:i386), what do I do wrong ? |
20:09:42 | FromDiscord | <IsaacPaul> show us the parameters used to compile and the error |
20:09:46 | FromDiscord | <Yardanico> In reply to @Schelz "Hi, I try to": can you show the full error as shown by the compiler? |
20:09:52 | FromDiscord | <Yardanico> and what's your OS/C compiler? |
20:10:10 | FromDiscord | <Schelz> I use this to compile https://media.discordapp.net/attachments/371759389889003532/909898092785074266/unknown.png |
20:10:18 | FromDiscord | <Yardanico> yes, I mean the full error |
20:10:28 | FromDiscord | <Schelz> https://media.discordapp.net/attachments/371759389889003532/909898164570583070/unknown.png |
20:10:43 | FromDiscord | <Yardanico> oh, this means that your C compiler is in "64-bit" mode but you're feeding it 32-bit code |
20:10:46 | FromDiscord | <Yardanico> what's your C compiler? |
20:10:56 | FromDiscord | <Yardanico> also update to nim 1.6 :) |
20:11:17 | FromDiscord | <Yardanico> if it's mingw, you can fix that error (usually) by passing `--passC:-m32 --passL:-m32` in addition to the flags you've already passed |
20:12:00 | FromDiscord | <Schelz> In reply to @Yardanico "what's your C compiler?": mingw yes |
20:12:08 | FromDiscord | <IsaacPaul> In reply to @tk "when you do things": If takes an iterator as an input and outputs an iterator then you can assume its lazy |
20:12:17 | FromDiscord | <IsaacPaul> pretty safely assume its lazy |
20:12:38 | FromDiscord | <Schelz> And if I add --passC:-m32 --passL:-m3 I still need to add --cpu:i386 ? |
20:12:39 | tk | and what about functions taking iterators, does the lazyness persist there? |
20:12:41 | FromDiscord | <Yardanico> yes |
20:12:43 | FromDiscord | <Yardanico> @Schelz |
20:13:16 | FromDiscord | <Yardanico> @Schelz basically --cpu:i386 tells Nim to compile Nim code to C in 32-bit mode, so `int`, `uint` and some other types are 32bit |
20:13:25 | tk | or rather, is it possible to make it work through a function somehow |
20:13:28 | FromDiscord | <Yardanico> and -m32 is needed for mignw to understand that you want to make a 32-bit binary, not a 64-bit one |
20:13:32 | FromDiscord | <Schelz> now I get this https://media.discordapp.net/attachments/371759389889003532/909898934661570630/unknown.png |
20:13:33 | FromDiscord | <Yardanico> because it supports both 32-bit and 64-bit usually |
20:13:33 | tk | or only with templates? |
20:14:27 | FromDiscord | <Yardanico> In reply to @Schelz "now I get this": try removing the passL argument |
20:14:36 | FromDiscord | <Yardanico> not sure if the mingw bundled with nim has 32-bit support, but it should |
20:14:37 | FromDiscord | <IsaacPaul> yea template vs proc makes no difference in this case. |
20:14:59 | FromDiscord | <Schelz> https://media.discordapp.net/attachments/371759389889003532/909899301126303764/unknown.png |
20:15:14 | FromDiscord | <Schelz> without --passL |
20:15:59 | FromDiscord | <Solitude> In reply to @tk "like if I do": it will read entire file. thats what toSeq does. eagerly collects result of an iterator. |
20:16:47 | FromDiscord | <Yardanico> In reply to @tk "like if I do": you might be interested in https://github.com/zero-functional/zero-functional if you want to use functional style chaining for seqs and stuff with more performance than sequtils :) |
20:17:00 | tk | FromDiscord: is there any way to make that thing work without first reading the entire file into ram? |
20:17:33 | FromDiscord | <IsaacPaul> In reply to @Solitude "it will read entire": Oh whoops, I looked at the docs and thought I saw a iterator return value 😂 I need my coffee. I'mma stop answering questions today |
20:17:33 | FromDiscord | <Solitude> yes, write a for-loop |
20:17:39 | FromDiscord | <Yardanico> @tk btw, FromDiscord is a bridge bot , you should reply like "@Nickname" where nickname is what's in the brackets |
20:17:54 | Yardanico | ^ so here FromDiscord is a bot and @Yardanico is my discord account |
20:18:00 | Yardanico | if you ping with @ users on discord will see your ping |
20:18:10 | tk | That would be very difficult since that's not what IRC uses and I have a lot of muscle memory built up. |
20:18:41 | Yardanico | well, it has to work that way because to ping on discord you must "resolve" the username into an actual user :) |
20:18:53 | Yardanico | no problems though, but keep it in mind if you want to ping someone who might not be online |
20:20:29 | FromDiscord | <Yardanico> In reply to @tk "FromDiscord: is there any": there's also https://nim-lang.org/docs/sugar.html#collect.m%2Cuntyped%2Cuntyped although it allows you to write in an imperative style with loops, not in a functional one |
20:20:49 | FromDiscord | <Yardanico> ah, it won't really work for stuff like foldl though |
20:21:39 | tk | So the zero-functional thing looks neat, does it follow semver? |
20:21:51 | FromDiscord | <Yardanico> don't know about that one, sorry |
20:21:55 | FromDiscord | <IsaacPaul> In reply to @Yardanico "you might be interested": 😮 I didn't realize seqUtils was so inefficient |
20:22:09 | FromDiscord | <Yardanico> In reply to @IsaacPaul "😮 I didn't realize": well that's quite obvious because it's implemented as simple templates |
20:22:19 | FromDiscord | <Yardanico> so if you chain multiple of them you'll have multiple temporary sequences |
20:23:19 | FromDiscord | <Yardanico> anyone posted zen of nim to HN yet? |
20:23:35 | FromDiscord | <IsaacPaul> Yea it's been there for a little bit |
20:23:42 | FromDiscord | <Yardanico> ah right found it |
20:23:57 | FromDiscord | <IsaacPaul> In reply to @PMunch "Oh hey everyone, look": ^ |
20:24:07 | FromDiscord | <Yardanico> yeah, it won't get into top though |
20:24:16 | FromDiscord | <Yardanico> also upvotes from direct links are not counted by HN :) |
20:24:31 | FromDiscord | <Yardanico> so that's why you usually search the post yourself on the website and upvote |
20:28:08 | FromDiscord | <Rika> In reply to @tk "are sequences lazy?": no |
20:28:16 | FromDiscord | <Rika> In reply to @tk "like if I do": yes |
20:28:55 | FromDiscord | <Rika> In reply to @IsaacPaul "If takes an iterator": toSeq reads the whole iterator |
20:30:18 | FromDiscord | <Rika> In reply to @tk "So the zero-functional thing": you can semi-safely assume libraries conform to semver |
20:30:27 | FromDiscord | <Rika> but that's kinda a whole can o worms so |
20:36:06 | FromDiscord | <IsaacPaul> In reply to @Rika "toSeq reads the whole": I assumed map, fold, ect all took and outputted an iterator xD |
20:36:23 | FromDiscord | <IsaacPaul> which honestly makes the most sense to me |
20:37:48 | tk | I wonder what it would take to create a non-template-based lazy "pipe" library or something |
20:38:09 | FromDiscord | <IsaacPaul> https://github.com/def-/nim-iterutils like this? |
20:39:05 | tk | I guess |
20:39:09 | tk | I think this looks about right |
20:39:35 | FromDiscord | <Rika> In reply to @IsaacPaul "I assumed map, fold,": it could make sense yes |
20:39:56 | FromDiscord | <Rika> In reply to @tk "I wonder what it": you can make your own by returning closure iterators |
20:40:09 | FromDiscord | <Rika> theyre p.much ad hoc laziness |
20:40:26 | FromDiscord | <Rika> like, thunks are basically single-yield closure iterators |
20:41:05 | tk | thunks? |
20:41:13 | FromDiscord | <Rika> uh |
20:41:15 | FromDiscord | <Rika> lazy values |
20:41:25 | tk | I didn't realise you could return iterators, or that they could be closures |
20:41:26 | FromDiscord | <Rika> theyre called thunks from what i know |
20:41:38 | FromDiscord | <Rika> https://en.wikipedia.org/wiki/Thunk |
20:42:20 | tk | ah, I've written code like this a million times but never knew what it was called |
20:42:26 | FromDiscord | <Rika> you can return closure iterators only, inline iterators are, well, inlined |
20:42:32 | tk | Also, I've heard of thunks before but never associated them to this |
20:42:50 | tk | interesting |
20:42:57 | FromDiscord | <Rika> thunks can also be first class functions, but those are less fun |
20:43:21 | FromDiscord | <Rika> if you need lazy single-values, first class functions. if you need lazy containers, closure iterators |
20:43:47 | FromDiscord | <Yardanico> apparently with https://zen.su/posts/amalgamating-nim-programs/ compiling with `--gc:arc -d:useMalloc --os:any -d:posix -d:noSignalHandler --panics:on -d:danger` the total C code size is under 1K lines, and most of that is just copypaste from normal C stdlib headers |
20:43:56 | FromDiscord | <Yardanico> need to update the article a bit though |
20:50:09 | FromDiscord | <Yardanico> https://gist.github.com/Yardanico/bd66fe0599a0db0a43965467cfebd75f |
20:50:27 | FromDiscord | <Yardanico> that's the resulting C code from all those flags for `echo "Hello, world!"` :) |
20:51:00 | * | beshr quit (Remote host closed the connection) |
20:58:55 | FromDiscord | <Yardanico> after removing cruft that's already in the C lib it's 450 loc :)) |
21:04:36 | * | Lord_Nightmare quit (Quit: ZNC - http://znc.in) |
21:18:26 | nisstyre | does anyone here use https://github.com/elcritch/nesper ? I tried it yesterday and got GCC errors when I tried to build the example :( |
21:18:35 | nisstyre | esp-idf worked fine though |
21:18:58 | nisstyre | might file an issue but I'm not sure if it's maintained actively anymore |
21:19:11 | nisstyre | or maybe I need a different compiler |
21:19:21 | tk | okay, I have one more question, I don't understand what is happening here: http://ix.io/3F5W - this code when executed with foo containing the lines 1, 2, and 3 will print 6 and then 0 |
21:20:14 | tk | since I am "calling" the iterator every time in sum I would have expected it to re-open the file |
21:20:29 | tk | now coincidentally, this is actualy the behaviour I wanted, but not the one I expected |
21:22:31 | tk | Like I would have expected that putting f in the scope of numfile_iterator instead of it would have achieved this result |
21:22:33 | FromDiscord | <Yardanico> In reply to @tk "since I am "calling"": it's a closure iterator, so it remembers its state which means it'll only open the file once |
21:23:02 | tk | but then if you have a to-level closure iterator will it also remember its state? |
21:23:06 | tk | let me check |
21:23:15 | FromDiscord | <Yardanico> if it's a closure iterator - yes, of course |
21:23:29 | FromDiscord | <Yardanico> if it's a normal iterator - no, because normal iterators are always inlined |
21:24:57 | FromDiscord | <Elegantbeef> Is this where i shill my `asClosure` macro? 😛 |
21:25:16 | FromDiscord | <Yardanico> write a `asGoodCode` macro please |
21:26:27 | FromDiscord | <Elegantbeef> The only way to write good code is to not write code at all |
21:26:28 | tk | https://play.nim-lang.org/ - okay, so in this case it doesn't do the same thing |
21:26:30 | tk | er |
21:26:35 | tk | let me actually paste a link to something |
21:26:35 | FromDiscord | <Elegantbeef> So the `asGoodCode` would just `quit(1)` |
21:26:45 | tk | https://play.nim-lang.org/#ix=3F5Z - there |
21:26:46 | FromDiscord | <Yardanico> In reply to @Elegantbeef "So the `asGoodCode` would": but 1 is a bad exit code! |
21:27:02 | FromDiscord | <Yardanico> @tk in this case you're not using the same closure iterator |
21:27:03 | FromDiscord | <Elegantbeef> Exactly |
21:27:21 | FromDiscord | <Yardanico> in your previous example it was one closure iterator because you instantiated it with ` let it = numfile_iterator("foo")` |
21:27:27 | tk | Yardanico: how so? |
21:27:34 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3F60 |
21:27:42 | FromDiscord | <Elegantbeef> `it` instantiates a new iterator |
21:27:47 | nisstyre | tk: in your example I would expect it to exhaust the iterator the first time |
21:27:58 | FromDiscord | <Elegantbeef> It's not global it's stored with that instantiation of the iterator |
21:28:21 | FromDiscord | <Yardanico> @nisstyre no, it passes a fresh instantiated iterator each time to sum_it so it'll output 6 each time |
21:28:22 | tk | that is unusual, where is this behaviour that mentioning a closure iterator "instantiates" it documented? |
21:28:37 | tk | and coincidentally, why doesn't "mentioning" the variable also do the same thing? |
21:28:51 | nisstyre | Yardanico: yeah it's probably a bias coming from python land |
21:28:53 | FromDiscord | <Yardanico> because you're not "mentioning" the variable |
21:28:58 | FromDiscord | <Yardanico> you're mentioning the iterator itself |
21:29:00 | nisstyre | I think the Nim way is better |
21:29:35 | tk | okay so what is the type of an iterator before it is assigned to an "iterator" typed variable (or returned as an "iterator" typed result?) |
21:29:44 | tk | does it have some special different type? |
21:30:02 | FromDiscord | <Yardanico> no, it's the same, but you're instantiating a new iterator each time you reference it |
21:30:22 | FromDiscord | <Elegantbeef> "Mentioning" the variable behaves differently since the state is attached to `a` |
21:30:28 | tk | right but as I said, in that case I don't get why referencing the reference doesn't do the same thing |
21:30:41 | FromDiscord | <Elegantbeef> `var a = it` instantiates the environment(state) and a pointer to iterator |
21:30:43 | FromDiscord | <Yardanico> because you're saving the state in a variable then |
21:30:50 | tk | right, so the type IS different |
21:30:58 | FromDiscord | <Yardanico> no? |
21:31:00 | FromDiscord | <Elegantbeef> No the type is the same |
21:31:03 | FromDiscord | <Elegantbeef> The value is different |
21:31:10 | tk | how can something of the same type behave differently in two identical contexts? |
21:31:14 | FromDiscord | <Yardanico> ??? |
21:31:34 | FromDiscord | <Elegantbeef> Cause you're making an Lvalue inside `sumIt` vs passing an LValue in |
21:31:55 | nisstyre | I think maybe the confusion is over closures, not iterators... |
21:32:06 | nisstyre | f is part of the closure state |
21:32:07 | FromDiscord | <Elegantbeef> when you do `sumIt(it)` i instantiates a new environment and makes an lvalue to pass to the procedure, so after the call is done there is no leaked state |
21:32:18 | FromDiscord | <Elegantbeef> You seem to want a globalized state for every closure iterator |
21:32:28 | tk | I don't _want_ anything |
21:32:33 | tk | I am simply trying to understand the behaviour |
21:32:42 | FromDiscord | <Yardanico> well, we already explained it I think |
21:33:41 | FromDiscord | <Elegantbeef> Closures need to store the state(where they are and data they're capturing), and the pointer to the procedure, as such when you do `it` that information is instantiated, when not assigned to a variable it's only used temporarily, when assigned to a variable it's persistent with that variable |
21:34:14 | FromDiscord | <Yardanico> also, take a look at this @tk https://play.nim-lang.org/#ix=3F64 |
21:34:32 | FromDiscord | <Yardanico> should it behave the same in both cases? |
21:34:34 | nisstyre | Elegantbeef: traditionally it's all the free variables that go into the closure environment |
21:34:47 | nisstyre | but it's not clear here IMO |
21:34:59 | nisstyre | it's slightly different from the traditional closure in e.g. lisp |
21:35:13 | tk | the type of a is _different_ from the type of getVal |
21:35:17 | FromDiscord | <Elegantbeef> Yea think my `asClosure` makes it a bit less silly 😀 |
21:35:30 | FromDiscord | <Yardanico> In reply to @tk "the type of a": no |
21:35:30 | FromDiscord | <Elegantbeef> No they're not, they're both Data |
21:35:43 | tk | How is an un-called function "Data"? |
21:35:46 | tk | it's a func |
21:35:49 | FromDiscord | <Yardanico> it is a called function though |
21:36:07 | FromDiscord | <Elegantbeef> https://github.com/beef331/slicerator/blob/master/tests/test1.nim#L57-L84 doesnt have any confusion of "what's caputed" 😛 |
21:36:09 | FromDiscord | <Yardanico> and with closure iterators you instantiate it by mentioning it without a call |
21:36:23 | tk | right, so what's the type of the thing you mention? |
21:36:29 | FromDiscord | <Yardanico> In reply to @tk "right, so what's the": which one? |
21:36:30 | nisstyre | what is asClosure supposed to do? |
21:36:45 | FromDiscord | <Elegantbeef> As closure takes an inline iterator and converts it to a closure |
21:36:47 | tk | if you mention "it" in a vacuum, without "instantiating it" what is its type? |
21:36:54 | nisstyre | ah interesting |
21:36:59 | FromDiscord | <Yardanico> In reply to @tk "if you mention "it"": the type of the iterator itself |
21:37:04 | FromDiscord | <Yardanico> nim has `typeof` |
21:37:04 | FromDiscord | <Elegantbeef> `iterator() {.closure.}` |
21:37:09 | FromDiscord | <Yardanico> just do `echo typeof(myVar)` |
21:37:16 | tk | right, but if I do typeof(it) it will just instantiate it before passing it to typeof no? |
21:37:29 | FromDiscord | <Elegantbeef> No typeof is compiile time only |
21:37:45 | FromDiscord | <Elegantbeef> It types the expression, it doesnt do any instantiating |
21:37:50 | tk | okay, so in this case I get the same type |
21:38:11 | FromDiscord | <Elegantbeef> It looks at the expression and goes "hey this is the symbol of `myVar` which is `iterator() {.closure.}` |
21:38:36 | * | Lord_Nightmare joined #nim |
21:38:46 | tk | so my point is, if they're symbols of the same type, why are they treated differently, what distinguishes them? |
21:39:08 | FromDiscord | <Elegantbeef> One is stored in a variable |
21:39:14 | FromDiscord | <Elegantbeef> So state persists |
21:39:41 | tk | this is unusual, so a thing stored in a variable is distinct from the same thing as-such ? |
21:39:48 | tk | as in, it's treated differently? |
21:40:08 | nisstyre | I'm guessing (but would be curious to know exactly how) that the compiler does some sort of "lambda lifting" type thing where it gets a set of all the variables in the closure function body |
21:40:13 | FromDiscord | <Elegantbeef> The only odd thing here is that `it` instantiates a value at runtime |
21:40:13 | nisstyre | and then adds them to a struct or something |
21:40:42 | FromDiscord | <Elegantbeef> You're right nisstyre |
21:40:43 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/intern.html#code-generation-for-closures |
21:40:46 | tk | okay, so then I guess my next question is, is it possible to avoid instantiating `it` ? |
21:40:52 | FromDiscord | <Elegantbeef> This is more of "how stuff works" at a lower level, but might help tk |
21:40:53 | tk | and pass `it` as-such? |
21:40:57 | nisstyre | thanks for the link |
21:41:21 | tk | let's say I wanted to create a function which returns an un-instantiated closure iterator |
21:41:28 | tk | which I can then instantiate as many times as I want |
21:41:44 | FromDiscord | <Elegantbeef> Isnt that what you already have |
21:41:54 | tk | well no, not with numfile_iterator |
21:42:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/hck |
21:42:39 | tk | I don't understand |
21:43:34 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3F68 doesnt this just work? |
21:43:34 | tk | also, if this is the case, why do iterators require () in for loops? or can I do it without the () ? |
21:43:47 | tk | That's not he code I wanted to make work :p |
21:43:53 | tk | I sent it earlier, let me re-send it |
21:43:58 | tk | http://ix.io/3F5W |
21:44:00 | FromDiscord | <Elegantbeef> But doesnt the same logic apply? |
21:44:03 | tk | no |
21:44:18 | tk | unles... you are suggesting I take it OUT of the function |
21:44:23 | tk | I guess that makes sense |
21:45:26 | tk | hmm... no, that doesn't work |
21:45:33 | tk | I can't pass it arguments then |
21:47:55 | FromDiscord | <Elegantbeef> perhaps https://play.nim-lang.org/#ix=3F69 |
21:48:08 | FromDiscord | <Elegantbeef> instead of passing in `it` in the calls down there you could pass `numFile` |
21:48:19 | tk | I would say that this is not elegant |
21:48:23 | FromDiscord | <Elegantbeef> The thing to note is closures without that factory require manually passing state every time |
21:48:34 | tk | I don't want the function which receives the iterator to have to care about knowing what to call the iterator with |
21:48:39 | FromDiscord | <Elegantbeef> You're right, that's why i'd suggest using `asClosure` |
21:48:49 | FromDiscord | <Elegantbeef> Write an inline iterator, then do `asClosure(yourInlineIterator)` |
21:49:09 | tk | let's see |
21:49:27 | tk | where is asClosure documented? |
21:49:45 | FromDiscord | <Yardanico> it's made by Elegantbeef :) |
21:49:49 | FromDiscord | <Elegantbeef> It's apart of my slicerator package, not in stdlib |
21:49:52 | tk | oh |
21:50:37 | tk | and... where would I find that? |
21:50:46 | FromDiscord | <Yardanico> beef linked it above - https://github.com/beef331/slicerator |
21:50:49 | tk | ah |
21:50:55 | FromDiscord | <Elegantbeef> https://github.com/beef331/slicerator |
21:51:12 | FromDiscord | <Elegantbeef> It's not properly documented but there are examples in `tests/test1` |
21:51:27 | tk | one moment |
21:52:01 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3F6a but yea it'd look like this |
21:52:24 | tk | can I put parentheses around the string? or at least a space in front of it? |
21:52:26 | FromDiscord | <Elegantbeef> Using it a lot would probably make compile time atrocious since i dont cache iterators yet though i probably should |
21:52:46 | FromDiscord | <Elegantbeef> Of course that's just one method of calling with a string |
21:52:51 | tk | do I have to call asClosure twice if I want to process the same file twice? |
21:53:35 | FromDiscord | <Elegantbeef> Hmm i havent used iterators much, so i dont know if there is a way to reset an iterator |
21:53:54 | nisstyre | why can't you just use a non-closure iterator |
21:54:04 | tk | because I can't pass it to the function |
21:54:10 | nisstyre | convert to seq? |
21:54:14 | FromDiscord | <Elegantbeef> They could use a non closure one if they made their `sum` a template and used `iterable[T]` |
21:54:25 | nisstyre | yeah or that |
21:54:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F6c |
21:55:02 | tk | in any case, the goal was just to avoid having to pass the filename twice |
21:55:05 | FromDiscord | <Elegantbeef> That'd accept both closure and inlines |
21:55:19 | tk | I basically want something which generates an iterator which I can repeatedly iterate over to access the same file |
21:56:16 | tk | or heck, it would be okay if I had a partial... hmm... maybe another layer of functions will solve this problem |
21:56:18 | tk | let me try something |
21:58:16 | FromDiscord | <Elegantbeef> I might be able to make a reset macro/template |
21:58:58 | tk | okay, now I'm even more lost as to why THIS doesn't work... |
21:59:02 | tk | let me make a code snippet |
22:00:18 | tk | http://ix.io/3F6e - what am I misunderstanding here? |
22:00:59 | tk | I would have expected the closure returned by numfile_iterator to return a fresh instance of the iterator every time it's called |
22:01:54 | tk | wow |
22:02:17 | nisstyre | probably it shares the same environment |
22:02:20 | tk | I got an unhandled exception in ccgtypes.nim, let me try in the latest nim |
22:02:23 | nisstyre | or maybe not, idk |
22:03:10 | tk | I should have found this bug on my other computer |
22:03:23 | tk | then I wouldn't have to wait minutes for a build |
22:05:27 | tk | the only problem is that ccgtypes.nim is in the ccg part of nim which I completely failed to follow the last time I tried to debug a nim compiler issue. |
22:05:40 | tk | the only other nim bug I have looked at was in the standard library which was much easier to figure out |
22:05:47 | FromDiscord | <Elegantbeef> Yea cgen is very obtuse |
22:06:01 | FromDiscord | <Elegantbeef> The only stuff i can reasonably follow is sem stuffs |
22:06:49 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3F6i well reset is implemented, no clue if that helps you any |
22:08:45 | tk | I actually found the compiler bug while writing a nim function to convert camelCase into snake_case (in a way which ensures that the identifiers still match) with the intention of installing that function inside nimls so that I got snake_case tab completion. As part of my test suite I was using nim_ident_normalize and found that it was broken for empty inputs. At the end of the day I managed to |
22:08:47 | tk | successfuly hack nimls to return snake case everywhere. |
22:08:58 | tk | (... still compiling ...) |
22:09:27 | FromDiscord | <Yardanico> In reply to @tk "I actually found the": there is a nim function like taht btw |
22:09:32 | FromDiscord | <Yardanico> (edit) "taht" => "that" |
22:09:44 | tk | there's a nim function to do the opposite IIRC |
22:09:53 | tk | not to go from camel to snake case |
22:10:07 | FromDiscord | <Yardanico> ah right didn't see you want snake_case |
22:10:14 | tk | of course |
22:10:17 | tk | it's the superior choice |
22:10:24 | FromDiscord | <Elegantbeef> It's ok yard you dont expect people to program wrong |
22:10:25 | tk | as well as 3 space indent |
22:10:32 | FromDiscord | <Yardanico> yeah yeah :) |
22:10:47 | FromDiscord | <Yardanico> @tk take a look at https://github.com/Yardanico/nuglifier too, it's the superior choice too |
22:10:54 | FromDiscord | <Yardanico> https://forum.nim-lang.org/t/6497 |
22:11:02 | FromDiscord | <Yardanico> https://raw.githubusercontent.com/Yardanico/nuglifier/master/example_output/example_case.nim example output (compiles and runs) |
22:11:11 | tk | seems awful |
22:11:22 | FromDiscord | <Yardanico> almost as bad as 3-space idents /s |
22:11:42 | tk | I personally struggle to read camelCase and find 2 space indent incredibly difficult to follow so nim being agnostic on these issues means I can happily use it. |
22:11:49 | FromDiscord | <Yardanico> yeah that's fine |
22:11:59 | FromDiscord | <Elegantbeef> It's always odd to see people follow star a package i link and have 0 clue who the fuck they are 😀 |
22:12:00 | tk | aha! the compilation has finished! |
22:12:05 | FromDiscord | <Elegantbeef> Lurkers all around me |
22:13:32 | tk | okay, I have a bona-fide compiler bug, now to check if anyone else has reported it and if not, make a minimal reproducer, report it and then try (and probably fail) to fix it |
22:14:22 | FromDiscord | <Elegantbeef> If you get a min repro i can try to help you debug/fix it |
22:14:41 | FromDiscord | <Elegantbeef> I'm not overly competent on the cgen side like i said, tend to stick to semantics |
22:45:41 | FromDiscord | <Zoom> Actually, tk makes a good point. It's not obvious how to make an iterator factory in vanilla Nim. |
22:45:56 | FromDiscord | <Zoom> At least to me it isn't |
22:49:56 | FromDiscord | <evoalg> I was reading that Zen of Nim article and I realized that I tend to program in a very unstructured way, with lots of returns in a proc, and lots of continues & breaks in a loop, and I'm already in love with doing that lol ... it gives me flexibility and power, and also saves on indenting in loops, but yea I guess I'm not letting the compiler reason about my code, and yea I admit I tend to think of returns as a "goto" |
22:50:21 | tk | Elegantbeef: it's fine, I'll try alone for a while, I like doing things like this |
22:57:43 | FromDiscord | <Elegantbeef> Yea this is why i think something like `asClosure` and `rest` need to be more first class |
22:58:14 | FromDiscord | <Elegantbeef> And yea evo Nim gives a ton of functionality to get away from typical silly code you see in other language |
22:58:19 | FromDiscord | <Elegantbeef> reset\ of course |
22:59:06 | FromDiscord | <Elegantbeef> Like you dont need to declare a result variable, you dont need to use return in most procedures between `break` named blocks and result |
23:00:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3F6s |
23:01:37 | FromDiscord | <evoalg> my initial reaction is to save a line by doing `return true` under the if |
23:01:46 | FromDiscord | <Yardanico> lol |
23:02:10 | FromDiscord | <Elegantbeef> That's up to you of course |
23:02:16 | FromDiscord | <evoalg> I know I'm bad |
23:02:27 | FromDiscord | <Elegantbeef> Nah it's preference |
23:02:31 | tk | can someone remind me what I need to invoke koch with to get it to compile and run a program with a freshly compiled nim? |
23:02:46 | FromDiscord | <Elegantbeef> `./koch temp c ./yourprogram.nim` |
23:02:48 | tk | thanks |
23:02:49 | krux02_ | ./koch temp c -r myfile |
23:03:15 | FromDiscord | <Elegantbeef> Krux waits in the shadows to strike! |
23:03:19 | FromDiscord | <Zoom> If my nesting gets out of hand it usually means it's time to separate a subroutine.An early return for a rare condition is fine, but if you rely on this and have many, maybe you should flip your perspective\: Write a function and think about it from the end to the beginning. What conditions should you satisfy on returning a desired result? Then untangle the concept into more specific steps. Hope it makes sense.↵(@evoalg) |
23:03:39 | FromDiscord | <Elegantbeef> Yea early returns I've grown to dislike |
23:03:56 | FromDiscord | <Elegantbeef> Though nim's standard 2 indentation hides nested ifs |
23:04:12 | FromDiscord | <Elegantbeef> "It's not that deep it's only 10 characters in" |
23:07:29 | FromDiscord | <Zoom> sent a code paste, see https://play.nim-lang.org/#ix=3F6y |
23:07:39 | FromDiscord | <Elegantbeef> I hate everything you stand for 😛 |
23:09:05 | FromDiscord | <Yardanico> In reply to @Zoom "Nah. That's the proper": pls stop trolling thanx |
23:09:20 | FromDiscord | <Elegantbeef> You're not my real mom! |
23:10:57 | tk | okay, well, I have no idea |
23:11:34 | FromDiscord | <Zoom> I stand by the opinion we really should be able to write some form of `iterable[T]` instead of an openArray in my example and not have to make `contains` a template. |
23:11:54 | FromDiscord | <Elegantbeef> Well i agree zoom, so who're you arguing with |
23:12:08 | FromDiscord | <evoalg> sent a code paste, see https://play.nim-lang.org/#ix=3F6C |
23:12:22 | FromDiscord | <Elegantbeef> It's also dumb you cannot implictly pass an open array to an `iterable[T]` |
23:12:28 | FromDiscord | <evoalg> with nots of nesting, this can greatly save indentations for me |
23:12:53 | FromDiscord | <Elegantbeef> It's really up to you on that one, i prefer `if not item.isBad` since it shows the logic flow and not the anti-logic flow |
23:13:10 | FromDiscord | <Zoom> With the heavens, it seems. I don't like the fact those issues make me repeat the same things every time I start going to this channel. |
23:13:47 | FromDiscord | <Elegantbeef> It's the same idea, but one explicitly states intent, the other requires reasoning it from the code |
23:14:20 | FromDiscord | <evoalg> ok ... I'm giving nim a good go, because one of the reasons is that it will improve my sloppy coding in general 😉 |
23:14:30 | FromDiscord | <Elegantbeef> I looked at it Zoom and iterable was intentionally made as such, and thanks to implict conversions failing when you do `iterable[int] or openArray[int]` they're ptetty much useless |
23:14:38 | FromDiscord | <Elegantbeef> pretty\ |
23:15:10 | FromDiscord | <Elegantbeef> In my view they have a good goal, but have failed miserably to meet the mark |
23:16:37 | FromDiscord | <Elegantbeef> There is this RFC that remedies them a bit, but still not ideal they need to be in a template https://github.com/nim-lang/RFCs/issues/397 |
23:19:14 | * | sagax quit (Excess Flood) |
23:21:44 | FromDiscord | <Elegantbeef> I'd also argue that `var a = someThing.items` should be implictly converted to a closure |
23:22:16 | FromDiscord | <Elegantbeef> But i guess that's what we have `asClosure` for now 😛 |
23:27:58 | FromDiscord | <evoalg> to use asClosure, I just have to remember to use the `()` with the variable right? Second question, I can't use it to turn toSeq into an iterator right? |
23:28:17 | FromDiscord | <Elegantbeef> Nope `toSeq` isnt an iterator |
23:28:45 | FromDiscord | <Elegantbeef> I mean you can but it doesnt make any sense as it's just `yourCollection.yourIterator` |
23:28:59 | FromDiscord | <Elegantbeef> You shouldnt need the `()` |
23:29:15 | FromDiscord | <Elegantbeef> Sadly `reset` only works if called in the declaration scope |
23:30:26 | FromDiscord | <sealmove> hey can't I use the `nim` command to compile many files at once? |
23:30:58 | FromDiscord | <Elegantbeef> It compiles the source module and all of it's dependancies, i dont think you can do multiple files at once |
23:31:05 | FromDiscord | <Elegantbeef> multiple source modules\ |
23:32:10 | FromDiscord | <sealmove> yeah I see : |
23:32:14 | FromDiscord | <sealmove> (edit) ":" => ":|" |
23:32:24 | FromDiscord | <Yardanico> any reason you want that? |
23:35:38 | FromDiscord | <sealmove> ok I'll try to explain |
23:36:20 | FromDiscord | <sealmove> in my project i generate nim source code programmatically (with Scala) |
23:36:34 | FromDiscord | <sealmove> and I need to test if the generated nim source files can compile |
23:36:48 | FromDiscord | <sealmove> and distinguish which ones do compile and which don't |
23:37:11 | FromDiscord | <sealmove> the other members have written a tool in ruby to do this. it's somewhat language-agnostic |
23:37:18 | FromDiscord | <sealmove> so I am trying to make a subclass for nim |
23:37:21 | FromDiscord | <Yardanico> i mean, why not just call nim separately for each file? the thing is - how would you expect it to behave with multiple files? |
23:37:32 | FromDiscord | <Yardanico> because in most languages passing multiple files to a compiler means compiling them together |
23:38:23 | FromDiscord | <Yardanico> it's a valid usecase, but for me it feels like that feature will add more complexity without any big gain (since you can just call nim multiple times) |
23:38:33 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=3F6D |
23:38:33 | FromDiscord | <Yardanico> nim also has --compileOnly to check if the _nim_ code compiles |
23:38:49 | FromDiscord | <sealmove> yes I wanted to ask about this |
23:39:01 | FromDiscord | <sealmove> what does it mean? |
23:39:05 | FromDiscord | <Yardanico> https://nim-lang.org/docs/nimc.html |
23:39:09 | FromDiscord | <Yardanico> "compile Nim files only; do not assemble or link" |
23:39:21 | FromDiscord | <Yardanico> nim has a lot of useful flags, give that page a read :) |
23:39:25 | FromDiscord | <sealmove> very good, this will be very useful |
23:51:38 | FromDiscord | <sealmove> btw Yardanico fun fact... |
23:51:55 | FromDiscord | <sealmove> the only reason I must do this is because Travis CI now charges based on time used |
23:52:05 | FromDiscord | <sealmove> https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing |
23:52:16 | FromDiscord | <sealmove> you probably know already |
23:52:58 | FromDiscord | <sealmove> currently I am using `testify` which is a crap tool I wrote some years ago https://github.com/sealmove/testify |
23:54:25 | FromDiscord | <sealmove> I don't know if using their ruby tool instead of `testify` will make a difference, but at least I'll follow their convention and remove `testify` as an extra dependency |
23:55:32 | FromDiscord | <sealmove> here is the _does-it-build? tool_ https://github.com/kaitai-io/kaitai_struct_tests/tree/master/builder |