00:00:39 | FromDiscord | <evoalg> I was reading that macro link above ... it seems to me that if Nim supported the syntax and functionality of what a particular macro was trying to do, then there would be no need for that particular macro, and so I'm thinking that writing macro's is like extending the Nim language itself ... is that right or am I bonkers? |
00:03:25 | FromDiscord | <Elegantbeef> Hmm a particular macro |
00:03:49 | FromDiscord | <Elegantbeef> It is indeed a method of extending the Nim language |
00:04:01 | FromDiscord | <Yardanico> In reply to @evoalg "I was reading that": yes, you're right in that |
00:04:11 | FromDiscord | <Yardanico> you can implement what macros do in the compiler and then it'll become a language feature |
00:04:28 | FromDiscord | <evoalg> nice! |
00:04:37 | FromDiscord | <Elegantbeef> Macros are realistically defined as "User defined compilation passes" |
00:05:28 | FromDiscord | <Elegantbeef> I do have an idea how to support unpacking in proc calls and var assignment, but no clue if Nim would accept it |
00:07:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Gdu |
00:09:51 | FromDiscord | <Elegantbeef> When doing tuple assignment it calls those procs and when doing a proc call you'd do something like `doThing(...(10, 20))` |
00:25:18 | FromDiscord | <evoalg> Cheers! It's like creating a super-set language of Nim that supports extra syntax to do cool stuff I want. I can see how it's very powerful (but advanced stuff for me). |
00:31:11 | * | ormiret quit (Ping timeout: 245 seconds) |
00:31:45 | * | ormiret joined #nim |
00:32:11 | * | pch quit (Remote host closed the connection) |
00:33:13 | FromDiscord | <Elegantbeef> Yep in other languages it requires compiler support, like async |
00:33:16 | * | notchris quit (Ping timeout: 245 seconds) |
00:33:31 | FromDiscord | <Elegantbeef> Thanks to macros we can do it all in "userspace" instead of relying on the compiler devs to add it |
00:35:22 | * | notchris joined #nim |
00:41:01 | FromDiscord | <evoalg> yay! ... do away with those dirty devs ... but seriously, I can see that if I was super duper brainy and creative then I could do a loads with all that freedom |
00:41:22 | FromDiscord | <Elegantbeef> Indeed, you can do quite wonderful things |
00:41:56 | FromDiscord | <Elegantbeef> They can remove a lot of boiler plate or similar |
00:44:21 | FromDiscord | <Elegantbeef> Oh and evoalg i did make that repl and it's pretty much 100% useless and a toy |
00:45:14 | FromDiscord | <evoalg> oh nice! ... the macro one right? ... will it help you to debug macro's while you're building them? |
00:45:39 | FromDiscord | <Elegantbeef> drop-2021-11-24\_15.34.24.mp4 https://media.discordapp.net/attachments/371759389889003532/913953681198678026/drop-2021-11-24_15.34.24.mp4 |
00:45:41 | FromDiscord | <Elegantbeef> It's supposed to but it's less than useful i wager |
00:45:57 | FromDiscord | <Elegantbeef> There is a video of it in use |
00:47:32 | FromDiscord | <evoalg> So, you used macro's to help you use macro's? |
00:47:46 | FromDiscord | <Elegantbeef> Well i used the NimVM and macros to help macro 😛 |
00:47:59 | FromDiscord | <evoalg> that's very cool |
00:49:58 | FromDiscord | <evoalg> When I get into macro's I'll ask you able it further ... for now I'm waiting to be stronger in the basics. I do feel that I understand what macro's are used for now (from a 50 thousand foot level) |
00:50:37 | FromDiscord | <Elegantbeef> Cmon you can be atleast on everest looking down at the trench! |
00:51:16 | FromDiscord | <evoalg> I guess my eyes aren't as good as they were when I was your age |
00:52:06 | FromDiscord | <Elegantbeef> Fairly certain there is a logistical issue that even elven eyes dont solve |
00:56:15 | FromDiscord | <Elegantbeef> Talking to you today reminded me about the dumb resetable closure restraint, so now we can reassign to the same closures! |
00:57:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GdC |
01:00:22 | FromDiscord | <Elegantbeef> But that `true` in the items iterator makes me angry so... distinct it is! |
01:03:17 | FromDiscord | <evoalg> let me try and digest that! |
01:06:37 | FromDiscord | <Elegantbeef> It's not that complicated, `a` is a resetable closure which in this case means you can either do `.reset` or `items(true)`(though it's now `items(Reset)`) to set values to their default |
01:07:15 | * | krux02 joined #nim |
01:07:18 | FromDiscord | <Elegantbeef> So in the case of `asResetableClosure("hello"[1..2])` it stores `"hello"` and `1..2` in `a` and when you call `reset` reinitializes the iterator |
01:08:14 | FromDiscord | <evoalg> easy! |
01:08:41 | FromDiscord | <Elegantbeef> The confusing stuff is the macro in the background that converts the iterator to a closure and generates it |
01:11:01 | * | krux02 quit (Remote host closed the connection) |
01:14:19 | FromDiscord | <codic> finally released the rewrite of my nim wm, yay https://media.discordapp.net/attachments/371759389889003532/913960896714375168/unknown.png |
01:14:35 | FromDiscord | <codic> (edit) "nim wm," => "wm in nim," |
01:23:21 | FromDiscord | <evoalg> In reply to @Elegantbeef "The confusing stuff is": I'm such a noob I had to do this to understand it: https://play.nim-lang.org/#ix=3GdG |
01:25:15 | FromDiscord | <evoalg> (I forgot a `print x` in line 27 too) |
01:33:03 | FromDiscord | <Elegantbeef> But hey you understand the silly thing 😛 |
01:34:57 | FromDiscord | <evoalg> remind me ... a normal slice in Nim is not an iterator, but the slicerator module makes it into an iterator (which means for large slices it's memory efficient and possibly speed effecient), and furthermore, slicerator also has the option of making closure iterators out of normal iterators, and even has a resetable closure iterator ... is that right? |
01:35:12 | FromDiscord | <Elegantbeef> Yep |
01:35:37 | FromDiscord | <superfunc> In reply to @Elegantbeef "Thanks to macros we": big agree, metaprogramming is how clojure got async, pattern matching and a bunch of other neat stuff |
01:36:03 | FromDiscord | <Elegantbeef> You can do `for x in @[10, 20, 30, 40][0..2]` and it will do a non allocating immutable slice with slicerator |
01:36:27 | FromDiscord | <Elegantbeef> Or if you want a mutable slice you can do `for x in @[10, 20, 30, 40]{0..2}` |
01:39:24 | FromDiscord | <Elegantbeef> And you seem to grasp what a resetable closure does |
01:40:27 | FromDiscord | <evoalg> sent a code paste, see https://play.nim-lang.org/#ix=3GdJ |
01:40:44 | FromDiscord | <Elegantbeef> Well that was a dumb example since `@[10, 20, 30, 40]` isnt mutable |
01:41:05 | FromDiscord | <Elegantbeef> it should be `var a = @[10, 20, 30, 40]` and `for x in a{0..2}: x = 300` |
01:41:06 | FromDiscord | <evoalg> ahhh true it's a literal |
01:41:15 | FromDiscord | <evoalg> nice |
01:44:06 | FromDiscord | <Elegantbeef> There is also some dumber stuff in that package i question removing |
01:44:19 | FromDiscord | <Elegantbeef> But yea slices + iterators as closure is mostly all the magic |
01:45:31 | * | pch joined #nim |
01:45:38 | FromDiscord | <evoalg> "dumber" implies the above is dumb, but it seems to me it's not dumb at all, as it's not satisfying (at least to me) that some of the core Nim things aren't iterators when they should be |
01:46:05 | FromDiscord | <Elegantbeef> Nah there is more in that package which is dumb |
01:46:41 | FromDiscord | <Elegantbeef> Like i said though this stuff couldnt be done pre 1.6 |
01:46:52 | FromDiscord | <Elegantbeef> `[]` was not allowed for iterators |
01:47:23 | FromDiscord | <evoalg> remove the other parts and get this into Nim 2.0 as default? Am I being naive again? |
01:47:58 | FromDiscord | <Elegantbeef> Well 1.6.2 maybe idk |
01:48:24 | FromDiscord | <evoalg> that would be awesome |
01:55:29 | FromDiscord | <evoalg> resetable or resettable? |
02:02:39 | FromDiscord | <Elegantbeef> I'll tell you when i learn to write remedial english 😛 |
02:03:43 | FromDiscord | <Elegantbeef> It's now spelled properly, well not properly but with two Ts 😛 |
02:04:26 | FromDiscord | <evoalg> I'm a shocking speller ... my spell check was complaining that's all 😉 |
02:04:51 | FromDiscord | <Elegantbeef> Cheers, i cannot spell and let rika bitch and moan about it |
02:06:35 | FromDiscord | <evoalg> I like findAll and rFindAll ... I hope they won't be taken out? |
02:06:45 | FromDiscord | <Elegantbeef> Probably not |
02:06:52 | FromDiscord | <Elegantbeef> `collectit` probably will be |
02:08:27 | FromDiscord | <evoalg> unless it's argued that some should be moved to a different module? |
02:09:36 | FromDiscord | <evoalg> (I don't know and I'm not good with such things) |
02:13:13 | FromDiscord | <evoalg> oh you changed it to "Resttable" |
02:13:32 | FromDiscord | <evoalg> you did it on purpose to wind Rika up |
02:16:07 | FromDiscord | <Elegantbeef> Hey apparently that's how it's spelled |
02:16:55 | FromDiscord | <evoalg> it does have two t's in it, I'll give you half a mark |
02:17:16 | FromDiscord | <Elegantbeef> Lol i cannot fucking spell |
02:22:17 | FromDiscord | <Mocha> is there a naming convention for types/variables that have to contain version numbers/decimals? e.g. "Version 1.3" -> Version13 |
02:23:05 | FromDiscord | <Elegantbeef> I think `TypevNumber` is the idiomatic way |
02:23:39 | FromDiscord | <Elegantbeef> Personally i'd prefer using a pragma and a string or tuple to get the type, but that's probably needlessly complex |
02:28:08 | FromDiscord | <Mocha> Oh thanks, I didn't know `TypevNumber` was idiomatic! Planning on just using a pure enum; just to confirm, if the version number has decimals (e.g. 1.2, 1.3, 1.4...), convention is just to omit them in the name? |
02:29:11 | FromDiscord | <Elegantbeef> Yep |
02:29:19 | FromDiscord | <Elegantbeef> Atleast i think so, it's very much up to you |
02:31:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GdR |
02:31:42 | FromDiscord | <Elegantbeef> But likei said probably needlessly complex |
02:32:12 | FromDiscord | <Mocha> oh the type itself doesn't need to be versioned, I'm just building a library that has to be aware of multiple protocol versions |
02:32:21 | FromDiscord | <Elegantbeef> Ah |
02:32:41 | FromDiscord | <Elegantbeef> Could be done with a static enum then |
02:34:10 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GdS |
02:34:23 | FromDiscord | <Elegantbeef> `[T: static ProtocolVersion]`\ |
02:34:32 | FromDiscord | <Elegantbeef> But that very much depends |
02:34:33 | FromDiscord | <Mocha> interesting |
02:34:39 | FromDiscord | <Mocha> i'll look into it for sure |
02:34:46 | * | src quit (Quit: Leaving) |
02:34:47 | FromDiscord | <Elegantbeef> What's the protocol? |
02:34:52 | FromDiscord | <Mocha> TLS :) |
02:35:15 | FromDiscord | <Elegantbeef> Ah so something that probably certainly only adds? |
02:35:24 | FromDiscord | <Mocha> yep |
02:36:14 | FromDiscord | <Elegantbeef> So then yea might be able to use that method and then you just have `proc doThing(myType: MyType)` |
02:36:27 | FromDiscord | <Elegantbeef> Unless you need to dispatch off that enum |
02:38:15 | * | neurocyte0132889 quit (Ping timeout: 268 seconds) |
02:52:04 | * | rockcavera quit (Remote host closed the connection) |
03:04:49 | FromDiscord | <Anonymous Poet> sent a code paste, see https://play.nim-lang.org/#ix=3GdY |
03:05:02 | FromDiscord | <Elegantbeef> `elif` is the `elif` version of `when` |
03:05:26 | FromDiscord | <Anonymous Poet> 😮 |
03:05:50 | FromDiscord | <Elegantbeef> Do wish there was a built in case statement version of `when` would make life nicer 😀 |
03:05:52 | FromDiscord | <Anonymous Poet> thanks! thats awesome |
03:06:17 | FromDiscord | <Anonymous Poet> this is good enough for my case now, not that many cases to enumerate ... would be kinda nice though |
03:06:41 | FromDiscord | <Elegantbeef> I mean it's technically possible with case statement macros but yea not great |
03:07:29 | FromDiscord | <Anonymous Poet> nim to the resuce yet again haa |
03:07:30 | FromDiscord | <Anonymous Poet> haha |
03:36:50 | FromDiscord | <impbox [ftsf]> trying to use redis to do `zrangebyscore` but I get ` Exception message: Expected '' at the beginning of a status reply got '-'`, is there a way to get the error? |
03:37:22 | FromDiscord | <Elegantbeef> What do you mean? |
03:37:45 | FromDiscord | <impbox [ftsf]> well the `-` in redis signifies an error, and it's usually followed by an error message from the server |
03:38:05 | FromDiscord | <Elegantbeef> Ah then not a clue |
03:39:04 | FromDiscord | <impbox [ftsf]> seems like a nim redis bug since the same command works via cli, but not sure |
03:42:46 | FromDiscord | <impbox [ftsf]> aha `-ERR syntax error` |
03:50:40 | FromDiscord | <impbox [ftsf]> yep, bug in nim redis |
03:51:19 | FromDiscord | <impbox [ftsf]> well.. it was, but already fixed |
03:52:09 | FromDiscord | <impbox [ftsf]> looks like it needs a version bump |
03:53:31 | FromDiscord | <gogolxdong (liuxiaodong)> sent a code paste, see https://paste.rs/JLP |
03:55:46 | * | arkurious quit (Quit: Leaving) |
03:56:08 | FromDiscord | <gogolxdong (liuxiaodong)> Test fails with unknown Bool type in nim-web3 recently. |
03:57:05 | FromDiscord | <gogolxdong (liuxiaodong)> Is Bool type still usable or what's the alternative type? |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:31 | * | supakeen joined #nim |
04:30:59 | FromDiscord | <Yardanico> `Bool` doesn't exist in Nim by default or in stdlib, it must be something specific to nim-web3 or some of the libraries it uses |
04:37:04 | FromDiscord | <Rika> Also bad naming because it’s too similar to regular bool |
04:47:12 | FromDiscord | <Yardanico> looks like it's generated in a macro https://media.discordapp.net/attachments/371759389889003532/914014468575465492/unknown.png |
04:47:20 | FromDiscord | <Yardanico> solidity contracts, web3 crypto stuff |
04:47:23 | FromDiscord | <Yardanico> https://github.com/status-im/nim-web3/blob/master/web3/encoding.nim#L83 |
04:55:13 | * | cheer[m] joined #nim |
05:38:40 | FromDiscord | <jfmonty2> Using Zippy (https://github.com/guzba/zippy) to compress a big string at compile-time, and I'm finding that it's really slow. Like, takes 5 minutes to compress 500KB slow. Am I doing something wrong or is it just "tough luck, compile-time execution is slow" ? |
05:39:30 | FromDiscord | <impbox [ftsf]> hmm compile time is probably slow |
05:39:37 | FromDiscord | <Elegantbeef> Consider using supersnappy instead |
05:39:57 | FromDiscord | <Elegantbeef> It's a less efficient for size compression algorithim but also cheaper for performance |
05:41:13 | FromDiscord | <jfmonty2> interesting, I'll have to take a look. |
05:41:51 | FromDiscord | <demotomohiro> You would better to run a external command to compress large string and staticRead the output at compile time. |
05:42:11 | FromDiscord | <impbox [ftsf]> aye |
05:42:11 | FromDiscord | <Elegantbeef> Probably, though this does give me a good idea to benchmark the VM |
05:42:35 | FromDiscord | <jfmonty2> yeah, that was the other thing that occurred to me. It's just a bit of a pain because I'll have to read the original string anyway so I can count the newlines. Not a huge deal though. |
06:08:26 | FromDiscord | <evoalg> sent a code paste, see https://play.nim-lang.org/#ix=3Get |
06:11:25 | FromDiscord | <Elegantbeef> Hmm yea that's not calling the iterator anymore, which is an other allocation, so unacceptable! |
06:13:29 | FromDiscord | <Yardanico> In reply to @jfmonty2 "Using Zippy (https://github.com/guzba/zippy) to": If compile time compression is slow you can always call some external binary and save its output in a const :) |
06:13:42 | FromDiscord | <Yardanico> Perhaps even the binary made by yourself for that specific purpose |
06:13:48 | FromDiscord | <Yardanico> A little hack |
06:15:20 | FromDiscord | <Elegantbeef> Already mentioned yard, how dare you repeat help! |
06:15:38 | FromDiscord | <Yardanico> Where did you mention that? I honestly didn't see |
06:15:48 | FromDiscord | <Elegantbeef> I didnt |
06:16:14 | FromDiscord | <impbox [ftsf]> yard has blocked everyone except beef |
06:16:25 | FromDiscord | <Yardanico> Look |
06:16:26 | FromDiscord | <Elegantbeef> I am just kidding of course but it was mentioned to use an external program |
06:16:30 | FromDiscord | <Yardanico> (edit) "Look" => "Lol" |
06:16:34 | FromDiscord | <Yardanico> yeah I see it now |
06:16:39 | FromDiscord | <Yardanico> I was focused on your messages |
06:16:44 | FromDiscord | <impbox [ftsf]> fair |
06:16:59 | FromDiscord | <Elegantbeef> Ah yea they're like a car crash |
06:17:06 | FromDiscord | <Elegantbeef> Dont want to look but cant look away |
06:21:24 | FromDiscord | <Elegantbeef> @evoalg\: there we go now you can do `"Hello".pairs(0..^2)` |
06:21:39 | FromDiscord | <Elegantbeef> Do like that you're using slicerator, making it better one subtly at a time |
06:22:18 | FromDiscord | <evoalg> nice ... it'll potentially break existing code by importing it though right? |
06:22:25 | FromDiscord | <Elegantbeef> The index is the index in the array and not since the start of the slice, which might be backwards |
06:22:34 | FromDiscord | <Elegantbeef> Nope |
06:22:45 | FromDiscord | <Elegantbeef> It the normal overload will take priority |
06:22:50 | FromDiscord | <evoalg> nice! |
06:23:17 | FromDiscord | <Elegantbeef> `for i, x in someIter` will call `pairs()` the fact you need to do `(0..1)` or `(0..^1)` means it'll never call it |
06:28:18 | FromDiscord | <evoalg> I'm not sure i understand. It looks like slicerator still breaks existing code that's like `for i, x in "Hello"[0..^2]:` |
06:28:32 | FromDiscord | <Elegantbeef> You mean it'll fix it |
06:29:13 | FromDiscord | <Elegantbeef> Well there is some ambiguity for that now with the iterator`[]` so you need to call pairs |
06:29:29 | FromDiscord | <Elegantbeef> And some argue you should call the iterator anyway 😀 |
06:30:05 | FromDiscord | <Elegantbeef> `for` is looking for an iterator you're doing `i, x` so it's expecting `[]` to return a tuple, but it doesnt |
06:30:36 | FromDiscord | <Elegantbeef> The solution is to call `.pairs` be it the builtin or iterator version of `"Hello".pairs(0..^2)` |
06:31:23 | FromDiscord | <Elegantbeef> So i guess it does break code in this one instance, but the break would get you more performant code so i think it's kinda the point of importing slicerator |
06:31:51 | FromDiscord | <Elegantbeef> The entire point of slicerator is to encourage 0 allocating slices and using iterators more |
06:32:40 | FromDiscord | <Elegantbeef> `for i, x in "Hello"[0..^2]` without it is just a hack that is abused for "proper" behaviour imo |
06:33:25 | FromDiscord | <Elegantbeef> We're abusing the fact `"Hello[0..^2]` returns a sequence then iterating over that sequence with `pairs` since we want `i, x` |
06:34:33 | FromDiscord | <Elegantbeef> I suppose I could use an operator for creating the slice so it doesnt interfere like `"hello"[&0..^2]` |
06:34:36 | FromDiscord | <evoalg> Yea I think it's a great idea. |
06:35:03 | FromDiscord | <evoalg> I mean using an iterator is a great idea |
06:35:40 | FromDiscord | <Elegantbeef> Yea i dont like using a unary operator for removing the ambiguity since sliceing a sequence is "wrong" in this case |
06:36:05 | FromDiscord | <evoalg> I just don't know enough about Nim or the community |
06:36:45 | FromDiscord | <evoalg> So for a normal `for x in myseq:` with no slice, another copy isn't done right? |
06:36:59 | FromDiscord | <Elegantbeef> Yea i dont really care about getting slicerator added to the stdlib, it's opinionated and forces better iterations |
06:37:12 | FromDiscord | <evoalg> true |
06:37:13 | FromDiscord | <Elegantbeef> You're correct that iterates it as is |
06:37:39 | FromDiscord | <evoalg> might it break imported code that I didn't write? |
06:37:47 | FromDiscord | <evoalg> or doesn't import work like that? |
06:37:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GeM |
06:37:55 | FromDiscord | <Elegantbeef> Import doesnt work that way |
06:38:14 | FromDiscord | <evoalg> ahh ok ... and also ahh ok 🙂 |
06:38:14 | FromDiscord | <Elegantbeef> Imported symbols can only go up in normal nim |
06:38:33 | FromDiscord | <Elegantbeef> To get them to go down you need to abuse features of the compiler |
06:38:43 | FromDiscord | <Elegantbeef> So you'd know that what you're doing is going to fuck it up |
06:41:20 | FromDiscord | <evoalg> Why does "enumerate" still support `for i, x in ` when it's still an iterator? |
06:41:42 | FromDiscord | <Elegantbeef> Enumerate yields a tuple |
06:42:01 | FromDiscord | <Elegantbeef> Actually sorry enumerate is a macro |
06:42:11 | FromDiscord | <Elegantbeef> So it rewrites the entire for loop |
06:45:14 | FromDiscord | <Elegantbeef> I guess i didnt explain |
06:45:31 | FromDiscord | <Elegantbeef> But if you do `for i, x in enumerate(mySeq.items)` it'll yield `index, value` |
06:45:47 | * | neocron joined #nim |
06:45:57 | FromDiscord | <Elegantbeef> Doesnt make much sense in this case since `pairs` exists, but in cases that you dont have pairs it does |
06:46:41 | FromDiscord | <evoalg> it mostly makes sense |
06:47:45 | FromDiscord | <evoalg> ... but where pairs would do another copy of a slice, enumerate wouldn't? (just like slicerator?) |
06:47:54 | FromDiscord | <evoalg> (I'm just trying to get my head around it) |
06:48:16 | FromDiscord | <Elegantbeef> pairs doesnt do the copy |
06:48:31 | FromDiscord | <Elegantbeef> `"hello"[0..^2]` creates a new string "hell" which then we call pairs on |
06:48:37 | * | Doraemon quit (Ping timeout: 268 seconds) |
06:48:45 | FromDiscord | <evoalg> ahhh ok |
06:49:16 | FromDiscord | <Elegantbeef> without slicerator you're always calling the slice proc so it's always reallocating whenever you slice |
06:49:32 | FromDiscord | <Elegantbeef> And of course it's pointless when you're iterating |
06:49:35 | FromDiscord | <evoalg> oh! |
06:49:46 | FromDiscord | <evoalg> that makes sense |
06:50:19 | FromDiscord | <Elegantbeef> Good! |
06:51:26 | FromDiscord | <evoalg> (and hence the need for slicerator) ... hehe thank you for today's lesson ... my head is about to explode with info again 😄 |
06:52:14 | FromDiscord | <Elegantbeef> Yep, with slicerator(assuming you dont use pairs) you get a dropin replacement that gives you a smaller memory footprint and slightly faster operation |
06:52:35 | FromDiscord | <Rika> i saw something about a unary |
06:52:50 | FromDiscord | <Rika> oh it was something else |
06:53:16 | FromDiscord | <Elegantbeef> Well it was a possibility to stop the slice iterator being confused for a slice |
06:53:21 | FromDiscord | <Rika> i was thinking of why not make a unary or a function that makes any iterable into an "intermediate" where [..] does proper iterator slicing |
06:53:38 | FromDiscord | <Elegantbeef> It's not needed |
06:53:48 | FromDiscord | <Rika> im not a fan of pairs(..) |
06:53:50 | FromDiscord | <Rika> i |
06:53:53 | FromDiscord | <Rika> whoops |
06:54:04 | FromDiscord | <impbox [ftsf]> i,m .. pairs() |
06:54:33 | FromDiscord | <Elegantbeef> Well `enumerate("hello"[0..^2])` works so alias `enumerate`? |
06:55:34 | FromDiscord | <Elegantbeef> I dont know `.pair(a..b)` kinda sucks, but short of doing `[&a..&b]` or similar i dont think it can be done nicely |
06:56:10 | FromDiscord | <Elegantbeef> Already using `{}` for mutable slices |
06:56:25 | FromDiscord | <Rika> <some name here>(x)[a..b] idk |
06:57:08 | FromDiscord | <Elegantbeef> PRs welcomed is all i can say cause yea i dont like it but i cant think of something reasonable |
06:58:41 | FromDiscord | <Elegantbeef> Ooh might be able to use a distinct open array |
06:58:52 | NimEventer | New thread by GalaxyDragon: Nim On AVR, see https://forum.nim-lang.org/t/8659 |
07:00:29 | NimEventer | New Nimble package! jester2swagger - Converts a file with Jester routes to Swagger JSON which can be imported in Postman., see https://github.com/ThomasTJdev/jester2swagger |
07:02:14 | FromDiscord | <Elegantbeef> Seems that's a no |
08:17:05 | * | n59 joined #nim |
08:18:01 | * | n59 quit (Client Quit) |
09:00:37 | NimEventer | New Nimble package! riimut - Transform latin letters to runes & vice versa. Four runic dialects available., see https://github.com/stscoundrel/riimut-nim |
09:48:48 | * | lumo_e joined #nim |
09:57:51 | FromDiscord | <Hex08> sent a code paste, see https://play.nim-lang.org/#ix=3Gfj |
09:58:22 | FromDiscord | <Rika> You only need to assign it to the first entry |
09:58:25 | FromDiscord | <Rika> Otherwise no |
09:59:06 | FromDiscord | <Hex08> In reply to @Rika "You only need to": Sorry I don't understand what you mean |
09:59:15 | FromDiscord | <Hex08> Adding a `.Natural` only to the `1` doesn't seem to work |
09:59:17 | FromDiscord | <Rika> Only 1 needs to have suffix |
09:59:20 | FromDiscord | <Rika> Really now |
09:59:35 | FromDiscord | <Hex08> Oh no! |
09:59:39 | FromDiscord | <Hex08> Sorry you're right |
09:59:46 | FromDiscord | <Rika> !eval var arr: array[4, Natural] = [1.Natural, 2, 3, 4] |
09:59:49 | NimBot | <no output> |
09:59:52 | FromDiscord | <Hex08> I had some leftover code, your suggestion works |
09:59:55 | FromDiscord | <Rika> Yeah |
10:00:03 | FromDiscord | <Rika> It’s at least somewhat better than all entries |
10:00:09 | FromDiscord | <Rika> Of course it’s still not the best |
10:01:04 | FromDiscord | <Hex08> Yeah it's alright, I think in Rust you would need a suffix for each but I'm not 100% sure |
10:02:14 | FromDiscord | <Elegantbeef> It might resolve it from it's type inference |
10:02:50 | FromDiscord | <Rika> Yeah reverse inference would be nice |
10:03:56 | FromDiscord | <Hex08> In reply to @Elegantbeef "It might resolve it": Yeah but it will still complain that the literals don't match |
10:04:07 | FromDiscord | <Hex08> You need a suffix for each 😦 https://media.discordapp.net/attachments/371759389889003532/914094224843100170/unknown.png |
10:04:26 | FromDiscord | <Elegantbeef> Oh interesting |
10:05:04 | FromDiscord | <Elegantbeef> I guess it's ambiguous if it should be a int or float and they're sticklers for "correct"? |
10:06:28 | FromDiscord | <Hex08> Yes, I might be wrong but I think Rust doesn't ever implicitly cast primitive types |
10:06:47 | FromDiscord | <Hex08> `int / float` is an error and you have to do `int as f64 / float` |
10:08:42 | FromDiscord | <Elegantbeef> Yea seems they'll infer the size of an integer but never make it a float |
10:08:45 | FromDiscord | <Elegantbeef> Which is an odd behaviour |
10:09:10 | FromDiscord | <Rika> That’s just annoying |
10:10:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Gfm |
10:10:31 | FromDiscord | <Rika> That’s normal at least |
10:10:37 | FromDiscord | <Rika> Same issue with Nim |
10:10:51 | FromDiscord | <Rika> Ah save for the integer part |
10:11:07 | FromDiscord | <Elegantbeef> Guess they view that int -\> sized int is okay to do implicitly but int -\> float is a no no |
10:11:14 | FromDiscord | <Rika> Wait no the whole thing is still like Nim yeah |
10:11:29 | FromDiscord | <Rika> I mean of course |
10:11:47 | FromDiscord | <Elegantbeef> It's not like Nim really |
10:11:52 | FromDiscord | <Rika> Integers can’t be fully represented by their same sized float counterparts |
10:11:55 | FromDiscord | <Elegantbeef> you can pass a numeric literal to any type |
10:12:02 | FromDiscord | <Rika> What you showed is not that |
10:12:19 | FromDiscord | <Rika> You showed a literal getting bound to a variable then being passed into a function |
10:12:23 | FromDiscord | <Elegantbeef> The compiler is backwards reasoning the type of `b` just find |
10:12:31 | FromDiscord | <Elegantbeef> Look at the type it reasoned `b` to |
10:12:35 | FromDiscord | <Elegantbeef> `u8` |
10:12:41 | FromDiscord | <Rika> Yes |
10:12:43 | FromDiscord | <Rika> Is that wrong? |
10:13:07 | FromDiscord | <Rika> Okay |
10:13:10 | FromDiscord | <Rika> I see your point |
10:13:11 | FromDiscord | <Elegantbeef> It's right, but i find it odd that it doesnt do it for a aswell since it's a literal |
10:13:59 | FromDiscord | <Rika> Well I think because integer to integer is always reversible unless you exceed the size of the destination |
10:14:06 | FromDiscord | <Rika> Whilst it’s not true for the other |
10:14:20 | FromDiscord | <Elegantbeef> Possibly, i find the behaviour odd still |
10:14:56 | FromDiscord | <Elegantbeef> You have this backwards type inference but only use it for some literals, seems counter to what one would expect |
10:16:08 | FromDiscord | <Schelz> I have a question why C code returns me wired numbers in nim print ? |
10:16:21 | FromDiscord | <Elegantbeef> Also that's the first rust code i've ever written, oh how the might have fallen |
10:16:34 | FromDiscord | <Elegantbeef> What's the code schelz? |
10:16:37 | FromDiscord | <Schelz> https://media.discordapp.net/attachments/371759389889003532/914097372102012948/unknown.png |
10:16:43 | FromDiscord | <Schelz> https://media.discordapp.net/attachments/371759389889003532/914097394751262720/unknown.png |
10:17:05 | FromDiscord | <Schelz> returns numbers like: 6289996, 10747340, 20970220 |
10:17:07 | FromDiscord | <Schelz> etc.. |
10:17:18 | FromDiscord | <Elegantbeef> One second let me recreate it |
10:17:28 | FromDiscord | <Elegantbeef> Oh you use `int` instead of `cint` |
10:17:31 | FromDiscord | <Elegantbeef> Could be an issue |
10:18:25 | FromDiscord | <Schelz> change to cint {.importc.} nothing changed |
10:18:52 | FromDiscord | <Schelz> (edit) "change" => "I changed " | "I changed to cint {.importc.} nothing changed ... " added "still weird numbers" |
10:18:52 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3Gfp works fine here |
10:19:17 | FromDiscord | <Schelz> lol |
10:20:48 | FromDiscord | <Schelz> I copied the code in the files nothing lol... |
10:20:54 | FromDiscord | <Elegantbeef> I dont know what to say |
10:21:05 | FromDiscord | <Elegantbeef> Wait did the code i give you not work? |
10:21:09 | FromDiscord | <Rika> Are you on windows |
10:21:18 | FromDiscord | <Rika> Maybe that would matter but it really shouldn’t |
10:21:37 | FromDiscord | <Elegantbeef> `nim -v` |
10:21:48 | FromDiscord | <Elegantbeef> There has to be something we're missing |
10:22:04 | FromDiscord | <Schelz> https://media.discordapp.net/attachments/371759389889003532/914098743199023144/unknown.png |
10:22:13 | FromDiscord | <Elegantbeef> Cause the only thing that makes sense is that you're not initialising values on C, but if that's the function that's not an issue |
10:22:26 | FromDiscord | <Elegantbeef> windows 32bit |
10:22:44 | FromDiscord | <Elegantbeef> So the code i gave you also failed? |
10:23:03 | FromDiscord | <Rika> It should still work even on 32 bit thoughhhhhh |
10:23:24 | FromDiscord | <Elegantbeef> Indeed |
10:24:16 | FromDiscord | <Schelz> In reply to @Elegantbeef "So the code i": yes |
10:24:28 | FromDiscord | <Rika> That is seriously strange |
10:24:58 | FromDiscord | <Elegantbeef> Does the compiled C work properly? |
10:25:30 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3Gfs |
10:25:38 | FromDiscord | <Elegantbeef> Although i assume you could've written that yourself 😀 |
10:25:56 | FromDiscord | <Rika> What if Nim thinks it’s 32 bit but the compiler is 64? |
10:25:58 | FromDiscord | <Elegantbeef> I can only imagine the 32bit nim compiler is shitting the bed, or there is an issue with your C compiler |
10:26:31 | FromDiscord | <Schelz> returns 88 and 66 https://media.discordapp.net/attachments/371759389889003532/914099857650761778/unknown.png |
10:26:46 | FromDiscord | <Rika> That’s correct then |
10:26:57 | FromDiscord | <Rika> 8 from print and another 8 from echo |
10:26:59 | FromDiscord | <Elegantbeef> Ok so we're in a proper universe |
10:27:14 | FromDiscord | <Rika> Lol |
10:27:47 | NimEventer | New thread by Mantielero: Importcpp constructor issue, see https://forum.nim-lang.org/t/8660 |
10:29:37 | FromDiscord | <Elegantbeef> I'm now confused why the other errored, is cint on 32bit not a 32bit int? |
10:31:03 | FromDiscord | <Schelz> lame its from cint {.importC, nodecl.} it has to be nodecl. too in order to work |
10:31:27 | FromDiscord | <Schelz> else its printing random numbers |
10:31:37 | FromDiscord | <Schelz> https://media.discordapp.net/attachments/371759389889003532/914101146002550824/unknown.png |
10:32:20 | FromDiscord | <Elegantbeef> you probably could just do `importc, header: "importex.c"` |
10:32:40 | FromDiscord | <Elegantbeef> then you wouldnt need the `{.compile: ... .}` |
10:32:48 | FromDiscord | <Elegantbeef> Atleast i dont think so |
10:33:22 | FromDiscord | <Elegantbeef> Eh probably dumb, to do that |
10:33:24 | FromDiscord | <Schelz> aha its working that way too |
10:33:37 | FromDiscord | <Schelz> works good https://media.discordapp.net/attachments/371759389889003532/914101649964929054/unknown.png |
10:34:29 | FromDiscord | <Elegantbeef> Well if you have more functions you might want to do `{.push importc header:"importex.c".}` and a `{.pop.}` after |
10:35:47 | FromDiscord | <Schelz> thx |
11:04:09 | * | lumo_e quit (Remote host closed the connection) |
11:05:26 | * | lumo_e joined #nim |
11:14:24 | * | src joined #nim |
11:19:59 | NimEventer | New thread by Lachu: Turn of name mangling for Nim type, while exporting to c, see https://forum.nim-lang.org/t/8661 |
11:29:33 | * | src quit (Quit: Leaving) |
11:30:25 | * | src joined #nim |
11:35:40 | * | src quit (Quit: Leaving) |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.3) |
12:06:55 | * | supakeen joined #nim |
12:18:32 | * | lumo_e quit (Ping timeout: 268 seconds) |
12:25:21 | * | neurocyte0132889 joined #nim |
12:25:21 | * | neurocyte0132889 quit (Changing host) |
12:25:21 | * | neurocyte0132889 joined #nim |
12:32:28 | * | PMunch joined #nim |
12:58:43 | FromDiscord | <lantos> @Yardanico |
13:10:02 | FromDiscord | <5271> how do i read a single character?↵like readKey |
13:11:57 | FromDiscord | <lantos> @cheatfate |
13:12:05 | FromDiscord | <lantos> (edit) "@cheatfate ... " added "on discord?" |
13:12:12 | FromDiscord | <lantos> (edit) |
13:12:21 | FromDiscord | <lantos> (edit) "@cheatfate" => "cheatfate" |
13:12:28 | FromDiscord | <lantos> (edit) "cheatfate" => "@cheatfate" |
13:13:36 | * | lumo_e joined #nim |
13:19:10 | FromDiscord | <gdquest> sent a code paste, see https://play.nim-lang.org/#ix=3Ggc |
13:20:29 | FromDiscord | <gdquest> sent a code paste, see https://play.nim-lang.org/#ix=3Ggd |
13:20:33 | FromDiscord | <Rika> notin |
13:20:35 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3Gge |
13:20:37 | FromDiscord | <enthus1ast> if not found -1 |
13:20:59 | FromDiscord | <Rika> `if character notin ...` |
13:21:03 | FromDiscord | <gdquest> Ah! `notin`, yes |
13:21:12 | FromDiscord | <gdquest> It's a bit like everything works like procedures? |
13:21:14 | FromDiscord | <Rika> if you prefer you can always `not_in` |
13:21:26 | FromDiscord | <gdquest> And thanks @enthus1iast too |
13:23:22 | FromDiscord | <gdquest> It's going very well working with nim already. I'm coding a formatter for my team and it's fairly straightforward so far |
13:30:32 | * | terminalpusher joined #nim |
13:36:09 | * | lumo_e quit (Ping timeout: 250 seconds) |
13:52:32 | * | mahlon quit (Ping timeout: 256 seconds) |
13:55:15 | * | terminalpusher quit (Remote host closed the connection) |
13:59:17 | FromDiscord | <lantos> sent a code paste, see https://play.nim-lang.org/#ix=3Ggo |
14:04:17 | * | anddam quit (Quit: WeeChat 3.3) |
14:14:54 | * | arkurious joined #nim |
14:54:10 | * | mahlon joined #nim |
15:00:08 | * | anddam joined #nim |
15:07:59 | * | lumo_e joined #nim |
15:13:51 | FromDiscord | <tandy> can you do a deepcopy in nim? |
15:13:52 | FromDiscord | <tandy> like in python? |
15:14:03 | FromDiscord | <Rika> yes |
15:14:07 | FromDiscord | <tandy> i have a seq[seq[ref object] |
15:14:15 | FromDiscord | <tandy> and x = y isnt working |
15:14:24 | FromDiscord | <Rika> deepcopy() |
15:14:25 | FromDiscord | <tandy> well it copies but changes are carried over to y |
15:14:28 | FromDiscord | <Rika> x = y is shallow |
15:14:53 | FromDiscord | <Rika> deep copies are explicit |
15:17:24 | FromDiscord | <tandy> oh epic it works |
15:19:47 | FromDiscord | <tandy> oh shit does `deepcopy` work with emscripten ? |
15:21:54 | FromDiscord | <tandy> yees it compiles |
16:01:32 | FromDiscord | <Rika> well deepcopy is a magic |
16:01:42 | FromDiscord | <Rika> https://github.com/nim-lang/Nim/blob/version-1-6/lib/system.nim#L2960 |
16:14:43 | * | lumo_e quit (Ping timeout: 268 seconds) |
16:15:20 | * | lumo_e joined #nim |
16:20:11 | FromDiscord | <gdquest> Wow! |
16:20:35 | FromDiscord | <gdquest> I must say, the ability to jump to definition with the standard library is so cool 🙂 |
16:21:09 | FromDiscord | <gdquest> How would you go about something like this in nim? This is Python `"\t" indent_level + "#" dash_count + wrapped_line` |
16:21:52 | FromDiscord | <gdquest> So I'm doing it the simple way, with a for loop right now, but I was wondering if there's something different or more idiomatic |
16:23:16 | FromDiscord | <haxscramper> `import std/strutils; repeat("$", dashCount)` |
16:23:23 | FromDiscord | <enthus1ast> well there is align↵↵https://nim-lang.org/docs/strutils.html#align%2Cstring%2CNatural%2Cchar |
16:27:55 | FromDiscord | <gdquest> Perfect, thanks! |
16:30:09 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3Ghb |
16:30:10 | FromDiscord | <gdquest> sent a code paste, see https://paste.rs/Qf7 |
16:30:39 | FromDiscord | <gdquest> Yes it's great you can make functions like that, although I'm avoiding sugar for now to get used to the Nim operators and functions |
16:31:27 | FromDiscord | <gdquest> (edit) "https://play.nim-lang.org/#ix=3Ghd" => "https://play.nim-lang.org/#ix=3Ghc" |
17:19:12 | * | lumo_e quit (Ping timeout: 260 seconds) |
17:28:16 | FromDiscord | <tandy> how can i debug illegal storage access error? |
17:28:37 | FromDiscord | <enthus1ast> have a closer look at your ref or pointer types |
17:29:28 | FromDiscord | <enthus1ast> u prolly try to use a unititialized ref |
17:30:13 | FromDiscord | <enthus1ast> btw JsonNode is ref |
17:40:13 | * | lumo_e joined #nim |
17:46:11 | * | lumo_e quit (Ping timeout: 250 seconds) |
17:47:27 | * | lumo_e joined #nim |
17:53:30 | FromDiscord | <tandy> hmmm i tried |
17:53:34 | FromDiscord | <tandy> big project those |
17:55:00 | FromDiscord | <enthus1ast> you could use gdb to find this, but i have not much experience with nim and gdb, so others might comment on this |
17:56:03 | FromDiscord | <enthus1ast> but i think its something along those lines\:↵compile with --debugger\:native↵run with gdb until it crashes↵see the stacktrace |
17:56:35 | * | lumo_e quit (Ping timeout: 250 seconds) |
17:57:37 | * | lumo_e joined #nim |
17:59:03 | FromDiscord | <tandy> https://internet-of-tomohiro.netlify.app/nim/gdb.en.html |
17:59:03 | FromDiscord | <tandy> i found this |
17:59:53 | FromDiscord | <enthus1ast> yes |
18:03:30 | FromDiscord | <enthus1ast> yeah at least in this example it picks it up easily |
18:03:31 | FromDiscord | <enthus1ast> https://play.nim-lang.org/#ix=3GhH |
18:04:43 | FromDiscord | <tandy> `/home/tandy/.nimble/tools/nim-gdb.py: No such file or directory.` |
18:04:52 | FromDiscord | <tandy> when i run nim-gdb on the compiled file |
18:05:47 | FromDiscord | <enthus1ast> imho you can try it withouth the nim specific scripts |
18:06:15 | FromDiscord | <enthus1ast> should be enough to find it |
18:06:25 | FromDiscord | <enthus1ast> but you can always source the correct python script |
18:06:44 | FromDiscord | <tandy> `nim c --debugger:native tests/test.nim` just compiles and does nothing |
18:06:56 | FromDiscord | <enthus1ast> yes |
18:07:04 | FromDiscord | <enthus1ast> please have a look at my example |
18:07:09 | FromDiscord | <enthus1ast> you must run it with gdb |
18:07:15 | FromDiscord | <enthus1ast> gdb test.exe |
18:07:37 | FromDiscord | <tandy> yes i try that here |
18:07:41 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3GhI |
18:07:51 | FromDiscord | <tandy> oh il try this |
18:08:26 | FromDiscord | <enthus1ast> then just run you programm until it crashes with\:↵r |
18:08:48 | FromDiscord | <enthus1ast> r{enter} |
18:10:10 | FromDiscord | <enthus1ast> imho the nim-gdb.py stuff is just to print variables better |
18:10:25 | FromDiscord | <enthus1ast> but you should be able to see the line where it crashes even withouth this |
18:15:53 | FromDiscord | <tandy> hmm its kinda useful |
18:15:57 | FromDiscord | <tandy> but yea ur right |
18:16:09 | FromDiscord | <tandy> i dont understnad why the var is uninitialised tho |
18:16:57 | FromDiscord | <enthus1ast> can you share code? |
18:17:14 | FromDiscord | <tandy> yeah its here |
18:18:53 | FromDiscord | <tandy> https://github.com/tandy-1000/minmax-checkers just pushed |
18:19:07 | FromDiscord | <tandy> the error is in `minimax` |
18:19:15 | FromDiscord | <tandy> im trying to make the tests work |
18:19:26 | FromDiscord | <tandy> you can run `nimble test` |
18:19:55 | FromDiscord | <enthus1ast> on which line it crashes? |
18:20:09 | FromDiscord | <enthus1ast> maybe send a github link |
18:20:44 | FromDiscord | <tandy> https://github.com/tandy-1000/minmax-checkers/blob/cb3c9ce6f7144505c0fcdb26b3bbc40caac052a8/src/classes.nim#L408 |
18:21:11 | FromDiscord | <tandy> i think the reason could be that minimax doesnt return any move in certain ocasions? |
18:21:57 | FromDiscord | <enthus1ast> oh you use some oop macros |
18:22:18 | FromDiscord | <tandy> yep |
18:23:24 | FromDiscord | <enthus1ast> if it can, and if it does in this case, this might be your error |
18:23:40 | FromDiscord | <tandy> i wonder how i can find that out |
18:24:07 | FromDiscord | <enthus1ast> echo "here"USE THE MOVE↵echo "there"\:D |
18:24:46 | FromDiscord | <tandy> oh i fixed it lol |
18:27:29 | FromDiscord | <tandy> ty ! minimax still maxes debug call depth so i got more work to do lol |
18:33:41 | * | lumo_e quit (Ping timeout: 245 seconds) |
18:59:18 | FromDiscord | <IsaacPaul> In reply to @fishcakenine "I am trying to": @fishcakenine .. not sure how to ping people on irc or gitter.. but hopefully this works lol. Did you ever finish your wgpu-native wrapper? |
19:03:01 | * | Figworm quit (Quit: Figworm) |
19:03:57 | * | krux02 joined #nim |
19:20:23 | * | src joined #nim |
19:23:34 | * | lumo_e joined #nim |
19:29:30 | * | src quit (Read error: Connection reset by peer) |
19:29:54 | * | src joined #nim |
19:30:08 | * | src quit (Remote host closed the connection) |
20:37:47 | * | lumo_e quit (Ping timeout: 250 seconds) |
21:01:41 | arkanoid | am I the only one receiving http 500 error here? https://github.com/yglukhov/nimpy |
21:02:11 | FromDiscord | <enthus1ast> nope |
21:02:12 | FromDiscord | <enthus1ast> 500 |
21:02:23 | FromDiscord | <enthus1ast> for me aswell |
21:02:48 | arkanoid | yglukhov hacked github with the power of nimpy |
21:04:04 | arkanoid | oh well, is massive https://www.githubstatus.com/ |
21:10:33 | arkanoid | do you tend to "import" or "include" the tested module X into your test_X.nim ? |
21:33:30 | arkanoid | I'm realizing how many different things in the world are named nim* nimble* nimpy* thanks to github being down |
21:36:08 | FromDiscord | <evoalg> regarding deepcopy which was mentioned above, when would I use that in Nim instead of normal copy ... I though containers in Nim were copied by value anyway? |
21:36:28 | arkanoid | what's the equivalent of "--app:lib" in .nimble file? |
21:39:07 | FromDiscord | <pyautogui> Github appears to be down for everybody. Twitter is memeing like crazy about it. Kind of sucks. |
21:39:13 | FromDiscord | <Recruit_main707> arkanoid: i think there is a way but i dont remember it right now, you can use a .nims file too and do `switch("app", "lib")`, lemme search and see if i can find a way to do it in the nimble file |
21:40:12 | FromDiscord | <Recruit_main707> I think there isnt |
21:40:42 | FromDiscord | <Recruit_main707> but what i said will work |
21:41:31 | FromDiscord | <Recruit_main707> so if you have a a `src/main.nim` file, add a `src/main.nims` file with that switch |
21:44:25 | arkanoid | yes it works, thanks |
21:49:30 | * | xet7 quit (Remote host closed the connection) |
21:50:34 | * | xet7 joined #nim |
21:51:48 | FromDiscord | <pyautogui> GH is back up. |
21:53:27 | arkanoid | yes |
21:54:45 | arkanoid | well, almost |
22:08:34 | * | src joined #nim |
22:11:53 | * | src quit (Client Quit) |
22:14:48 | * | perro joined #nim |
22:26:28 | * | xet7 quit (Quit: Leaving) |
22:26:52 | * | xet7 joined #nim |
22:36:57 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3Giy |
22:37:03 | FromDiscord | <codic> It seems just calling self.focused.isSome causes it to crash |
22:37:15 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3Giz |
22:37:20 | FromDiscord | <codic> 734 is the last line in the code snippet I posted |
22:37:26 | FromDiscord | <codic> Where is -1 coming from |
22:38:14 | FromDiscord | <codic> Oh nvm the trace is wrong |
22:49:22 | FromDiscord | <Varriount> What's the current state of CPS (continuation-passing style) for asynchronous programming in Nim? |
22:50:20 | FromDiscord | <Elegantbeef> The CPS folks have a bunch of demo projects, so it works 😀 |
22:53:17 | FromDiscord | <codic> Fixed the issue but is the trace pointing to the wrong line a compiler bug? |
22:54:12 | FromDiscord | <konsumlamm> In reply to @Varriount "What's the current state": https://github.com/nim-works/cps |
22:54:19 | FromDiscord | <konsumlamm> the readme says it's beta quality |
22:58:48 | * | k0ta joined #nim |
23:16:17 | FromDiscord | <evoalg> @ElegantBeef I'm noob and naive, but is there are way for Nim to completely change the default way slices work, so a slice would return an iterator unless a copy is needed? (a copy would be needed for `let a = "hello"[1..3]`) but it would return an iterator when needed, and also `for i, x in` would work? I'm trying to understand if Nim didn't do some of the iterators early on when it was being created and so iterators need to be "bolted on |
23:17:57 | FromDiscord | <Elegantbeef> Well i mean that's what it's supposed to do, the issue is that nim doesnt dispatch on return types |
23:18:47 | * | Onionhammer quit (Ping timeout: 250 seconds) |
23:18:49 | FromDiscord | <Elegantbeef> so when you do `iterator [](a: openarray, rng: slice[int]): T` and `iterator [](a: openarray, rng: slice[int]): (int, T)` it cannot disambiguate the two iterators |
23:19:35 | FromDiscord | <Elegantbeef> so in the case of the fun `for i, x in "hello"[0..^2]` it calls the `[]` iterator and since we can only have one it cannot be used with pairs |
23:19:36 | FromDiscord | <Varriount> In reply to @evoalg "<@!145405730571288577> I'm noob and": ` |
23:20:43 | FromDiscord | <Elegantbeef> The only issue we have with my package is that `for i, x in "hello"[0..^2]` calls my `[]` iterator that doesnt return a tuple, which means we have an error as we're attempting to unpack a T into two values |
23:21:14 | FromDiscord | <Elegantbeef> And actually your example is wrong, since a copy is only needed if you mutate the value |
23:21:44 | FromDiscord | <Elegantbeef> So you can do a reference aslong as you know the variable stays within scope of another and doesnt mutate |
23:22:01 | FromDiscord | <Elegantbeef> But that's an optimization |
23:22:22 | FromDiscord | <Elegantbeef> Hopefully that makes sense |
23:23:09 | FromDiscord | <Elegantbeef> Like i said i can remove the ambiguity 100% but then the ergonomics get shit |
23:23:30 | FromDiscord | <Elegantbeef> like `for i, x in "hello"[&0..^2]` solves the problem |
23:23:51 | FromDiscord | <Elegantbeef> But now we have to use `&` for pairs |
23:24:56 | FromDiscord | <evoalg> it does thank you! ... apart from the last bit ... so the assignment `a = "hello"[1..3]` could have an iterator assigned to it? ... so that would be an iterator not a range? I'm a bit confused about assigning a slice to a variable when it's an iterator? |
23:25:16 | FromDiscord | <Elegantbeef> Only closure iterators are assignable to variables |
23:25:23 | FromDiscord | <Elegantbeef> So it'd never call the iterator since it's not a closure |
23:25:47 | FromDiscord | <Elegantbeef> Only in `for` context is an iterator preferred over a function |
23:25:57 | FromDiscord | <Elegantbeef> Which is what slicerator relies upon |
23:26:03 | FromDiscord | <evoalg> ahh |
23:27:58 | FromDiscord | <Elegantbeef> Alternatively we could do `for i, x in "hello"[&(0..^2)]` 😛 |
23:28:30 | FromDiscord | <Elegantbeef> I dont know we need something to nicely disambiguate the pairs from the normal iterator |
23:28:58 | FromDiscord | <Elegantbeef> Cause i really dont care that `for i, x in "hello"[0..^2]` errors, cause it's bad anyway |
23:29:28 | FromDiscord | <evoalg> Thank you, I understand the problem now ... I don't know what the answer is, but as least I understand the problem! |
23:29:53 | FromDiscord | <Elegantbeef> Yea i mean it's really just a question of do we want to use distincts or `pairs(range)` |
23:29:54 | FromDiscord | <evoalg> oh that's bad? ... how would you do `for i, x in` instead? |
23:30:08 | FromDiscord | <Elegantbeef> Well it's bad cause it relies on sequence slicing |
23:30:43 | FromDiscord | <Elegantbeef> So if you have a large string and you do that to it you're needlessly taking more ram and slowing the program |
23:31:24 | FromDiscord | <Elegantbeef> The iteration isnt the issue as much as the fact it's abusing slicing and implicit pairs like i mentioned yesterday |
23:31:27 | FromDiscord | <evoalg> "sequence slicing" is making a copy? |
23:31:34 | FromDiscord | <Elegantbeef> Yep |
23:31:59 | FromDiscord | <Elegantbeef> `for i, x in "hello"[0..^2]` is turned into `for i, x in "hell".pairs` |
23:32:07 | FromDiscord | <Elegantbeef> And creation of `"hell"` is an allocation |
23:32:34 | FromDiscord | <evoalg> that's hell |
23:35:00 | meowray | `create(T)` does not set m_type so `T of BaseOfT` does not work. How to set m_type? |
23:35:53 | meowray | `var a = create(T); a = T()` sets m_type but the redundant assignment looks bad |
23:36:40 | FromDiscord | <Elegantbeef> do you have a full example? |
23:37:03 | FromDiscord | <Ricky Spanish> how do you define an object that has a string array as a field? it seems to be unhappy when i use []string, seq[string] works but not really what i was aiming for |
23:37:32 | FromDiscord | <Elegantbeef> Arrays in nim are dependent types so it's `field: array[Length, string]` |
23:37:50 | FromDiscord | <Ricky Spanish> ah ok thanks for explaining @ElegantBeef |
23:37:54 | FromDiscord | <Elegantbeef> If you do not know the length at compile time you do not use an array |
23:38:00 | FromDiscord | <Elegantbeef> Or you do but make it larger than you'll need |
23:40:14 | FromDiscord | <MaskRay (Fangrui Song)> sent a code paste, see https://play.nim-lang.org/#ix=3GiP |
23:41:38 | * | src joined #nim |
23:41:51 | * | src quit (Remote host closed the connection) |
23:42:55 | FromDiscord | <Elegantbeef> You've jumped three programs in 10 seconds 😛 |
23:43:14 | FromDiscord | <Elegantbeef> Is there a reason you're using `create` over a reference? |
23:43:54 | FromDiscord | <@MaskRay:matrix.org> (I realized that IRC is bad for pasting program... Then I thought I might try Gitter, but finalized I realized most people seem to use Matrix... So I dug up my app.element.io account which has been used for a while..) |
23:44:06 | FromDiscord | <Elegantbeef> Well gitter is matrix now so ya 😛 |
23:44:55 | FromDiscord | <@MaskRay:matrix.org> I want to do raw memory management without GC, so I want to avoid `ref`. I still need `instanceof`, though... |
23:45:10 | FromDiscord | <Elegantbeef> Ah i see, was uncertain what you were after so thought i'd ask |
23:45:29 | FromDiscord | <Elegantbeef> I assume there is lacking type information from `create` since it just dumbly 0's memory |
23:46:53 | FromDiscord | <@MaskRay:matrix.org> Yes. According to `nim c --gc:arc -d:debug --debugger:on a; rr record ./a; rr replay -d cgdb`, `create` allocated memory does not have valid `m_type`. `b[] = InputSection()` will set `m_type`, but the redundant assignment is bad. |
23:47:05 | * | PMunch quit (Quit: leaving) |
23:47:18 | FromDiscord | <Elegantbeef> Might be the way to do it |
23:47:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GiQ |
23:47:52 | FromDiscord | <Elegantbeef> You of course can do `createU` in this case since you're setting it after |
23:48:06 | FromDiscord | <Elegantbeef> So it shouldnt be any more costly, or negligibly more costly |
23:48:39 | FromDiscord | <Elegantbeef> Actually that caching is useless |
23:48:40 | FromDiscord | <Elegantbeef> I'm dumb |
23:49:04 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GiS |
23:50:40 | FromDiscord | <@MaskRay:matrix.org> sent a code paste, see https://play.nim-lang.org/#ix=3GiT |
23:50:49 | FromDiscord | <Elegantbeef> Yea that also works, if you never want to pass an expression |
23:50:54 | FromDiscord | <pmunch> Generally a good idea to do the caching though [Elegantbeef](https://matrix.to/#/@elegantbeef:matrix.org) |
23:51:05 | FromDiscord | <Elegantbeef> Well it doesnt matter in this case |
23:51:24 | FromDiscord | <Elegantbeef> `typeof(default)` is a compile time evaluated statement, and you only use default after i t |
23:51:26 | FromDiscord | <pmunch> Sure, but it's good that you're showing it to people |
23:51:35 | FromDiscord | <Elegantbeef> Ah yes |
23:53:47 | FromDiscord | <Elegantbeef> @evoalg\: if you ever want to play with "how bad is it really" this is fun https://play.nim-lang.org/#ix=3GiW |
23:54:01 | FromDiscord | <Elegantbeef> Though slicerator was dumbly using `toOpenArray` which slowed it down like 5ns |
23:54:23 | FromDiscord | <Elegantbeef> But naive is like 3 times slower than slicerator/manual |
23:54:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3GiX |
23:56:27 | FromDiscord | <Elegantbeef> This of course gets worse the larger the sequence is |