00:03:36 | FromDiscord | <TryAngle> hmmm so I missunderstood concepts in the first place maybe? |
00:03:58 | FromDiscord | <TryAngle> so they act as restrictions what types can be used but not replace the procs |
00:04:00 | FromDiscord | <theangryepicbanana> not really it's just that they can't be as "specific" as you think they can |
00:04:04 | FromDiscord | <theangryepicbanana> (edit) "really" => "really," |
00:04:28 | FromDiscord | <theangryepicbanana> so when you call `operate` in `addTest`, it's still going to test both overloads of `operate` |
00:05:42 | FromDiscord | <TryAngle> I thought at first they were similar to traits from Rust, which override the type function with the trait function in that scope |
00:05:50 | FromDiscord | <TryAngle> but that seems to not be the case |
00:05:52 | FromDiscord | <theangryepicbanana> nope |
00:06:00 | FromDiscord | <theangryepicbanana> concepts are compile-time only |
00:06:31 | FromDiscord | <TryAngle> I thought the rust were compile time also 🤔 ↵but I'm unsure |
00:06:38 | FromDiscord | <theangryepicbanana> well like |
00:07:07 | FromDiscord | <TryAngle> bc they "zero cost generics" hype everwhere, idk haven't looked into compiler / runtime |
00:07:17 | FromDiscord | <theangryepicbanana> instead of `operate` being implemented for every valid type for `Add`, it's just a generic function that takes 2 arguments of type `Add` |
00:07:18 | FromDiscord | <Elegantbeef> You can get that kind of behaviour using generic logic |
00:07:18 | FromDiscord | <Elegantbeef> Here i'll show how in a second |
00:07:25 | FromDiscord | <theangryepicbanana> oh yeah was about to mention that |
00:07:34 | FromDiscord | <TryAngle> o_O |
00:07:36 | FromDiscord | <TryAngle> now i'm curious |
00:07:51 | * | Guest2 quit (Quit: Client closed) |
00:16:00 | FromDiscord | <Elegantbeef> Shit my example didnt work 😀 |
00:17:42 | FromDiscord | <TryAngle> thanks for trying at least 🥲 |
00:17:51 | FromDiscord | <Elegantbeef> Eh i'll get it working |
00:24:58 | FromDiscord | <TryAngle> that would be amazing but you really don't have to 🥺 |
00:26:10 | FromDiscord | <Elegantbeef> Too bad! |
00:28:08 | FromDiscord | <Elegantbeef> Lol never mind even with mixin'd symbols the first instantiation is used |
00:28:54 | FromDiscord | <TryAngle> In reply to @Elegantbeef "Lol never mind even": what are mixin'd symbols 😃 ? |
00:29:13 | FromDiscord | <ynfle (ynfle)> When is one supposed to be used over the other? |
00:29:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3INV |
00:29:30 | FromDiscord | <Elegantbeef> `mixin` forces the symbol `funStuff` to be chosen at instantiation |
00:30:04 | FromDiscord | <ynfle (ynfle)> In the above `operate` example how are the 2 function differentiated? |
00:30:44 | FromDiscord | <TryAngle> In reply to @ynfle (ynfle) "In the above `operate`": they are not sadly thats why I'm asking her 😔 |
00:31:07 | FromDiscord | <Elegantbeef> Annoyingly you cannot have per module generics it seems |
00:31:29 | FromDiscord | <Elegantbeef> I wonder if there is a way to instantiate a new generic |
00:31:51 | FromDiscord | <ynfle (ynfle)> What would you want to happen?↵(@TryAngle) |
00:32:33 | FromDiscord | <Elegantbeef> What are you after anyway try, i read a bit but dont follow |
00:32:40 | FromDiscord | <TryAngle> hmmm in worst case I can just not be generic over operators 🤔 |
00:33:05 | FromDiscord | <TryAngle> basically implement parts of abstract algebra as generic as possible |
00:33:10 | FromDiscord | <ynfle (ynfle)> What are you trying to do? |
00:33:36 | FromDiscord | <ynfle (ynfle)> But if you call `operate(1, 2)` how do you know which operation you want to use? |
00:34:48 | FromDiscord | <ynfle (ynfle)> Can you give an example? |
00:35:07 | FromDiscord | <TryAngle> In reply to @ynfle (ynfle) "But if you call": I've written somewhere up that I misunderstood nim's concepts↵I thought they were like Rust Traits that overwrite the function in the scope where the trait is used |
00:35:42 | FromDiscord | <Elegantbeef> I think they probably should |
00:36:12 | FromDiscord | <ynfle (ynfle)> Ok↵(@TryAngle) |
00:36:23 | FromDiscord | <ynfle (ynfle)> Did you resolve what you wanted to get done? |
00:36:51 | FromDiscord | <Elegantbeef> you can reason that if you have a concept defined and the mixin'd symbols do not match, a new instantiation probably should be made |
00:36:52 | FromDiscord | <ynfle (ynfle)> I don't know rust so well |
00:37:08 | FromDiscord | <ynfle (ynfle)> Do you still want help doing something in nim? |
00:37:29 | FromDiscord | <Elegantbeef> Damn it try i now have to toy with this idea and see what breaks |
00:37:37 | FromDiscord | <Elegantbeef> Cause i think what you're suggesting is the "right" thing |
00:38:41 | FromDiscord | <TryAngle> In reply to @ynfle (ynfle) "I don't know rust": I will try to compact the Rust code I had somewhere.. just give me a sec |
00:39:41 | * | noeontheend joined #nim |
00:40:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3INZ |
00:42:31 | FromDiscord | <Elegantbeef> It's of course not since the `doThing(a, b) == 340` doesnt instantiate a new `doThing` for the scope of moduleB |
00:44:26 | FromDiscord | <Elegantbeef> Hmmm if we just make that `proc doThing` a `template doThing` this does work as intended |
00:44:28 | FromDiscord | <Elegantbeef> So i guess that's my suggestion, use templates for the procs that depend on scope |
00:44:46 | FromDiscord | <Elegantbeef> See try there was a benefit for me ramming my head in the wall for you 😛 |
00:45:44 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3IO0 |
00:46:12 | FromDiscord | <TryAngle> (edit) "https://play.nim-lang.org/#ix=3IO0" => "https://play.nim-lang.org/#ix=3IO1" |
00:46:17 | FromDiscord | <Elegantbeef> So yea we'd use distincts here |
00:48:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IO2 |
00:49:18 | FromDiscord | <Elegantbeef> I dont think there is much reason to use concepts for this, since you're just wanting distinct behaviour for the same type |
00:49:57 | FromDiscord | <TryAngle> I only used the same type here to not make the example too complicated for somebody who doesn't write Rust 😅 |
00:50:06 | FromDiscord | <ElegantBeef> Oh |
00:51:00 | FromDiscord | <Elegantbeef> Anyway you can use the concept + templates instead of procs to get this behaviour |
00:54:06 | FromDiscord | <TryAngle> In reply to @Elegantbeef "Anyway you can use": may you give a small example please? |
00:54:16 | FromDiscord | <Elegantbeef> Same as my example above |
00:54:23 | FromDiscord | <Elegantbeef> But here |
00:54:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IO4 |
00:54:49 | FromDiscord | <Elegantbeef> There we go |
00:55:19 | FromDiscord | <Elegantbeef> Scope is now taken into account on call of `doThing` and `+` is bound to whatever is in scope instead of the first isntantiation of `doThing` thanks to the fact it's a template instead of proc |
00:55:30 | FromDiscord | <Elegantbeef> So now `+` is overridable based of scope |
00:56:32 | FromDiscord | <Elegantbeef> That atleast allows the overidable behaviour, the disallowing operators is more tricky |
00:58:08 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3IO6 |
00:58:53 | FromDiscord | <Elegantbeef> Isnt this what you wanted scope taken into account? |
00:58:57 | * | noeontheend quit (Ping timeout: 240 seconds) |
00:59:26 | NimEventer | New thread by Jocker: Pythons None in Nim, see https://forum.nim-lang.org/t/8725 |
01:03:14 | FromDiscord | <TryAngle> In reply to @Elegantbeef "Isnt this what you": yeah but I need to combine Monoid<Additive> and Monoid<Multiplicative> so scoping is not really an option for that :/ |
01:03:27 | FromDiscord | <TryAngle> (edit) "In reply to @Elegantbeef "Isnt this what you": yeah but I need to combine Monoid<Additive> and Monoid<Multiplicative> ... so" added "for other purposes" |
01:03:42 | FromDiscord | <TryAngle> (edit) "In reply to @Elegantbeef "Isnt this what you": yeah but I need to combine Monoid<Additive> and Monoid<Multiplicative> ... for" added "(not directly but in hirarchy)" |
01:04:49 | FromDiscord | <ynfle (ynfle)> In this rust code, is it missing a `>` in each of the test `fn`s?↵(@TryAngle) |
01:05:13 | FromDiscord | <TryAngle> In reply to @ynfle (ynfle) "In this rust code,": yes it does miss them |
01:05:26 | FromDiscord | <ynfle (ynfle)> Ok↵(@TryAngle) |
01:05:29 | FromDiscord | <TryAngle> I typed it in discord and forgot them in the hurry 😅 |
01:05:43 | FromDiscord | <ynfle (ynfle)> What is the purpose of the Monoid part? |
01:06:19 | FromDiscord | <ynfle (ynfle)> Is this not sufficient? https://play.nim-lang.org/#ix=3IOc |
01:07:00 | FromDiscord | <TryAngle> In reply to @ynfle (ynfle) "What is the purpose": this is proabably what I resort to now |
01:07:17 | * | noeontheend joined #nim |
01:08:04 | FromDiscord | <TryAngle> in 99% of having the operator generic is not needed anyways↵it's just like knowing it's not generic in the codebase 😱 |
01:08:13 | FromDiscord | <TryAngle> (edit) "in 99% of ... having" added "cases" |
01:09:38 | FromDiscord | <TryAngle> @ElegantBeef still big thanks for coming up with an interesting solution, didn't know something like mixin were a thing, will definitely use something like that for another thing I have in my head already 🤔 😀 |
01:12:27 | FromDiscord | <Fish-Face> is there any documentation for `nimly` that isn't just the two examples in the readme 😦 |
01:12:42 | FromDiscord | <ynfle (ynfle)> @TryAngle https://nim-lang.org/docs/manual_experimental.html#concepts Talks about monoids |
01:13:50 | FromDiscord | <TryAngle> In reply to @ynfle (ynfle) "@TryAngle https://nim-lang.org/docs/manual_experime": haha I know about that example but sadly this is just a little snippet :/ |
01:14:00 | FromDiscord | <ynfle (ynfle)> Ya↵(@TryAngle) |
01:14:08 | FromDiscord | <ynfle (ynfle)> It doesn't show a monoid generic concept |
01:18:32 | FromDiscord | <exelotl> huh https://play.nim-lang.org/#ix=3IOe |
01:18:56 | FromDiscord | <exelotl> this prints `0` on Nim 1.6 but `6` on Nim 1.4.8 |
01:19:36 | FromDiscord | <exelotl> which is correct? |
01:21:52 | FromDiscord | <ynfle (ynfle)> The weird part is it still prints hello on 1.6.0 |
01:22:39 | FromDiscord | <TryAngle> I mean len 0 should be correct in the context of `c` no? |
01:22:47 | FromDiscord | <Elegantbeef> O is right |
01:22:55 | FromDiscord | <ynfle (ynfle)> Right. But why should it print? |
01:23:13 | FromDiscord | <Elegantbeef> 0 even |
01:23:39 | FromDiscord | <TryAngle> strings are usually null terminated in c↵e.g the "NULL" ascii char is the end of the string |
01:23:45 | FromDiscord | <Elegantbeef> Nah we're wrong |
01:23:55 | FromDiscord | <Elegantbeef> This is a global const Cstring, which is probably generated as an array |
01:24:04 | FromDiscord | <TryAngle> (edit) "string" => "string↵the "NULL" ascii char is `\0`" |
01:24:21 | FromDiscord | <Elegantbeef> make it `let` and do `echo s` or `echo s.len` and it'll properly behave |
01:24:55 | FromDiscord | <Elegantbeef> Since it's a constant cstring it's emitted as `['\0', 'h', 'e', 'l', 'l', 'o']` |
01:25:05 | FromDiscord | <Elegantbeef> So i'd argue 1.6 is right |
01:26:38 | FromDiscord | <Elegantbeef> To add to this a `cstring` is a ptr to a character and you cannot have a ptr to a constant since they're pasted into call site |
01:27:04 | FromDiscord | <Elegantbeef> So very much 1.6 is the "right" behaviour to me, would like to hear any counter points anyone has though 😀 |
01:28:04 | FromDiscord | <TryAngle> this like this are litereally the reason why I was searching for other langs and found Rust & Nim XD |
01:28:14 | FromDiscord | <TryAngle> (edit) "this" => "things" |
01:28:46 | FromDiscord | <Elegantbeef> Does this mean you run screaming from Nim now? 😛 |
01:32:12 | FromDiscord | <TryAngle> What do you mean 😳? |
01:32:42 | FromDiscord | <Elegantbeef> You said things like that is why you were searching for other languages, and Nim has stuff like that 😛 |
01:32:47 | FromDiscord | <Elegantbeef> It's mostly a joke |
01:36:44 | FromDiscord | <TryAngle> sent a long message, see http://ix.io/3IOg |
01:37:45 | FromDiscord | <Elegantbeef> Lack of restrictions? |
01:38:37 | * | noeontheend quit (Ping timeout: 240 seconds) |
01:40:13 | FromDiscord | <TryAngle> In reply to @Elegantbeef "Lack of restrictions?": I think this is more of a opinion thing so idk ↵but that when using Concepts only the procs supplied by the concept are allowed. |
01:41:19 | FromDiscord | <TryAngle> If I want all why not just type the type directly 🤔 |
01:42:24 | FromDiscord | <TryAngle> + they are experimental anyways |
01:42:52 | FromDiscord | <Elegantbeef> Eh they're "experimental" |
01:43:37 | FromDiscord | <Elegantbeef> Hmm with the new concept style, this safety could be enforced with a macro |
01:43:59 | FromDiscord | <Elegantbeef> God damn it quit enticing me with fun |
01:46:47 | FromDiscord | <TryAngle> Haha↵Just did nothing but writing in Rust last year but figured many things are ugly to implement so now I'm trying to write things in Nim but I'm still used to the "rust-way" |
01:47:04 | FromDiscord | <TryAngle> (edit) "Haha↵Just did nothing but writing in Rust last year but figured many things are ugly to implement so now I'm trying to write things in Nim but I'm still used to the "rust-way" ... " added "sadly" |
02:03:03 | FromDiscord | <Avionix> I've got a question about the `std/times` module and was wondering if anyone has any idea what's wrong. |
02:03:04 | FromDiscord | <Avionix> https://play.nim-lang.org/#ix=3IOq |
02:03:19 | FromDiscord | <Avionix> Here's an example. |
02:03:24 | FromDiscord | <Elegantbeef> @TryAngle\: here is what you've got me to make 😛 https://play.nim-lang.org/#ix=3IOr |
02:05:39 | FromDiscord | <Avionix> Basically, I'm converting a string containing a unix epoch into a `Time` object. For some reason, the resulting `Time` object doesn't equal the one I used to actually make the unix epoch string. |
02:06:04 | FromDiscord | <Elegantbeef> It seems to be missing nanoseconds |
02:06:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IOs |
02:07:13 | FromDiscord | <Avionix> Oh. That's precisely it, thank you! |
02:07:15 | FromDiscord | <Rika> Unix epoch usually refers to the second precise epoch |
02:07:29 | FromDiscord | <Elegantbeef> From unix float almost works but still isnt right |
02:08:00 | FromDiscord | <Elegantbeef> If you want to do time \<-\> string you'll probably have to use `formatTime` and `parseTime` using your own output |
02:08:21 | FromDiscord | <Elegantbeef> This way you can get the generally uncared about values |
02:08:51 | FromDiscord | <Avionix> I think I might do that. Thanks for your help! |
02:08:57 | FromDiscord | <Elegantbeef> Alternatively you can always just do `proc sameTime(a, b: Time): bool = (a - b) < initDuration(seconds = 0)` |
02:09:06 | FromDiscord | <Elegantbeef> Sorry `seconds = 1` |
02:39:17 | * | neurocyte0132889 quit (Ping timeout: 240 seconds) |
03:09:55 | * | src quit (Quit: Leaving) |
03:36:17 | * | noeontheend joined #nim |
03:40:37 | * | arkurious quit (Quit: Leaving) |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:30 | * | supakeen joined #nim |
04:19:47 | FromDiscord | <valerga> is there a difference between `echo x, y` vs `echo x & y`? |
04:20:20 | FromDiscord | <valerga> oh ok it's not casted to string for instance, in the second one |
04:22:22 | FromDiscord | <Elegantbeef> Indeed as you've noticed `echo(x, y)` is `echo($x, $y)` but the other expects two types that have `&` implemented |
04:23:27 | FromDiscord | <Rika> same-ish difference with python's print(x,y) and print(x+y) |
04:36:12 | FromDiscord | <valerga> expects two types? or one type, a string? |
04:36:41 | FromDiscord | <Elegantbeef> Well it's looking for `&(typeof(x), typeof(y)` |
04:37:12 | FromDiscord | <valerga> but isn't that &'s 'responsibility'? |
04:37:22 | FromDiscord | <Elegantbeef> That's where the error is from |
04:37:29 | FromDiscord | <valerga> ah ok |
04:38:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IOL |
05:01:44 | NimEventer | New Nimble package! opensimplexnoise - A pure nim port of the open simplex noise algorithm from Kurt Spencer, see https://github.com/betofloresbaca/nim-opensimplexnoise |
05:04:12 | FromDiscord | <Rika> nice |
05:19:46 | NimEventer | New Nimble package! prettystr - Small library for working with strings, see https://github.com/prettybauble/prettystr |
06:13:17 | * | noeontheend quit (Ping timeout: 240 seconds) |
06:55:29 | FromDiscord | <baalajimaestro> Hi, is there any way i could run osproc with async. I am trying to do a telegram bot, and dont want the execution to block others from messaging it |
06:55:51 | FromDiscord | <baalajimaestro> I did find this, https://github.com/cheatfate/asynctools/blob/master/asynctools/asyncproc.nim↵↵But not sure how to use |
06:56:40 | FromDiscord | <baalajimaestro> I nimble installed the necessary package, and imported asynctools.asyncproc, but asyncproc.execProcess doesnt seem to work out |
06:59:47 | FromDiscord | <Elegantbeef> In what way didnt it work out? |
07:11:17 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3IPa |
07:13:02 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IPb |
07:13:03 | FromDiscord | <that_dude> And I'm hesitant to use macrocache because I don't understand how it works. I'd like to make it myself |
07:13:32 | FromDiscord | <that_dude> Damn |
07:13:39 | FromDiscord | <that_dude> That did seem to fix it |
07:13:52 | FromDiscord | <Elegantbeef> Well yea you're putting the string there instead of ast now |
07:15:29 | FromDiscord | <baalajimaestro> it just said undeclared identifier asyncproc, when there is an import right a line above |
07:15:41 | FromDiscord | <Elegantbeef> full code? |
07:16:35 | FromDiscord | <Elegantbeef> You cant really implement macro cache thanks to the magic it implements but you can get close |
07:17:27 | FromDiscord | <that_dude> In reply to @Elegantbeef "Well yea you're putting": I'm confused. Isn't `proc_name` holding a string already? |
07:17:58 | FromDiscord | <that_dude> I thought quote do is a perfect copy and paste |
07:18:05 | FromDiscord | <that_dude> ish |
07:20:25 | FromDiscord | <Elegantbeef> Well it puts in a symbol to `proc_name` which is a Nim AST node |
07:20:42 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3IPe look at the output here https://play.nim-lang.org/#ix=3IPe |
07:20:43 | FromDiscord | <Elegantbeef> Damn it |
07:20:47 | FromDiscord | <Elegantbeef> Double paste |
07:21:02 | FromDiscord | <baalajimaestro> https://paste.baalajimaestro.me/6IloRO |
07:21:10 | FromDiscord | <baalajimaestro> this is what i tried |
07:21:33 | FromDiscord | <Elegantbeef> Oh python imports |
07:21:39 | FromDiscord | <Elegantbeef> my favourite |
07:22:13 | FromDiscord | <baalajimaestro> well, i am new to nim, pretty much have been using python earlier |
07:22:16 | FromDiscord | <Elegantbeef> Does it behave the same without it? |
07:22:39 | FromDiscord | <baalajimaestro> without what exactly? |
07:23:07 | FromDiscord | <Elegantbeef> instead of `from x in y` do `import x` |
07:23:17 | FromDiscord | <baalajimaestro> hmmm ill try that |
07:24:20 | FromDiscord | <baalajimaestro> oh that worked |
07:24:37 | FromDiscord | <that_dude> Does sym only bind to procs or something? I thought it does to all variables/entities |
07:24:55 | FromDiscord | <baalajimaestro> idk how that changes anything, isnt it supposed to like slim down whats imported inside? |
07:24:55 | FromDiscord | <Elegantbeef> `from x import y` doesnt make a `y.x` work it imports only `asynproc` |
07:25:09 | FromDiscord | <Elegantbeef> `import asynctools` imports everything exported |
07:25:19 | FromDiscord | <baalajimaestro> thats something different from python indeed |
07:26:12 | FromDiscord | <Elegantbeef> you want `import asynctools as asyncproc` but life is easier just doing `import asynctools` |
07:27:07 | FromDiscord | <Elegantbeef> The issue is that doing the quote like that will bind the sym of the variable that was made inside the macro, not the value it holds↵(@that_dude) |
07:27:59 | FromDiscord | <Elegantbeef> In nim baalaji the convention is to just do `import x` and bring everything since it makes life easier |
07:28:23 | FromDiscord | <Elegantbeef> Selective imports dont make much sense imo, but your milage may vary |
07:31:05 | FromDiscord | <that_dude> So basically when done it's referencing a var that doesn't exist anymore? I kinda thought macros kinda just paste selves into the code like a template and then run the pasted code. Does it instead work closer to the way a proc works where it takes code in and then after manipulations spits out new code to replace the old one? |
07:31:42 | FromDiscord | <Elegantbeef> Macros are nothing like templates |
07:31:56 | FromDiscord | <baalajimaestro> ah okay got it |
07:32:00 | FromDiscord | <Elegantbeef> They take what you give them and run on the vm with the input and return the output |
07:32:43 | FromDiscord | <baalajimaestro> i was thinking in the python route, where you can import a specific function and make your code run faster just coz you werent importing 1000 other randoms you never need |
07:32:49 | FromDiscord | <Elegantbeef> Templates are code substitution and dont require the vm, they take the AST from the template replace the symbols and expand |
07:32:59 | FromDiscord | <Elegantbeef> Yea Nim is compiled so you dont slow down the code with all the imports |
07:33:07 | FromDiscord | <Elegantbeef> It statically knows what you use and doesnt include anything else |
07:33:28 | FromDiscord | <that_dude> I understand. I think. I took them to be templates that can use code to generate more custom ast's |
07:33:32 | FromDiscord | <Elegantbeef> Python has to check what a function is at runtime |
07:33:32 | FromDiscord | <baalajimaestro> similar to C's LTO if i am making a correct reference? |
07:33:52 | FromDiscord | <Elegantbeef> LTO is different, we're talking about dead code elimination really |
07:34:03 | FromDiscord | <Elegantbeef> Nim doesnt generate code for procedures you dont use |
07:34:15 | FromDiscord | <baalajimaestro> hmmm got it |
07:34:58 | FromDiscord | <Elegantbeef> I didnt even think about the fact that you reduce runtime costs when doing that in python, that's interesting |
07:35:28 | FromDiscord | <Elegantbeef> Yea i think you understand, you can always think of macros as a user defined compilation pass |
07:35:33 | FromDiscord | <Elegantbeef> Cause that's what they're really |
07:36:48 | FromDiscord | <Elegantbeef> The compiler finds a macro call takes the code it requests passes it to the VM which then runs your code returning your AST then semantically checks it, so very much just a user defined pass |
07:37:48 | FromDiscord | <Elegantbeef> The `quote` macro btw uses the backticks as a "insert the AST of X here" like a template |
07:38:07 | FromDiscord | <Elegantbeef> If you're on 1.6 you may also want to look at genast as it's a bit nicer |
07:38:19 | FromDiscord | <Elegantbeef> it's inside `std/genasts` |
07:38:56 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3IPg |
07:39:11 | FromDiscord | <Elegantbeef> Ah nope that's just standard nim code |
07:39:16 | FromDiscord | <that_dude> I will look into genasts, the reason I used `quote do` is because all of the examples I saw used it |
07:39:19 | FromDiscord | <Elegantbeef> You can pass arguments with a block style `:` |
07:39:30 | FromDiscord | <that_dude> ah |
07:39:41 | FromDiscord | <Elegantbeef> Yea genast is new in 1.6 so all the tutorials use quote which is older |
07:40:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IPh |
07:40:30 | FromDiscord | <Elegantbeef> All that does is take the expression after `:` and put it inside the `a.add` call |
07:40:43 | FromDiscord | <Elegantbeef> It works for all procedures/templates but is mainly for templates/macros |
07:41:04 | FromDiscord | <that_dude> So `quote do` returned an object which was the nimnode in this case and effectivly turned it into `result = newStmtList(x, node)` |
07:41:13 | FromDiscord | <Elegantbeef> Yep! |
07:41:23 | FromDiscord | <that_dude> Neat |
07:42:04 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3IPi |
07:42:08 | FromDiscord | <that_dude> to make let work nicer |
07:42:13 | FromDiscord | <Elegantbeef> That's different though |
07:42:28 | FromDiscord | <Elegantbeef> that's like `var a = {1}` in other languages 😀 |
07:43:32 | FromDiscord | <Elegantbeef> Nim's got a bunch of these elegant solutions to problems |
07:43:52 | FromDiscord | <that_dude> Aren't the two examples basically the same? The let one returned a value of 1 and added that as an arg which just so happened to be the only input to the assignment? |
07:44:11 | FromDiscord | <Elegantbeef> Nah `block` is a keyword which opens a new scope |
07:44:29 | FromDiscord | <that_dude> and `a.add` didnat? |
07:44:33 | FromDiscord | <Elegantbeef> I mean i guess it's both a block expressions |
07:44:55 | FromDiscord | <Elegantbeef> I was being dumbly pedantic |
07:44:59 | FromDiscord | <that_dude> ah |
07:45:01 | FromDiscord | <that_dude> mb |
08:01:04 | FromDiscord | <Elegantbeef> @that_dude\: if you wanted to see how one would do it with macrocache https://play.nim-lang.org/#ix=3IPo |
08:01:16 | FromDiscord | <Elegantbeef> It's not that interesting but might tickle your brain |
08:32:29 | FromDiscord | <that_dude> I'm going to keep that tab open, but I don't think I'm ready to deal with that level of manipulation |
10:36:44 | FromDiscord | <Hamid_Bluri> sent a code paste, see https://play.nim-lang.org/#ix=3IPM |
10:37:26 | FromDiscord | <Rika> You’re trying to overload tuple [] |
10:37:29 | FromDiscord | <Rika> Use object |
10:37:50 | FromDiscord | <Hamid_Bluri> same with `object` |
10:38:02 | FromDiscord | <Rika> Are you sure |
10:38:17 | FromDiscord | <Hamid_Bluri> yes |
10:38:33 | FromDiscord | <Hamid_Bluri> no |
10:38:56 | FromDiscord | <Hamid_Bluri> fine with object |
10:38:58 | FromDiscord | <Hamid_Bluri> thanks |
10:40:06 | FromDiscord | <Rika> 👌 |
11:15:24 | FromDiscord | <sOkam!> I know of the std/memfiles lib, https://nim-lang.org/docs/memfiles.html↵but, as the noob I am, I'm not fully grasping how I would use the info that an opened file contains, or how to filter the info to an specific application↵How would one go about accessing all in-ram information used by an app? |
11:16:12 | FromDiscord | <sOkam!> (edit) "file" => "memfile" |
12:04:58 | FromDiscord | <Michal58> In reply to @Michal58 "<@!259277943275126785> yeah, it doesn't": is this deprecated in 1.6.2? |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.4) |
12:06:54 | * | supakeen joined #nim |
13:03:50 | * | xet7 quit (Remote host closed the connection) |
13:04:48 | * | xet7 joined #nim |
13:06:37 | * | xet7 quit (Remote host closed the connection) |
13:07:37 | * | xet7 joined #nim |
13:13:30 | * | TakinOver joined #nim |
13:23:41 | FromDiscord | <hmmm> jeez I just read from the forum that you can do something like: "proc foo(x: int or typeof(nil); y: int or typeof(nil)) =" |
13:24:29 | FromDiscord | <hmmm> someone should really do a Nim Pearls publication and free us from medieval ignorance 🤔 |
13:24:49 | FromDiscord | <hmmm> or I should just RTFM, one of the two I guess 🤨 |
13:34:15 | FromDiscord | <Rika> !eval echo typeof nil |
13:34:17 | NimBot | typeof(nil) |
13:34:23 | FromDiscord | <Rika> ? |
13:34:33 | FromDiscord | <Rika> what about that is weird idgi |
13:34:57 | qwr | seems that nim doesn't have separate name for nil type other than typeof(nil) ? |
13:36:23 | * | qwr is guessing that in essence it should be like ocaml's unit type or haskell's () (haskell uses () as typename for the type of () value) |
13:37:28 | FromDiscord | <Rika> no its more like a "sentinel that can match many things" like the empty of seq[empty] when typeof(@[]) |
13:37:59 | FromDiscord | <Rika> nil can match pointer or ptr T or ref T |
13:38:48 | qwr | which means that "nillable" types are in fact sum types of the T and typeof(nil) |
13:39:21 | qwr | (not unique to nim) |
13:41:55 | qwr | or maybe the compiler considers typeof(nil) itself generic - i couldn't find it from language manual so not sure |
13:42:59 | qwr | but the nature of nullable/nillable types is equivalent to parametric sum type |
13:44:19 | qwr | javas Option<T> or rusts std::option are nice demonstrations of this, as both are functionally equivalent to nillable type |
13:46:13 | qwr | https://doc.rust-lang.org/std/option/enum.Option.html |
13:46:29 | FromDiscord | <Rika> no nil is just literal NULL in c |
13:46:35 | FromDiscord | <Rika> nim also has a separate option type |
13:47:09 | FromDiscord | <demotomohiro> In reply to @hmmm "jeez I just read": It is just using a feature written in the Nim manual. |
13:47:10 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/manual.html#generics-type-classes |
13:48:38 | qwr | Rika: yes of course, i'm just saying that from type theory perspective nillability is also a form of sum type |
13:49:59 | FromDiscord | <Rika> okay |
13:54:32 | * | src joined #nim |
14:04:24 | * | arkurious joined #nim |
14:07:03 | * | neurocyte0132889 joined #nim |
14:07:03 | * | neurocyte0132889 quit (Changing host) |
14:07:03 | * | neurocyte0132889 joined #nim |
14:22:58 | * | FromDiscord quit (Remote host closed the connection) |
14:23:11 | * | FromDiscord joined #nim |
14:23:58 | NimEventer | New thread by Mantielero: What approach can I use to fix a number of parameters in some functions?, see https://forum.nim-lang.org/t/8726 |
15:35:30 | * | elph joined #nim |
15:36:06 | * | krux02 joined #nim |
15:59:34 | * | averell joined #nim |
16:18:16 | * | geek_ joined #nim |
16:25:38 | * | xet7 quit (Quit: Leaving) |
16:26:36 | * | xet7 joined #nim |
17:11:34 | FromDiscord | <Rosen> sent a code paste, see https://play.nim-lang.org/#ix=3IRQ |
17:12:36 | FromDiscord | <Rika> `nimble list -i | grep neo` shows what? |
17:13:08 | FromDiscord | <Rosen> It's there |
17:13:15 | FromDiscord | <Rika> version i mean |
17:13:18 | FromDiscord | <Rosen> 0.3.1 |
17:14:00 | FromDiscord | <Rika> i checked docs |
17:14:02 | FromDiscord | <Rika> its not there |
17:14:11 | FromDiscord | <Rika> only for float matrices does it exist |
17:14:20 | FromDiscord | <Rosen> oh! |
17:14:23 | FromDiscord | <Rosen> that makes sense |
17:14:24 | FromDiscord | <Rosen> durr |
17:14:26 | FromDiscord | <Rosen> thank you |
17:15:48 | * | geek_ quit (Remote host closed the connection) |
17:39:10 | * | src left #nim (Leaving) |
17:52:42 | FromDiscord | <Schelz> Can somebody give me an idea how could I separate mingw 64 compiler from mingw 32 ? |
17:56:31 | FromDiscord | <Schelz> they bugged out and its using only 32 bit |
17:58:35 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3IS1 |
18:00:54 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3IS6 |
18:01:00 | FromDiscord | <Rika> its a start of course |
18:01:20 | FromDiscord | <Rika> also whoops, should be \`typ\` and \`val` |
18:01:32 | FromDiscord | <Rika> or wait idk anymore tbh |
18:02:24 | FromDiscord | <TryAngle> looks good tbh↵if I want to make it more I could make the parameters a type and take varargs as parameter in the template? |
18:02:36 | FromDiscord | <TryAngle> (edit) "more" => "in "one call"" |
18:02:43 | FromDiscord | <TryAngle> (edit) "tbh↵if" => "already thanks↵if" |
18:04:14 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3IS7 |
18:04:26 | FromDiscord | <Rika> In reply to @TryAngle "looks good already": no idea what you mean |
18:05:23 | FromDiscord | <TryAngle> In reply to @Rika "no idea what you": instead of calling tovalue multiple times, do multiple types in one call |
18:05:48 | FromDiscord | <Rika> i mean yeah but that doesnt elaborate on how to do it in the template |
18:05:49 | FromDiscord | <Rika> lol |
18:06:24 | FromDiscord | <TryAngle> can't I just for loop the varargs and make a proc in the for loop 😂? |
18:11:46 | FromDiscord | <Rika> ah now i get it |
18:11:50 | FromDiscord | <Rika> okay yeah sure i guess |
18:11:54 | FromDiscord | <Rika> would be a macro then |
18:29:43 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3ISd |
18:30:16 | FromDiscord | <TryAngle> adding / removing `untyped` doesn't fix it 😔 |
18:31:36 | FromDiscord | <TryAngle> ah |
18:32:13 | FromDiscord | <TryAngle> calling the paramters zero / one is the issue XD |
18:45:29 | * | flynn joined #nim |
19:02:38 | NimEventer | New Nimble package! prettyclr - Small library for working with colors, see https://github.com/prettybauble/prettyclr |
19:11:15 | * | cheer joined #nim |
19:26:17 | * | noeontheend joined #nim |
19:54:17 | * | noeontheend quit (Ping timeout: 240 seconds) |
20:01:59 | * | cheer left #nim (WeeChat 3.3) |
20:23:07 | * | noeontheend joined #nim |
20:37:13 | NimEventer | New thread by Gcao: Geniune question about JS backend support, see https://forum.nim-lang.org/t/8727 |
21:27:16 | FromDiscord | <qb> Does nim have that somewhere? https://docs.rs/linux-raw-sys/0.0.5/linux_raw_sys/v5_11/general/constant.NR_exit.html |
21:28:06 | FromDiscord | <qb> Basically looking for the syscall table |
21:30:16 | FromDiscord | <Elegantbeef> https://github.com/def-/nim-syscall only package on nimble that comes up from `syscall` |
21:34:23 | FromDiscord | <qb> Yea that enum is what I'm looking for https://github.com/def-/nim-syscall/blob/master/src/linux_x86_64/nr.nim |
21:42:24 | FromDiscord | <TryAngle> is there a way to inherit in new-style concepts? |
21:42:48 | FromDiscord | <Elegantbeef> Nope they're sadly more limited |
21:43:06 | FromDiscord | <TryAngle> I see, and mixing them is not possible either? |
21:43:07 | FromDiscord | <Elegantbeef> I assume you want A is Y and procedures? |
21:44:48 | FromDiscord | <TryAngle> ah, mixing seems actually possible lol |
21:45:40 | FromDiscord | <TryAngle> In reply to @Elegantbeef "Nope they're sadly more": but the "old-style" will be kept right? |
21:45:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IT3 |
21:46:08 | FromDiscord | <Elegantbeef> For now atleast it'll be kept |
21:46:58 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3IT4 |
21:47:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3IT5 |
21:47:24 | FromDiscord | <TryAngle> thx |
21:47:52 | FromDiscord | <Elegantbeef> But you of course can always use the concept method, if you prefer(though might be more likely to hit a concept recurse limit) |
21:48:33 | FromDiscord | <TryAngle> In reply to @Elegantbeef "But you of course": oh, what is the limit? |
21:49:07 | FromDiscord | <Elegantbeef> I dont know the compiler will bitch at you when you reach it |
21:49:34 | FromDiscord | <TryAngle> hmmm I think the max that I will hit in the whole project will be 10 |
21:49:39 | FromDiscord | <TryAngle> so I think that should be fine |
21:49:42 | FromDiscord | <Elegantbeef> Though if you're using new concepts that's less of an issue afaik, since the old method used `when compiles` internally |
21:49:53 | FromDiscord | <Elegantbeef> The new method uses more sensible reasoning afaik |
22:05:27 | FromDiscord | <jfmonty2> sent a code paste, see https://play.nim-lang.org/#ix=3ITb |
22:05:34 | FromDiscord | <jfmonty2> but I get an error because I'm attempting to redefine the `len` field |
22:06:04 | FromDiscord | <Elegantbeef> use `elif` instead of `when, when, else` |
22:06:24 | FromDiscord | <Elegantbeef> should be `when, elif, else` |
22:06:31 | FromDiscord | <jfmonty2> oh |
22:06:40 | FromDiscord | <jfmonty2> huh, didn't know that |
22:06:49 | FromDiscord | <qb> I'm trying to inject a syscall into a process with ptrace. I've found some usable cpp code but the nim version doesn't works yet. Am I missing something? https://play.nim-lang.org/#ix=3ITa |
22:07:53 | FromDiscord | <Elegantbeef> Ugh is today the day i read C++ 😛 |
22:08:41 | FromDiscord | <Elegantbeef> Dont `cast` those valuse do `clong syscall_n` .... |
22:08:47 | FromDiscord | <Elegantbeef> or how ever you prefer that call |
22:09:39 | FromDiscord | <Elegantbeef> Also what compiler are you using? |
22:10:48 | FromDiscord | <metamuffin> https://youtu.be/B6ftyLpyono |
22:12:36 | FromDiscord | <qb> In reply to @Elegantbeef "Also what compiler are": gcc |
22:16:01 | FromDiscord | <qb> Gonna get some sleep. Gonna fix that casts. Thats the result of dumb copying cpp code to nim 😄 |
22:16:18 | FromDiscord | <qb> (edit) "Gonna" => "I'm going to" |
22:25:35 | FromDiscord | <TryAngle> wait how do I import from a module that is above?↵import ../name↵seems to not be the correct one 😂 |
22:25:43 | FromDiscord | <TryAngle> (edit) "above?↵import ../name↵seems" => "above?↵`import ../name`↵seems" |
22:26:11 | FromDiscord | <Elegantbeef> That is the proper way to import it |
22:26:48 | FromDiscord | <TryAngle> ah |
22:27:01 | FromDiscord | <TryAngle> ../↵is not compatible↵with [name1, name2] |
22:30:58 | FromDiscord | <Solitude> `".." ` as a workaround |
22:46:21 | FromDiscord | <TryAngle> does nim allow to define 3-ary operators? |
23:04:58 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3ITk |
23:23:01 | FromDiscord | <Elegantbeef> `SomeSignedInt` and `SomeUnsignedInt` exist btw |
23:24:30 | FromDiscord | <Elegantbeef> The issue is it's ambiguous |
23:24:41 | FromDiscord | <Elegantbeef> `3` can be both `uint` or `int` depending on context |
23:25:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ITp |
23:25:47 | FromDiscord | <Elegantbeef> @TryAngle\: ^ |
23:28:59 | FromDiscord | <TryAngle> ah I see |
23:29:32 | FromDiscord | <TryAngle> so it would work in cases like this if I specifiy if it's int or uint when calling the Test function like you did? |
23:30:27 | FromDiscord | <TryAngle> but why does it work then if I manually implement all via a template? |
23:31:10 | FromDiscord | <Elegantbeef> Example? |
23:31:19 | FromDiscord | <Elegantbeef> The reason the float works btw is `1.0` is float64 |
23:31:34 | FromDiscord | <Elegantbeef> Unless there is only a float32 proc i should say |
23:32:20 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3ITt |
23:33:40 | FromDiscord | <Elegantbeef> Not having a typeclass is my wager, with a type class it's ambiguous if it's SomeSignedInt or SomeUnsignedInt, without type class it prefers `int` |
23:34:38 | FromDiscord | <TryAngle> hmmm should I add a PR for that or is that intended behavior? looks a bit sus |
23:35:48 | FromDiscord | <Elegantbeef> I think it's just how it works, conversions arent done to typeclasses, it is confusing though |
23:35:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ITv |
23:35:59 | FromDiscord | <Elegantbeef> I have to shovel some snow so if you have follow up questions it'll be delayed |
23:37:56 | FromDiscord | <TryAngle> so it's intended? |
23:45:12 | FromDiscord | <Elegantbeef> It maybe, i think when there are overloaded calls if all are typeclasses it wants explicit |