00:00:02 | FromDiscord | <Elegantbeef> So what needs to placed in the body of this proc is the `mgetOrPut` symbol that matches the one we want, and since we dont have an instantiated generic i dont think `semOverloadedCall` will work |
00:01:36 | FromDiscord | <Elegantbeef> I've been wrong before so if you can make my statement wrong i'll be happy 😛 |
00:11:02 | FromDiscord | <SirOlaf> How are generic overrides resolved then |
00:11:18 | FromDiscord | <Elegantbeef> Generic overrides wouldnt be allowed to borrow afaict |
00:11:27 | FromDiscord | <SirOlaf> But they must be resolved somehow |
00:11:30 | FromDiscord | <SirOlaf> Even without borrow |
00:11:35 | FromDiscord | <Elegantbeef> They have more specific types |
00:11:48 | FromDiscord | <Elegantbeef> On instantiation their types are used to dispatch |
00:12:05 | FromDiscord | <Elegantbeef> The dispatch is done on a instantiated type |
00:12:12 | FromDiscord | <SirOlaf> Guess that makes sense |
00:12:45 | FromDiscord | <SirOlaf> Why are borrowed functions different though? |
00:13:02 | FromDiscord | <SirOlaf> Generic functions get ignore from what I know, why are borrowed generic functions not ignored too |
00:13:12 | FromDiscord | <SirOlaf> Until a concrete type is given |
00:13:38 | FromDiscord | <Elegantbeef> The issue is we need to get the symbol |
00:14:02 | FromDiscord | <Elegantbeef> I guess this could be delayed until generic instantiation |
00:14:05 | FromDiscord | <SirOlaf> Point is that the entire resolution should be unneeded until later |
00:14:34 | FromDiscord | <Elegantbeef> So yea at generic instantiation is when you need to make the borrow it seems |
00:14:54 | FromDiscord | <SirOlaf> Yep, that is the idea. I have no idea where to even begin with that though |
00:15:04 | FromDiscord | <Elegantbeef> `semInst` |
00:15:50 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/devel/compiler/seminst.nim#L403-L404 here i think |
00:18:35 | FromDiscord | <SirOlaf> searchForBorrowProc still needs to do something about it |
00:20:25 | FromDiscord | <Elegantbeef> Check if the symbol flags has `sfBorrow` if so run that proc, else instantiate body? |
00:22:39 | FromDiscord | <SirOlaf> Gotta slow down there, this is new territory for me |
00:22:52 | FromDiscord | <SirOlaf> seminst that is |
00:25:43 | FromDiscord | <SirOlaf> First question I have is how it can get to generateInstance if searchForBorrowProc fails before |
00:25:59 | FromDiscord | <SirOlaf> Or does it happen the other way around |
00:28:49 | FromDiscord | <Elegantbeef> You dont call search if it's generic |
00:29:36 | FromDiscord | <Elegantbeef> I guess generic with unresolved types |
00:30:34 | FromDiscord | <SirOlaf> So simply stop semBorrow? |
00:31:17 | FromDiscord | <Elegantbeef> I think so if it has generic parameters you wait until generic instantiation to borrow |
00:31:21 | FromDiscord | <Elegantbeef> that seems to make sense to me |
00:31:42 | FromDiscord | <SirOlaf> It makes sense, but whether or not that's how things are done in the compiler is a mystery to me |
00:32:16 | FromDiscord | <Elegantbeef> Yea it's yet to be seen if this will work |
00:35:15 | FromDiscord | <SirOlaf> Now how do you check if it has generic params |
00:35:47 | FromDiscord | <SirOlaf> I may or may not have seen a function for that purpose at some point |
00:35:48 | FromDiscord | <Elegantbeef> `procAst[genericParamsPos].len > 0` |
00:36:20 | * | tiorock joined #nim |
00:36:21 | * | tiorock quit (Changing host) |
00:36:21 | * | tiorock joined #nim |
00:36:21 | * | rockcavera is now known as Guest1211 |
00:36:21 | * | Guest1211 quit (Killed (strontium.libera.chat (Nickname regained by services))) |
00:36:21 | * | tiorock is now known as rockcavera |
00:36:21 | FromDiscord | <Elegantbeef> There might be |
00:36:36 | * | krux02 quit (Remote host closed the connection) |
00:37:05 | FromDiscord | <SirOlaf> There is a isGenericRoutine |
00:37:30 | FromDiscord | <Gorylek😚> Hi |
00:37:44 | FromDiscord | <Elegantbeef> Yellow |
00:38:02 | FromDiscord | <SirOlaf> (edit) "There is a isGenericRoutine ... " added "in ast" |
00:38:36 | FromDiscord | <SirOlaf> In reply to @SirOlaf "There is a isGenericRoutine": Does what it says |
00:39:37 | FromDiscord | <SirOlaf> So, I can now prevent semBorrow from doing things |
00:40:16 | FromDiscord | <Elegantbeef> Nice we're half way there wooooaaah |
00:41:59 | * | rockcavera quit (Ping timeout: 256 seconds) |
00:43:54 | FromDiscord | <SirOlaf> Actually not quite, it doesn't enjoy that |
00:44:33 | FromDiscord | <SirOlaf> Or no, fixed itself |
00:45:56 | FromDiscord | <SirOlaf> Ok it does what it should. Trying to use mgetOrPut creates a new error, which is expected (`Error: internal error: wrong AST for borrowed symbol`) |
00:46:13 | FromDiscord | <SirOlaf> So now it has to be made usable |
00:47:49 | FromDiscord | <SirOlaf> Now how should generateInstance deal with this |
00:48:38 | FromDiscord | <Elegantbeef> Check if the `sfBorrow in procSym.flags` if so make the body the borrowed symbol, otherwise instantiate the body |
00:50:43 | FromDiscord | <SirOlaf> How can I get the body though |
00:51:12 | FromDiscord | <Elegantbeef> `procAst[bodyPos] = semBorrowProc` |
00:53:04 | FromDiscord | <SirOlaf> `n[bodyPos] = fn.ast` ? |
00:53:26 | FromDiscord | <SirOlaf> Or using getBody |
00:53:45 | FromDiscord | <Elegantbeef> semBorrow writes to body |
00:54:01 | FromDiscord | <Elegantbeef> So you just do `semBorrow` in the tree if it's supposed to borrow |
00:54:02 | FromDiscord | <Elegantbeef> Otherwise you instantiate the body |
00:55:13 | FromDiscord | <SirOlaf> That is a bit of a dilemma |
00:55:20 | FromDiscord | <Elegantbeef> Why? |
00:55:26 | FromDiscord | <SirOlaf> semBorrow can't succeed, can it |
00:55:36 | FromDiscord | <Elegantbeef> it can at the point of the generic isntantiation |
00:55:46 | FromDiscord | <Elegantbeef> Since we now have a concrete type instead of a generic inst |
00:55:52 | FromDiscord | <Elegantbeef> generic invocation\ |
00:56:04 | FromDiscord | <SirOlaf> Oh yeah, we finally got concrete types |
00:58:07 | * | rockcavera joined #nim |
00:58:08 | * | rockcavera quit (Changing host) |
00:58:08 | * | rockcavera joined #nim |
00:58:15 | FromDiscord | <SirOlaf> Problem is that I don't have access to it from seminst |
00:58:38 | FromDiscord | <Elegantbeef> Reorder it so you do |
00:58:48 | FromDiscord | <SirOlaf> Great plan |
00:58:55 | FromDiscord | <SirOlaf> Issue is that I also can't import it |
00:59:27 | FromDiscord | <Elegantbeef> You can move code around |
01:00:02 | FromDiscord | <SirOlaf> Wouldn't I need to move semBorrow into a different file then |
01:00:04 | FromDiscord | <SirOlaf> Seems a bit intrusive |
01:01:05 | FromDiscord | <Elegantbeef> You gotta do what you gotta do |
01:01:31 | FromDiscord | <Elegantbeef> Get it to work then clean it up |
01:05:11 | FromDiscord | <SirOlaf> Issue seems to just be that seminst is included before semstmts. Moving it produces more issues though, so this is quite the puzzle |
01:09:57 | FromDiscord | <Elegantbeef> Just move the borrow stuff into the main module for now |
01:10:50 | FromDiscord | <SirOlaf> Easier said than done |
01:11:10 | FromDiscord | <SirOlaf> searchForBorrowProc for example depends on lots of stuff in semcall |
01:11:16 | FromDiscord | <SirOlaf> So can't move it out |
01:11:39 | FromDiscord | <SirOlaf> Who would have thought the real challenge would be getting the code in the right order |
01:12:45 | FromDiscord | <Elegantbeef> If you send the diff over i could look at it 😀 |
01:13:54 | FromDiscord | <SirOlaf> Couldn't I just predecalre |
01:13:59 | FromDiscord | <SirOlaf> (edit) "predecalre" => "forward declare" |
01:14:40 | FromDiscord | <Elegantbeef> Depends if the modules are imported or included |
01:14:45 | FromDiscord | <SirOlaf> All is included |
01:14:49 | FromDiscord | <SirOlaf> That's why they all depend on each other |
01:14:53 | FromDiscord | <Elegantbeef> Then perhaps |
01:32:44 | FromDiscord | <SirOlaf> In reply to @SirOlaf "Actually got it to": We are back at this issue |
01:33:39 | FromDiscord | <Elegantbeef> Is the type a generic instance or generic invocation? |
01:33:52 | FromDiscord | <SirOlaf> Which one |
01:34:11 | FromDiscord | <Elegantbeef> Inside the proc we've declared |
01:34:23 | FromDiscord | <Elegantbeef> IE is `DefaultTable` |
01:34:49 | FromDiscord | <SirOlaf> How or where would I check this |
01:34:52 | FromDiscord | <SirOlaf> Not quite following |
01:35:40 | FromDiscord | <Elegantbeef> check the `ast[paramPos][0].typ.kind` |
01:36:28 | FromDiscord | <Elegantbeef> If it's a `genericInvocation` we're lacking the instantiation info in our proc header |
01:37:03 | FromDiscord | <SirOlaf> In reply to @Elegantbeef "check the `ast[paramPos][0].typ.kind`": Which ast though |
01:37:14 | FromDiscord | <SirOlaf> At what stage of this process |
01:37:37 | FromDiscord | <Elegantbeef> Before you `semBorrow` do `echo n[paramPos][1.typ.kind]` |
01:37:49 | FromDiscord | <Elegantbeef> `echo n[paramPos][1].typ.kind`\ |
01:38:06 | FromDiscord | <Elegantbeef> Inside the generate instance |
01:38:31 | FromDiscord | <SirOlaf> Do you mean genericParamsPos? |
01:38:37 | FromDiscord | <SirOlaf> Because paramPos is not declared |
01:38:38 | FromDiscord | <Elegantbeef> No |
01:39:09 | FromDiscord | <Elegantbeef> `paramsPos`\ |
01:40:43 | FromDiscord | <SirOlaf> That gives me sigsegv |
01:40:53 | FromDiscord | <SirOlaf> So not quite the output you might want |
01:41:39 | FromDiscord | <Elegantbeef> You did do it only inside the borrow branch right? |
01:42:39 | FromDiscord | <SirOlaf> I put an if statement at the location you showed on github and placed the echo there |
01:44:00 | FromDiscord | <Elegantbeef> odd |
01:47:19 | FromDiscord | <SirOlaf> It does not have a paramsPos |
01:47:23 | FromDiscord | <SirOlaf> Not long enough |
01:47:38 | FromDiscord | <SirOlaf> Or no that's wrong |
01:48:59 | FromDiscord | <SirOlaf> It does not have a typ |
01:49:16 | FromDiscord | <Elegantbeef> it might be `result.ast` instead |
01:49:35 | FromDiscord | <Elegantbeef> Seems that might be the AST we want to use |
01:50:04 | FromDiscord | <Elegantbeef> so pass that to sem borrow instead perhaps |
01:50:09 | FromDiscord | <SirOlaf> Sure |
01:54:10 | FromDiscord | <SirOlaf> That doesn't have typ either |
01:55:17 | FromDiscord | <SirOlaf> Also same type mismatch error |
01:58:53 | FromDiscord | <Elegantbeef> Hmppph |
01:59:27 | FromDiscord | <Elegantbeef> Could you shoot me the git diff, i want to see something without bugging you |
02:00:28 | FromDiscord | <SirOlaf> Bold of you to assume I got anything set up for that |
02:01:01 | FromDiscord | <Elegantbeef> \`git diff \>\> "distinct.diff" |
02:01:08 | FromDiscord | <Elegantbeef> Then just throw that file on a site and send it |
02:02:16 | FromDiscord | <SirOlaf> https://media.discordapp.net/attachments/371759389889003532/928830869077131284/distinct.diff |
02:02:20 | FromDiscord | <SirOlaf> Not many changes to see |
02:05:57 | FromDiscord | <Elegantbeef> Hmm could you do `git diff --no-color` seems that is not playing nice |
02:07:33 | FromDiscord | <SirOlaf> https://media.discordapp.net/attachments/371759389889003532/928832197555789834/distinct.diff |
02:08:19 | FromDiscord | <Elegantbeef> Ok it's just not playing nice whatsoever |
02:09:22 | FromDiscord | <Elegantbeef> Are you by anychance using powershell? |
02:09:27 | FromDiscord | <SirOlaf> That I am |
02:09:39 | FromDiscord | <Elegantbeef> Ah apparently it ruins git diffs |
02:09:44 | FromDiscord | <Elegantbeef> Guess i'll manually apply the patch |
02:09:53 | FromDiscord | <SirOlaf> Good to know |
02:21:18 | FromDiscord | <Elegantbeef> Oh you were passing `fn` to `semBorrow` which is the uninstantiated symbol |
02:21:51 | FromDiscord | <SirOlaf> What is supposed to be passed |
02:21:58 | FromDiscord | <Elegantbeef> `result` |
02:22:07 | FromDiscord | <SirOlaf> So result.ast and result |
02:22:09 | FromDiscord | <Elegantbeef> It then causes an issue with the mismatch at the 3rd position in my test file |
02:22:19 | FromDiscord | <Elegantbeef> i think it can be `n` |
02:23:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Ljs |
02:24:10 | FromDiscord | <SirOlaf> I don't have that error |
02:24:44 | FromDiscord | <Elegantbeef> What do you have? |
02:25:03 | FromDiscord | <SirOlaf> Currently Error: no symbol to borrow from found again |
02:25:06 | FromDiscord | <SirOlaf> Lemme recompile |
02:25:29 | FromDiscord | <Elegantbeef> Little hint if you arent already do `./koch temp c ./someFIle.nim` if you arent already |
02:25:44 | FromDiscord | <Elegantbeef> I guess on windows it's `koch.exe`? |
02:26:06 | FromDiscord | <SirOlaf> I tried that and promptly gave up |
02:26:19 | FromDiscord | <SirOlaf> Complains about a missing lib file or something |
02:26:24 | FromDiscord | <Elegantbeef> Ah |
02:26:35 | FromDiscord | <Elegantbeef> Not on windows so cannot help much there |
02:31:05 | FromDiscord | <SirOlaf> Did you change anything other than fn |
02:31:27 | * | neurocyte0917 joined #nim |
02:32:48 | FromDiscord | <Elegantbeef> did change the `else` to an `elif` statement |
02:33:07 | FromDiscord | <Elegantbeef> ` elif c.inGenericContext == 0:` instead of `else` for the instantiate body |
02:33:29 | * | neurocyte091 quit (Ping timeout: 256 seconds) |
02:33:29 | * | neurocyte0917 is now known as neurocyte091 |
02:33:42 | FromDiscord | <SirOlaf> Isn't that checked above |
02:34:32 | FromDiscord | <Elegantbeef> It was the check that was the prior |
02:34:36 | FromDiscord | <Elegantbeef> You removed it, i put it back |
02:35:19 | FromDiscord | <SirOlaf> Pretty sure I didn't remove anything |
02:35:30 | FromDiscord | <SirOlaf> Either way, this is odd |
02:35:46 | FromDiscord | <Elegantbeef> there was an `if c.genericContext ==0` guarding the body instantiation |
02:35:48 | FromDiscord | <Elegantbeef> When you added the sym check you removed that |
02:36:04 | FromDiscord | <SirOlaf> It's there for me |
02:36:32 | FromDiscord | <SirOlaf> And the diff show it too |
02:36:52 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/928839576427061339/image.png |
02:36:58 | FromDiscord | <Elegantbeef> Oh nvm i see |
02:37:02 | FromDiscord | <Elegantbeef> You made this go inside |
02:37:30 | FromDiscord | <SirOlaf> Was it not supposed to go inside? |
02:38:18 | FromDiscord | <Elegantbeef> I just moved the `if c.genericContext == 0` to an elif branch |
02:38:42 | FromDiscord | <Elegantbeef> Dont think so |
02:38:45 | FromDiscord | <Elegantbeef> Could be wrong |
02:40:16 | FromDiscord | <SirOlaf> How on earth can your error be different from mine |
02:40:26 | FromDiscord | <Elegantbeef> Cause i have different flow |
02:41:29 | * | noeontheend joined #nim |
02:41:42 | * | arkurious quit (Quit: Leaving) |
02:41:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Ljy |
02:42:17 | FromDiscord | <SirOlaf> No I changed it |
02:43:01 | FromDiscord | <Elegantbeef> mydiff.diff https://media.discordapp.net/attachments/371759389889003532/928841123147960320/mydiff.diff |
02:44:43 | FromDiscord | <SirOlaf> That is identical |
02:45:09 | FromDiscord | <SirOlaf> What code are you testing with |
02:45:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Ljz |
02:45:44 | FromDiscord | <Elegantbeef> Reduced the complexity a bit to still catch edge cases |
02:45:49 | FromDiscord | <Elegantbeef> But also makes it easier to reason |
02:45:55 | FromDiscord | <SirOlaf> That does now give me the same error |
02:46:29 | FromDiscord | <SirOlaf> Must have changed some strange stuff in my test then |
02:47:08 | FromDiscord | <Elegantbeef> The issue now is that we're skipping the generic for `key` so not getting a `DefaultTable` there |
02:47:18 | FromDiscord | <Elegantbeef> I mean `val` |
02:47:30 | FromDiscord | <SirOlaf> How is that |
02:47:41 | FromDiscord | <SirOlaf> Seems strange |
02:47:45 | FromDiscord | <Elegantbeef> Cause it's skipping over all distincts |
02:47:58 | FromDiscord | <Elegantbeef> But we want `B` to stay whatever `B` is |
02:49:42 | FromDiscord | <SirOlaf> Where could it be skipping |
02:50:06 | FromDiscord | <SirOlaf> Guess stacktrace kinda says |
02:50:09 | FromDiscord | <Elegantbeef> line 727 of semcall |
02:50:21 | FromDiscord | <SirOlaf> Also my weird koch error was because of working dir, working now |
02:54:51 | nixfreaknim[m] | I having lots of issues with understanding inline procs , I know its stupid but can someone please show me in this example ? https://play.nim-lang.org/#ix=3LjA |
02:55:18 | nixfreaknim[m] | I would I call both of those procs correctly ? |
02:55:40 | FromDiscord | <Rika> What’s the issue? |
02:55:46 | FromDiscord | <Rika> Just call them like normal |
02:56:27 | FromDiscord | <Elegantbeef> Also you may want to do `i: 0..2` |
02:56:27 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3LjB |
02:56:27 | FromDiscord | <Elegantbeef> Works fine |
02:58:02 | FromDiscord | <Elegantbeef> Well olaf i'm at the end of my guesses of what can be done |
02:58:08 | FromDiscord | <Elegantbeef> So good luck from here |
02:58:27 | FromDiscord | <SirOlaf> Thanks for the assistance up till now |
03:00:12 | FromDiscord | <Elegantbeef> No problem, you're closer to having it work than i was |
03:12:12 | FromDiscord | <Varriount> How would I go about compiling Nim to WebAssembly? |
03:15:05 | FromDiscord | <Elegantbeef> Impbox has a wasm file for nico that i used |
03:15:15 | FromDiscord | <Elegantbeef> Which i think is derived from the tutorial treeform has |
03:55:42 | * | Gustavo6046_ joined #nim |
03:56:32 | * | Gustavo6046 quit (Ping timeout: 240 seconds) |
04:09:38 | * | Gustavo6046_ is now known as Gustavo6046 |
04:35:06 | NimEventer | New post on r/nim by derrpwave: nip: a simple package to get your public IP address with nim, see https://reddit.com/r/nim/comments/rxyp67/nip_a_simple_package_to_get_your_public_ip/ |
04:36:17 | * | noeontheend quit (Ping timeout: 240 seconds) |
04:50:11 | FromDiscord | <michaelb> sent a code paste, see https://play.nim-lang.org/#ix=3LjY |
04:50:33 | FromDiscord | <michaelb> if you have dig and awk installed, try pasting that line in your terminal 😄 |
04:51:25 | * | Gustavo6046 quit (Ping timeout: 240 seconds) |
04:52:32 | FromDiscord | <Elegantbeef> Who's going to make the issue closing the client and wrapping the echo with a `when isMainModule` |
05:14:33 | * | cyraxjoe joined #nim |
05:18:57 | * | cyraxjoe quit (Ping timeout: 240 seconds) |
05:19:16 | * | cyraxjoe joined #nim |
05:24:11 | * | Gustavo6046 joined #nim |
05:41:16 | * | cyraxjoe quit (Quit: I'm out!) |
05:43:04 | * | rockcavera quit (Remote host closed the connection) |
05:43:11 | * | cyraxjoe joined #nim |
05:46:45 | * | cyraxjoe quit (Client Quit) |
05:48:20 | * | cyraxjoe joined #nim |
05:53:01 | * | MightyJoe joined #nim |
05:53:05 | * | cyraxjoe quit (Ping timeout: 256 seconds) |
06:09:52 | * | Gustavo6046 quit (Quit: Leaving) |
07:13:20 | * | jjido joined #nim |
07:21:09 | FromDiscord | <eyecon> Why is `strformat` singular but `sequtils` plural? I always forget which is which. Why is `algorithm` singular but `setutils` plural? |
07:21:23 | FromDiscord | <eyecon> Is there a system to it or is it just random?P |
07:21:29 | FromDiscord | <eyecon> (edit) "random?P" => "random?" |
07:23:11 | FromDiscord | <Solitude> strformat implements single thing |
07:23:18 | FromDiscord | <Solitude> algorithm shoud've been plural, i guess |
07:23:43 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
07:23:50 | FromDiscord | <congusbongus> seems random to me↵imo they should all have been singular, then there's no chance of confusion |
07:26:34 | FromDiscord | <xflywind> https://nim-lang.org/docs/contributing.html#evolving-the-stdlib-conventions |
07:26:55 | FromDiscord | <xflywind> > New module names should prefer plural form whenever possible, e.g.: std/sums.nim instead of std/sum.nim. In particular, this reduces chances of conflicts between module name and the symbols it defines. |
07:36:58 | * | PMunch joined #nim |
07:45:06 | * | jjido joined #nim |
08:51:25 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
09:31:17 | * | joast quit (Ping timeout: 240 seconds) |
09:48:47 | * | neurocyte091 quit (Quit: The Lounge - https://thelounge.chat) |
09:50:00 | * | neurocyte0917 joined #nim |
10:24:52 | FromDiscord | <evoalg> @ElegantBeef I wanna ask you further about `mixin` but if you're about to hit the sack I'll wait until tomorrow? |
10:25:12 | FromDiscord | <Elegantbeef> Feel free to ask right now |
10:25:56 | FromDiscord | <evoalg> https://play.nim-lang.org/#ix=3Lls ... it doesn't seem to make any difference? |
10:26:36 | FromDiscord | <Elegantbeef> That's a template so the mixin isnt even really needed |
10:26:59 | FromDiscord | <evoalg> ahhh ... I was trying to follow what you were saying about it the other day and I got confused 😉 |
10:27:40 | FromDiscord | <evoalg> if I don't need it I don't have to worry about it I guess 🙂 |
10:28:30 | FromDiscord | <Elegantbeef> It's needed in generics more than templates |
10:28:41 | FromDiscord | <Elegantbeef> Though i think it can be used in some cases of templates to solve issues |
10:29:09 | FromDiscord | <evoalg> gotcha ... I'll test in generics - thank you! |
10:29:36 | FromDiscord | <Elegantbeef> I'll save you the effort https://play.nim-lang.org/#ix=3Llv |
10:29:45 | FromDiscord | <Elegantbeef> You can see in this case first `doThing` isnt declared before the proc |
10:29:58 | FromDiscord | <Elegantbeef> Secondly the first `doThing` in scope is used |
10:30:04 | FromDiscord | <Elegantbeef> in both cases |
10:30:19 | FromDiscord | <Elegantbeef> Which is cause a single procedure is generated |
10:30:32 | FromDiscord | <Elegantbeef> one for `showcaseMagic2[int]` is used regardless where you call it from after first instantiation |
10:31:00 | FromDiscord | <evoalg> gosh you always come through! ... I will absorb.... |
10:31:37 | FromDiscord | <Elegantbeef> Say you want to have a routine that you can change the behaviour on a per module or even per scope basis, you'd want the template |
10:31:56 | FromDiscord | <Elegantbeef> But if you just want a routine that you implement in a given module and it always calls the right stuff you'd mixin with the generic |
10:32:53 | FromDiscord | <evoalg> nice ... and so you personally use mixin? |
10:33:05 | FromDiscord | <Elegantbeef> If it's needed |
10:33:07 | FromDiscord | <Elegantbeef> Same with bind |
10:33:47 | FromDiscord | <Elegantbeef> bind is the opposite of mixin, instead of taking the scope of the instantiation into account it takes only the scope of declaration |
10:34:10 | FromDiscord | <Elegantbeef> So if you never want a procedure to be overridden in a generic you'd do `bind doThing` |
10:34:54 | FromDiscord | <evoalg> oh wow thank you ... this will take me a little while ... I may be some time 😉 |
10:35:25 | FromDiscord | <Elegantbeef> It's all about generics, best might be to play with multiple files adding/removing procs before the generic one, exporting/unexporting them |
10:35:50 | FromDiscord | <Elegantbeef> one could probably do a whole talk on generics and open/closed symbols |
10:36:48 | FromDiscord | <evoalg> gosh, and this isn't even getting onto advanced stuff like macros |
10:37:03 | FromDiscord | <Elegantbeef> Well macros play off this stuff |
10:37:20 | FromDiscord | <Elegantbeef> If you understand what a symbol is and what it means to be closed/open it helps |
10:38:09 | FromDiscord | <evoalg> I don't know what they mean ... I ask you a question and I always end up with two new questions 😄 |
10:38:21 | FromDiscord | <Elegantbeef> A symbol is just a name that points to something |
10:38:29 | FromDiscord | <Elegantbeef> `int` is a name that points to a type |
10:38:41 | FromDiscord | <Elegantbeef> `var a = 100` `a` is a name that points to that variable |
10:39:05 | FromDiscord | <Elegantbeef> Being opened means the choice isnt defined yet |
10:39:39 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Llz |
10:39:59 | FromDiscord | <Elegantbeef> inside `doOtherThing` `doThing` is open since it's uncertain what it could be, but it knows that it is either the float/int overload |
10:40:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LlB |
10:40:42 | FromDiscord | <Elegantbeef> Though possibly not actually closed in the AST, but it's the idea that counts |
10:41:55 | FromDiscord | <evoalg> gotcha ok, and so proc calls can be open like `doThing(a)` in the first eg is open |
10:42:56 | FromDiscord | <evoalg> proc calls themselves must be just another symbol |
10:43:14 | FromDiscord | <Elegantbeef> They're not but that's what you'll learn with macros |
10:43:25 | FromDiscord | <Elegantbeef> They're a `call` and the first child of that is a symbol |
10:43:36 | FromDiscord | <Elegantbeef> So close |
10:44:21 | FromDiscord | <Elegantbeef> But given you arent touching macros yet it doesnt matter 😛 |
10:45:17 | FromDiscord | <Elegantbeef> Point being all named things are symbols and an open symbol is when there is ambiguity that will be resolved, a close symbol is a symbol that's lock at declaration to not consider instantiation scope |
10:47:38 | FromDiscord | <evoalg> nice thank you ... as always you're awesome! It feels good to understand some of this |
10:49:22 | FromDiscord | <Elegantbeef> No problem and good day(night) |
11:16:42 | * | jjido joined #nim |
11:19:54 | FromDiscord | <Shiba> Can you run nim code on nim? |
11:20:29 | FromDiscord | <Shiba> Cna you run nim code in nim |
11:20:42 | FromDiscord | <Shiba> (edit) "nim" => "nim?" |
11:21:47 | FromDiscord | <Rika> ? |
11:21:48 | FromDiscord | <valerga> like macros? |
11:21:56 | FromDiscord | <Rika> The VM? NimScript? |
11:22:11 | FromDiscord | <Shiba> Yes |
11:22:27 | FromDiscord | <Rika> `nim e script.nims` |
11:22:55 | FromDiscord | <Rika> Limitations apply |
11:23:01 | FromDiscord | <valerga> i still need to make my first macro, i don't really understand them |
11:23:49 | FromDiscord | <valerga> what's a good exercise to get the subject? |
11:24:24 | FromDiscord | <valerga> the docs pass me by |
11:26:26 | FromDiscord | <Rika> In reply to @valerga "what's a good exercise": When you want to do something very repetitive and a proc can’t do it because you need to pass in code as data |
11:30:43 | FromDiscord | <valerga> tbh i've never had such problem |
11:31:01 | FromDiscord | <valerga> maybe because I never considered it |
11:32:25 | FromDiscord | <evoalg> In reply to @valerga "maybe because I never": there is https://dev.to/beef331/demystification-of-macros-in-nim-13n8 but I think Elegantbeef said some of that is outdated with new stuff? |
11:33:09 | FromDiscord | <evoalg> also https://forum.nim-lang.org/t/8658 ? |
11:40:22 | NimEventer | New thread by Pietroppeter: One Language to Rule the Mole, see https://forum.nim-lang.org/t/8780 |
11:45:49 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
12:04:28 | FromDiscord | <Rika> OMG thats cute |
12:10:06 | madprops | haha nice, i dig the mole |
12:10:35 | FromDiscord | <Rika> its good |
12:41:18 | FromDiscord | <SirOlaf> Feel like the bug from yesterday is on its last legs. It manages to resolve the overload correctly and just fails during type comparison |
12:52:34 | FromDiscord | <valerga> https://media.discordapp.net/attachments/371759389889003532/928994522086654022/backdrop-1920.jpg |
12:52:45 | FromDiscord | <valerga> a mole and his friends |
12:52:54 | FromDiscord | <SirOlaf> In reply to @SirOlaf "Feel like the bug": In fact, disabling the type check makes it work completely |
12:53:20 | FromDiscord | <SirOlaf> So just gotta make it accept the check |
12:55:51 | FromDiscord | <SirOlaf> Although [] isn't quite accepted for some reason |
12:57:53 | FromDiscord | <SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3LmM |
13:03:01 | * | jjido joined #nim |
13:06:41 | * | fvs quit (Quit: WeeChat 3.4) |
13:35:51 | FromDiscord | <eyecon> In reply to @valerga "what's a good exercise": There's https://dev.to/beef331/demystification-of-macros-in-nim-13n8 |
13:36:20 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
13:41:21 | * | qwr wouldn't say that something needs to be very repetative with macros, just use them when no other language feature can remove repeatation/boilerplate that annoys you |
13:41:53 | FromDiscord | <Rika> qwr: its a "general use case", not the only |
13:41:54 | FromDiscord | <Rika> just an idea |
13:42:07 | FromDiscord | <Rika> you can also use it to convert "ugly code" into nicer-looking code |
13:58:54 | FromDiscord | <pietroppeter> someone stop me... I may even have submitted the mole thread to an orange site... |
14:00:28 | * | rockcavera joined #nim |
14:00:28 | * | rockcavera quit (Changing host) |
14:00:28 | * | rockcavera joined #nim |
14:15:46 | FromDiscord | <SirOlaf> Anyone know how the compiler resolves nested generics |
14:22:27 | * | tiorock joined #nim |
14:22:27 | * | tiorock quit (Changing host) |
14:22:27 | * | tiorock joined #nim |
14:22:27 | * | rockcavera is now known as Guest2947 |
14:22:27 | * | tiorock is now known as rockcavera |
14:25:56 | * | Guest2947 quit (Ping timeout: 256 seconds) |
14:30:27 | * | arkurious joined #nim |
14:53:35 | PMunch | @SirOlaf, yes |
14:53:44 | PMunch | Well I certainly hope so |
14:54:18 | PMunch | @pietroppeter, I kinda like the idea of using a mole as a mascot |
14:54:41 | FromDiscord | <SirOlaf> Do you know? Because this generic borrow breaks apart for nested generics |
14:54:59 | FromDiscord | <SirOlaf> Picks the wrong candidate or something, still digging |
15:00:17 | FromDiscord | <SirOlaf> Decides that `proc (a: T, i: I: Ordinal, x: sink S)` is better than `proc (t: var DefaultTable[[]=.A, []=.B], key: A, val: sink B)` |
15:03:05 | FromDiscord | <Patitotective> Are nimble packages insenstive-case too? |
15:03:08 | FromDiscord | <Patitotective> (edit) "insenstive-case" => "insensitive-case" |
15:08:21 | FromDiscord | <Rika> package names? |
15:10:39 | FromDiscord | <Patitotective> yes |
15:10:50 | PMunch | @SirOlaf, I have no idea |
15:11:13 | PMunch | I was just joking by saying that someone probably knows, since you asked if anyone knows |
15:11:20 | PMunch | @Patitotective, nope |
15:11:37 | FromDiscord | <Patitotective> Ok thanks |
15:29:31 | FromDiscord | <ajusa> Is it possible to use strformat at run time? |
15:31:08 | FromDiscord | <ajusa> that doesn't make sense I guess since strformat can evaluate expressions, which requires it to be done at compile time. is strutils interpolation the best option at runtime then? |
15:32:51 | FromDiscord | <Rika> what? |
15:33:28 | FromDiscord | <Rika> do you mean `&some_runtime_string`? |
15:33:29 | FromDiscord | <Rika> no |
15:34:06 | FromDiscord | <ajusa> In reply to @Rika "do you mean `&some_runtime_string`?": yes, and I realize it isn't possible now. If the string is known at compile time though can I still do it? |
15:34:19 | FromDiscord | <Rika> well yes |
15:34:35 | FromDiscord | <Rika> !eval import strformat; let a = 2; let b = 3; const c = "{a+b}"; echo &c |
15:34:36 | NimBot | Compile failed: /usercode/in.nim(1, 65) Error: type mismatch: got <system.string> |
15:34:43 | FromDiscord | <Rika> whoaaaat |
15:34:49 | FromDiscord | <Rika> maybe static: ? |
15:35:00 | FromDiscord | <Rika> dunno im tired i dont want to deal with this |
15:35:28 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3Lo8 |
15:36:11 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/JdH |
15:36:22 | FromDiscord | <Rika> how do you know my age, thats sus |
15:36:27 | FromDiscord | <Rika> also no |
15:36:31 | FromDiscord | <Rika> technically no |
15:36:41 | FromDiscord | <Solitude> In reply to @Patitotective "Can I create a": stop pythoning |
15:36:42 | FromDiscord | <Rika> you will have to wrap your types in a variant type |
15:37:04 | FromDiscord | <Rika> yeah idk at that point use an object |
15:37:04 | FromDiscord | <Patitotective> In reply to @Solitude "stop pythoning": ;-; |
15:37:18 | FromDiscord | <Solitude> every single python refugee asks that question |
15:37:47 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Lo9 |
15:38:13 | FromDiscord | <Solitude> sent a code paste, see https://play.nim-lang.org/#ix=3Loa |
15:38:53 | FromDiscord | <Patitotective> In reply to @Solitude "read a tutorial https://nim-lang.org/docs/tut1.html": no, i mean, i dont want an object |
15:39:06 | FromDiscord | <Patitotective> but maybe a tuple hmmmm |
15:39:12 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3Lob |
15:39:33 | FromDiscord | <Patitotective> how would i use it? |
15:41:14 | NimEventer | New thread by Xigoi: Nimdenter, see https://forum.nim-lang.org/t/8781 |
15:41:28 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3Lod |
15:41:49 | FromDiscord | <Rika> In reply to @NimEventer "New thread by Xigoi:": holy fuck |
15:42:08 | FromDiscord | <Patitotective> hmmmmmmmmmmmm↵i will use an object, no one want tables |
15:42:09 | FromDiscord | <Patitotective> hehe |
15:42:15 | FromDiscord | <Patitotective> thanks anyways |
15:42:16 | FromDiscord | <Patitotective> 🙃 |
15:45:03 | FromDiscord | <Patitotective> well, hehe, im really trying to simulate (or emulate if you think) this library in nim https://patitotective.github.io/PREFS/ |
15:45:08 | FromDiscord | <Patitotective> any suggestions? |
15:45:09 | FromDiscord | <Patitotective> lol |
15:45:13 | FromDiscord | <Patitotective> (edit) "https://patitotective.github.io/PREFS/" => "https://patitotective.github.io/PREFS" |
15:49:10 | FromDiscord | <Rika> the object variant |
15:49:47 | FromDiscord | <Rika> it seems well defined and the types arent variable, so yeah its an appropriate use case |
15:50:16 | FromDiscord | <Rika> you can see that its used in the json module |
15:50:26 | FromDiscord | <Patitotective> let me see |
15:51:14 | FromDiscord | <ajusa> In reply to @NimEventer "New thread by Xigoi:": This is hilarious |
15:55:21 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Loq |
15:56:17 | * | pro joined #nim |
16:00:04 | FromDiscord | <Rika> pretty much |
16:26:19 | FromDiscord | <SirOlaf> Why does magic bypass matchesAux in matches |
17:08:06 | FromDiscord | <Patitotective> should i follow this style guide? https://nim-lang.org/docs/nep1.html |
17:11:27 | FromDiscord | <auxym> probably. I think it's the style most of the community uses. |
17:41:17 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LoX |
17:43:19 | FromDiscord | <eyecon> How does the compiler distinguish `a.b` referring to the value of a (potentially callable) field `b` of `a` or the result of `b(a)`? Simply based on the non-existence of the other? |
17:44:40 | FromDiscord | <eyecon> E.g. I say `if s.len == 3` and this is understood as `if len(s) == 3` but it could also have been a field `len` of the variable `s` |
17:45:47 | FromDiscord | <el__maco> I would assume one of these forms takes precedence and that's it? |
17:50:01 | FromDiscord | <eyecon> I'm on a roll with compiler crashes I guess: https://play.nim-lang.org/#ix=3Lp3 |
17:51:11 | FromDiscord | <eyecon> sent a code paste, see https://play.nim-lang.org/#ix=3Lp5 |
17:51:31 | FromDiscord | <ajusa> In reply to @eyecon "This is an honor:": I don't think that's a compiler crash? You're calling a function that hasn't been initialized |
17:52:01 | FromDiscord | <eyecon> I get that, but shouldn't the compiler catch this case? |
17:52:48 | FromDiscord | <eyecon> Ah, you mean it's a runtime crash |
17:52:53 | FromDiscord | <ajusa> Ye |
17:52:54 | FromDiscord | <eyecon> Sorry, you're right of course |
17:53:16 | FromDiscord | <eyecon> My point was that it could have been caught at the compilation phase |
17:53:22 | FromDiscord | <ajusa> Adding `myspecial.len = proc(): int = 5` and reordering code to make sense results in it working. |
17:54:00 | FromDiscord | <SirOlaf> Might be a bug with default object constructors |
17:55:03 | FromDiscord | <SirOlaf> If not, only way to prevent would be tracking if it's initialized and that's hard |
17:55:11 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3Lp8 |
17:55:15 | FromDiscord | <ajusa> See https://nim-lang.org/docs/manual_experimental.html#strict-not-nil-checking |
17:56:33 | FromDiscord | <ajusa> I believe Araq has mentioned or alluded to making not nil the default for Nim 2, as that'd be a pretty large breaking change (many people use nil, especially with C libraries). That's one of the reasons it isn't enabled by default right now. |
17:57:25 | FromDiscord | <eyecon> Yes, explicit nillability (nilability?) would change so much |
17:57:50 | FromDiscord | <eyecon> In reply to @el__maco "I would assume one": I guess it's the field access that has higher precedence: https://play.nim-lang.org/#ix=3Lp9 |
17:58:13 | FromDiscord | <SirOlaf> In reply to @eyecon "Yes, explicit nillability (nilability?)": Sounds like it would also change the compile times in a bad way |
17:58:56 | FromDiscord | <eyecon> It's good to know that `b(a)` remains unambiguous though |
18:00:06 | * | pro quit (Quit: WeeChat 3.4) |
18:06:46 | FromDiscord | <ajusa> Is there a parseSomeNumber or something similar that parses to an Int, then tries parsing to a float? |
18:07:13 | FromDiscord | <eyecon> But which type would it return? |
18:07:23 | FromDiscord | <ajusa> Some number is a type |
18:07:33 | FromDiscord | <ajusa> Oh wait it mostly for procs, never mind |
18:08:00 | FromDiscord | <ajusa> Guess I'll do it explicitly and use a template for reusability |
18:16:19 | * | mikko quit (Quit: WeeChat 2.7.1) |
18:40:30 | * | krux02_ joined #nim |
18:42:22 | FromDiscord | <auxym> SomeNumber is a typeclass, not a type |
18:44:04 | FromDiscord | <auxym> The return type of a proc needs to be known at compile time. Nim is a static language, your proc (or template) cannot decide to return either a float or an int based on its input at runtime. |
18:45:55 | * | user_ joined #nim |
18:46:38 | * | user_ quit (Client Quit) |
18:46:44 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3Lpp |
18:49:26 | FromDiscord | <auxym> That could work, but I think you'd need `{.dirty.}` or `{.inject.}` otherwise `n` will get gensym'd to some garbled name. |
18:49:56 | FromDiscord | <auxym> Oh I see you're passing it as a param |
18:50:10 | FromDiscord | <auxym> should be good |
18:51:38 | FromDiscord | <auxym> As long as everything in `body` assumes `n` is SomeNumber and not specifically a float or int. |
18:51:55 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3Lps |
18:52:11 | FromDiscord | <ajusa> I'm pretty proud of this for validation, reduces a ton of the code I'd need to write otherwise. |
18:53:13 | FromDiscord | <auxym> Yeah, that's what great about nim templates and macros |
18:53:30 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3Lpt |
19:00:18 | NimEventer | New thread by JohnAD: Fully understanding closure iterators, see https://forum.nim-lang.org/t/8782 |
19:05:59 | * | pippin left #nim (#nim) |
19:07:12 | FromDiscord | <SirOlaf> Have another question that will probably go unanswered, is there a function to recursively the basetypes of distinct generics |
19:07:20 | FromDiscord | <SirOlaf> (edit) "Have another question that will probably go unanswered, is there a function to recursively ... the" added "determine" |
19:07:44 | FromDiscord | <SirOlaf> Specifically of their type parameters |
19:08:16 | FromDiscord | <SirOlaf> Think that's the thing that's missing to make borrowed generic functions work |
19:12:50 | * | Gustavo6046 joined #nim |
19:15:14 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LpE |
19:15:16 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/pC5 |
19:15:54 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LpE" => "https://play.nim-lang.org/#ix=3LpF" |
19:16:09 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LpF" => "https://play.nim-lang.org/#ix=3LpG" |
19:18:35 | FromDiscord | <SirOlaf> Should work if you make the prefs argument var |
19:18:43 | FromDiscord | <Patitotective> let me try |
19:22:29 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LpI |
19:23:42 | FromDiscord | <Patitotective> Shouldn't `PContent` be `OrderedTable[string, PrefsNode]`? |
19:42:07 | * | fvs joined #nim |
19:42:27 | FromDiscord | <Casey.McMahon> sent a code paste, see https://play.nim-lang.org/#ix=3LpO |
19:42:36 | FromDiscord | <Casey.McMahon> (edit) "https://play.nim-lang.org/#ix=3LpO" => "https://play.nim-lang.org/#ix=3LpP" |
19:44:15 | FromDiscord | <leorize> depends on the degree of complexity you want your system to be capable of |
19:44:43 | * | PMunch quit (Quit: leaving) |
19:45:46 | FromDiscord | <Casey.McMahon> haha, what do you mean? |
19:46:29 | FromDiscord | <leorize> do you want to be aware of cmake's syntax to replace things, or do you just want quick 'n dirty text replacement? |
19:48:10 | FromDiscord | <Casey.McMahon> quick n dirty for now |
19:50:53 | FromDiscord | <Isofruit> So you have a file and want to find and replace "foo bar baz" with "foo bat cave" in that file, as a one-of? |
19:50:59 | FromDiscord | <leorize> the `lines` iterator is useful for extracting lines, then pair it with `regex` or `npeg` to extract what you need |
20:13:11 | FromDiscord | <Patitotective> btw This is how package's structure looks like https://media.discordapp.net/attachments/371759389889003532/929105404829503508/Screenshot_from_2022-01-07_15-07-33.png |
20:13:12 | FromDiscord | <Patitotective> I've got some types defined in `niprefs/prefs.nim` and in `niprefs.nim` I have `import niprefs/prefs` but I'm not able to use those types when importing _niprefs_ with `import niprefs` but it works with `import niprefs/prefs` |
20:13:33 | FromDiscord | <Patitotective> (edit) "I've got some types defined in `niprefs/prefs.nim` and in `niprefs.nim` I have `import niprefs/prefs` but I'm not able to use those types when importing _niprefs_ with `import niprefs` ... but" added "in an external module" |
20:16:37 | FromDiscord | <Patitotective> do i need to redefine them in `niprefs.nim`? |
20:17:05 | FromDiscord | <Patitotective> (all types in `niprefs/prefs.nim` are marked with `¨`) |
20:17:08 | FromDiscord | <Patitotective> (edit) "`¨`)" => "``)" |
20:17:13 | FromDiscord | <leorize> you have to re-export it in `niprefs` |
20:17:18 | FromDiscord | <leorize> Nim does not have package imports |
20:17:31 | FromDiscord | <Patitotective> In reply to @leorize "you have to re-export": re-export? |
20:17:52 | FromDiscord | <leorize> add `export prefs` in `niprefs.nim` |
20:18:17 | FromDiscord | <Casey.McMahon> sent a code paste, see https://play.nim-lang.org/#ix=3Lq1 |
20:18:48 | FromDiscord | <Patitotective> In reply to @leorize "add `export prefs` in": Thanks 🙃 |
20:20:14 | FromDiscord | <leorize> that works, regex would be a touch more efficient but this one is simple enough↵(@Casey.McMahon) |
20:28:12 | FromDiscord | <leorize> though instead of using a boolean, `break` is much better |
20:28:20 | FromDiscord | <leorize> or `parseutils.skipUntil` |
20:34:08 | FromDiscord | <Isofruit> Man, I'm doing easy meta programming and my head still hurts |
20:34:27 | FromDiscord | <Isofruit> I can only imagine the brain-cramps you can give yourself if you actually dive deep into the topic |
20:35:39 | FromDiscord | <leorize> my advise for you would be less spontaneous mutations and more general rewrites |
20:37:11 | FromDiscord | <leorize> the AST structure punishes spontaneous mutation by trapping you in a maze of complexity |
20:37:47 | FromDiscord | <Isofruit> I'm not even dealing with macros, just pragmas whose values I want to access at compile time |
20:37:57 | FromDiscord | <Isofruit> But some of these pragmas are associated with types in Options |
20:37:59 | FromDiscord | <Isofruit> and gnaaaaaa |
20:38:18 | FromDiscord | <leorize> using macros might be better lol |
20:38:48 | FromDiscord | <leorize> the API for non-macro stuff is just sad in my experience |
20:39:14 | FromDiscord | <Isofruit> Before I give myself that type of migraine, mind taking a look at a code-sample and tell me if that's really better done with macros? |
20:39:27 | FromDiscord | <leorize> sure |
20:39:33 | FromDiscord | <Isofruit> You familiar with norm? |
20:40:04 | FromDiscord | <leorize> I'm somewhat familiar |
20:41:21 | FromDiscord | <Isofruit> That already works, because that mean's you're likely familiar that it has the concept of `Model` a `{.tableName.}` pragma and that you can grab a Model's SQL table via the `table()` function |
20:45:58 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3Lqb |
20:47:24 | FromDiscord | <Isofruit> Lets call that proc `getRelatedFieldName`↵If I go `getRelatedFieldName(B, A)` I want that to output `myA`.↵Mort importantly, I want `getRelatedFieldName(B, Surprise)` to ALSO output `myA`. |
20:48:14 | FromDiscord | <leorize> definitely macros for this |
20:48:28 | FromDiscord | <SirOlaf> Look what you made me do https://media.discordapp.net/attachments/371759389889003532/929114288445083658/Capture.PNG |
20:48:42 | FromDiscord | <Isofruit> I claim innocence |
20:48:50 | FromDiscord | <leorize> but fair warning\: typed macros are the stairways to madness |
20:48:55 | * | jjido joined #nim |
20:49:02 | FromDiscord | <Isofruit> It's just |
20:49:02 | FromDiscord | <Isofruit> Gnaaa |
20:49:19 | FromDiscord | <SirOlaf> All I needed was someone that knows how generics work |
20:49:51 | FromDiscord | <Isofruit> I have multiple models to the same SQL Tables for simplicity reasons.↵And I just want to get the foreign key field name somewhat dynamically >_> |
20:50:23 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Lqd |
20:50:29 | FromDiscord | <Isofruit> Oh well, I guess looking into macros or madness |
20:50:48 | FromDiscord | <SirOlaf> I am now in need of an algorithm that pulls out child nodes into branches that are distinct generic types |
20:51:38 | FromDiscord | <Isofruit> What should the code you just posted express Patitotective? |
20:52:54 | FromDiscord | <Patitotective> `PrefsNodeObj` is an object that can have multiple types because I want to create a custom table that supports different value types |
20:53:03 | FromDiscord | <Patitotective> and I want it to be able to store enums |
20:53:37 | FromDiscord | <Patitotective> `PrefsNodeKind` represents the type `PrefsNodeObj` can have |
20:53:56 | FromDiscord | <Patitotective> (edit) "type" => "types" |
20:54:17 | FromDiscord | <Isofruit> You want to define enums at runtime then? Or at compile time? |
20:54:51 | FromDiscord | <leorize> you should try my union\: https://github.com/alaviss/union↵(@Patitotective) |
20:56:20 | FromDiscord | <Patitotective> In reply to @leorize "you should try my": oh, so i can delete all my code and just make `OrderedTable[string, union(int, string, etc)]`? |
20:57:03 | FromDiscord | <Isofruit> It keeps being true: The best code is the code you don't write yourself. Until it isn't |
20:57:27 | FromDiscord | <Patitotective> In reply to @Isofruit "It keeps being true:": dont say that ;-; |
20:58:11 | FromDiscord | <Isofruit> If I could already have a library that did this generic stuff for me and not have to write it myself? |
20:58:22 | FromDiscord | <Isofruit> I would delete the hundreds of lines of code I already have in a heartbeat! |
20:58:44 | FromDiscord | <leorize> pretty much↵(@Patitotective) |
20:59:01 | FromDiscord | <leorize> I have like one user atm so I always welcome more \:p |
20:59:49 | FromDiscord | <Patitotective> In reply to @leorize "I have like one": i'll be glad to use someone else's code lmao↵nice package 🙃 |
20:59:51 | FromDiscord | <Patitotective> (edit) "🙃" => "👍" |
21:04:51 | FromDiscord | <Isofruit> Okay, macros seem intimidating |
21:04:59 | FromDiscord | <Isofruit> I'll give generic typing one more try |
21:05:11 | FromDiscord | <leorize> while you try that I'll write you a quick macro |
21:05:31 | FromDiscord | <Isofruit> `when`, come to my aid! |
21:07:17 | * | dithpri joined #nim |
21:07:26 | FromDiscord | <Patitotective> In reply to @leorize "while you try that": seems like _union_ is not published in nimbe (?) should i install from the github repo? |
21:07:31 | FromDiscord | <Patitotective> (edit) "nimbe" => "nimble" |
21:08:16 | FromDiscord | <leorize> yea you should |
21:11:39 | FromDiscord | <Isofruit> I think I can solve this... If I manage to access the type `A`in a `none(A)` case so I can call `A.table()` |
21:12:02 | * | fvs left #nim (WeeChat 3.4) |
21:12:03 | FromDiscord | <Isofruit> (edit) "so" => "of `Option[A]`so" |
21:13:13 | * | Lord_Nightmare quit (Ping timeout: 256 seconds) |
21:13:14 | FromDiscord | <Isofruit> I can already check whether `Option[Whatever]` contains a Model or not, I'm just struggling with accessing the typedesc |
21:13:51 | FromDiscord | <Isofruit> (edit) "I can already check whether ... `Option[Whatever]`the" added "in" | "contains a Model" => "the `Whatever` inherits from `Model`" |
21:14:28 | FromDiscord | <SirOlaf> The compiler can now translate `var Table[system.string, DefaultTable[system.string, system.string]]` into `var Table[system.string, Table[system.string, system.string]]` and yet my fix does not work |
21:14:54 | FromDiscord | <SirOlaf> Has Beef resurrected yet |
21:15:34 | FromDiscord | <Isofruit> Is beef the messiah? |
21:16:15 | * | Lord_Nightmare joined #nim |
21:16:30 | FromDiscord | <SirOlaf> Am hoping this gives him some new ideas, because I'm about to run out of them |
21:17:50 | FromDiscord | <leorize> wdym trouble with accessing the typedesc?↵(@Isofruit) |
21:20:09 | FromDiscord | <Isofruit> Remember the earlier types.↵`B.table()` works. If I can access the type B itself (which I assume is called `typedesc` since you do `proc(a: typedesc[T])` when you want to tell a proc the parameter will be the type and not an instance of it), I'm done |
21:20:50 | FromDiscord | <leorize> you mean you wanna access `Whatever` in `Option[Whatever]`? |
21:21:03 | FromDiscord | <Isofruit> Yeah, specifically `Whatever` and not an instance of it |
21:21:15 | FromDiscord | <Isofruit> because the instance can be none |
21:21:17 | FromDiscord | <Isofruit> and none murders me |
21:21:23 | FromDiscord | <leorize> typetraits has the answers what you need |
21:22:59 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3Lqp |
21:23:04 | * | Lord_Nightmare quit (Quit: ZNC - http://znc.in) |
21:23:04 | FromDiscord | <Isofruit> Oh, typetraits |
21:23:11 | FromDiscord | <Isofruit> Hmmmm |
21:23:55 | FromDiscord | <reilly> Looking at the example given for methods in the manual (https://nim-lang.org/docs/manual.html#methods), I don't really see what makes this functionally any different from regular old procs. |
21:25:07 | * | Lord_Nightmare joined #nim |
21:26:22 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Lqr |
21:27:13 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3Lqr" => "https://play.nim-lang.org/#ix=3Lqs" |
21:28:59 | FromDiscord | <Patitotective (Patitotective)> sent a long message, see http://ix.io/3Lqu |
21:31:00 | * | rockcavera quit (Remote host closed the connection) |
21:31:00 | FromDiscord | <leorize> sent a code paste, see https://paste.rs/NNv |
21:31:03 | FromDiscord | <Patitotective (Patitotective)> sent a code paste, see https://play.nim-lang.org/#ix=3Lqw |
21:32:46 | FromDiscord | <leorize> sent a code paste, see https://play.nim-lang.org/#ix=3Lqx |
21:33:05 | FromDiscord | <leorize> note that `Content` is merely an alias, any other `union(string | int | bool)` is the same as `Content` |
21:34:22 | FromDiscord | <leorize> the best way to see it is to change all `method` -\@reilly) |
21:34:37 | FromDiscord | <ajusa> oh hey union I love that library, used it a few projects of mine |
21:34:47 | FromDiscord | <Isofruit> Found the one user |
21:35:10 | FromDiscord | <leorize> I guess I have more than one users lol |
21:35:21 | FromDiscord | <Isofruit> Now you have |
21:35:23 | FromDiscord | <Isofruit> TWO users |
21:36:21 | FromDiscord | <ajusa> before union: `TypeKind = enum tkString, tkInt, tkFloat`↵after union: `VNType = union(int | float | string)`↵I just wish it had more docs, and some integration with the pattern matching that hax built |
21:37:25 | FromDiscord | <Isofruit> I've read through typetraits now, I can't seem to find anything related to accessing nested types within objects↵Were you trying to point me towards "stripGenericParams" leorize? |
21:37:47 | FromDiscord | <haxscramper> There is a bug with generics that prevented from using union with pattern matching to the full extent, but in the end it does not require any special interactions |
21:38:24 | FromDiscord | <haxscramper> In reply to @haxscramper "anyway, if remove generics": This one |
21:38:54 | FromDiscord | <leorize> https://nim-lang.github.io/Nim/typetraits#genericParams.t%2Ctypedesc↵(@Isofruit) |
21:39:27 | FromDiscord | <Isofruit> squints↵Hmmmm I assume that's banking on that Option is an enum |
21:40:29 | FromDiscord | <Isofruit> Ohhhhhh |
21:40:47 | FromDiscord | <Isofruit> When I played around with it I was an idiot and gave it an instance, not a type |
21:47:36 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3LqF |
21:47:58 | FromDiscord | <Solitude> .get |
21:48:04 | FromDiscord | <Solitude> .get(0) |
21:58:14 | FromDiscord | <Isofruit> SON OF A HORSESHOE IT WORKS |
21:59:14 | FromDiscord | <leorize> do let me know what docs would you like to see, I'll write some more when I have time↵(@ajusa) |
21:59:23 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3LqI |
21:59:32 | FromDiscord | <Isofruit> If anyone wanted to see the monstrosity I built |
22:00:28 | FromDiscord | <leorize> it's shorter than my macro, so there is that |
22:00:28 | FromDiscord | <haxscramper> I haven't checked it since then |
22:01:05 | FromDiscord | <Isofruit> Macros are one of those things I'm currently still too afraid to touch |
22:01:08 | FromDiscord | <Isofruit> Which is likely silly |
22:01:22 | FromDiscord | <leorize> you should not touch them now |
22:01:29 | FromDiscord | <Isofruit> But I'm already having my hands full comprehending my problems through the lenses of generics and templates |
22:01:33 | FromDiscord | <leorize> like you need a couple library to sanely program them |
22:02:15 | FromDiscord | <Isofruit> I assumed as much. I like templates though |
22:02:37 | FromDiscord | <Isofruit> They are fairly comprehensible, expand code into position X |
22:03:15 | FromDiscord | <Isofruit> Used one to save myself the hassle of doing the same try-except-sendHTTP400Response block over and over again where only the try block chances |
22:03:16 | FromDiscord | <leorize> templates are nice |
22:03:22 | FromDiscord | <Isofruit> (edit) "chances" => "changes" |
22:03:36 | FromDiscord | <leorize> use it in moderation to avoid code bloat, though |
22:04:09 | FromDiscord | <Isofruit> Yeh, I only intend to use the one, I see no usecase for others since I can typically do generics |
22:04:51 | FromDiscord | <Isofruit> My order of attempts pretty much goes:↵normal procs > generics > templates > macros (neeeeveeeeeer) |
22:05:00 | FromDiscord | <SirOlaf> Something you can't do is borrow generic function from generic types |
22:05:04 | FromDiscord | <SirOlaf> (edit) "function" => "functions" |
22:05:24 | FromDiscord | <leorize> I usually have to use a template in that case↵(@SirOlaf) |
22:05:37 | FromDiscord | <Isofruit> This sounds like the kind of idea I would only want to have after either copious amounts of coding to the point my brain is in delirium or alcohol |
22:06:02 | FromDiscord | <leorize> you should put macro in a separate branch of the tree lol |
22:06:37 | FromDiscord | <leorize> that stuff is not only more powerful, it doesn't have interop with non-macros |
22:07:03 | FromDiscord | <SirOlaf> In reply to @leorize "I usually have to": I have it fixed as long as the generics aren't nested, which is why I have been looking for assistance |
22:07:14 | FromDiscord | <Isofruit> I read templates are like the nice version of macros, limited but comprehensible.↵Are macros just massive code generators? |
22:07:50 | FromDiscord | <leorize> macros are code transformers |
22:08:03 | FromDiscord | <Isofruit> So a language over the language |
22:08:15 | FromDiscord | <leorize> sorta |
22:08:37 | FromDiscord | <leorize> I believe [Elegantbeef](https://matrix.to/#/@elegantbeef:matrix.org) got a fix or smt↵(@SirOlaf) |
22:08:54 | FromDiscord | <SirOlaf> He was helping me yesterday |
22:09:20 | FromDiscord | <SirOlaf> And we actually kinda did get it to work with flat generics, just didn't realize |
22:09:54 | FromDiscord | <leorize> \\o/ that's cool |
22:10:08 | FromDiscord | <SirOlaf> Issue is that nesting completely kills it |
22:10:29 | FromDiscord | <SirOlaf> And I have run out of ideas after converting the distinct type into base didn't work |
22:17:26 | FromDiscord | <Isofruit> If there is one thing I'm wonky on about generics with when statements is: You don't know if you built them wrong until you ensured every path of the when-controlflow has been traversed and not caused the compiler to die |
22:18:20 | FromDiscord | <Isofruit> Just found two bugs in the earlier generic thingy that I did not notice because my code example didn't use my generic function in a way that caused these "when" bits that were badly coded to ever be used |
22:18:43 | FromDiscord | <Isofruit> (edit) "Just found two bugs in the earlier generic thingy that I did not notice because my code example didn't use my generic function in a way that caused these "when" bits that were badly coded to ever be used ... " added "(I fixed it in the code sample I posted earlier, but dang)" |
22:21:49 | FromDiscord | <Elegantbeef> Concepts 😛↵(@Isofruit) |
22:22:04 | FromDiscord | <SirOlaf> The man is back |
22:22:08 | FromDiscord | <Elegantbeef> Isnt the nesting issue just cause of `val: B`↵(@SirOlaf) |
22:22:16 | FromDiscord | <SirOlaf> I have created a new error |
22:23:12 | FromDiscord | <SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3LqQ |
22:23:28 | FromDiscord | <SirOlaf> Which is strange, because the type is obviously completely different |
22:24:15 | FromDiscord | <SirOlaf> Basically semOverloadedCall (or rather semOverloadedCall) produces nonsense |
22:24:24 | FromDiscord | <SirOlaf> (edit) "semOverloadedCall)" => "semResolvedCall)" |
22:24:39 | FromDiscord | <Isofruit> In reply to @Elegantbeef "Concepts 😛 (<@180601887916163073>)": Sorry, generics + work noodled my brain through, I know you want to express sth. related to when we last chatted with that, but my brain is just not parsing it atm. |
22:24:46 | FromDiscord | <Elegantbeef> What's your searchforborrowproc look like now? |
22:24:48 | FromDiscord | <Elegantbeef> Also how did you reason what to skip and what not to? |
22:25:26 | FromDiscord | <SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3LqR |
22:25:43 | FromDiscord | <SirOlaf> Actually quite simple and elegant, but should check more node types |
22:25:47 | FromDiscord | <Elegantbeef> I'm saying using concepts will ensure the stuff works at compile time instead of at instantiation |
22:26:03 | FromDiscord | <Elegantbeef> We dont want to base layered generics afaik |
22:26:31 | FromDiscord | <Isofruit> concepts as in "think this through beforehand and have a concept of it in your head already before you start"? |
22:26:33 | FromDiscord | <Elegantbeef> with what we had yesterday was the issue not just `val: B` was dropped to `Table[string, seq[string]]`? |
22:26:36 | FromDiscord | <SirOlaf> In reply to @Elegantbeef "We dont want to": Well yeah, probably not seeing how my thing doesn't work at all |
22:26:39 | FromDiscord | <Elegantbeef> No the Nim concepts system |
22:26:47 | FromDiscord | <SirOlaf> (edit) "not" => "not," |
22:26:54 | FromDiscord | <Isofruit> https://tenor.com/view/umm-confused-blinking-okay-white-guy-blinking-gif-7513882 |
22:27:13 | FromDiscord | <Isofruit> I shall google that one |
22:27:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LqS |
22:27:37 | FromDiscord | <Isofruit> I have not ever seen that |
22:27:49 | FromDiscord | <Elegantbeef> It user defined duck typing basically |
22:27:50 | FromDiscord | <Isofruit> Not even seen a single line of code with a "concept" thingy in it |
22:28:01 | FromDiscord | <Elegantbeef> Kinda like TS interfaces |
22:28:25 | FromDiscord | <SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3LqT |
22:28:42 | FromDiscord | <Isofruit> Wait! I do TS! ... could this have made my thingy easier?↵I'll need to have a read on that, recover brainmass and then see |
22:28:49 | FromDiscord | <SirOlaf> My thought process when making the basify function was that B is Table but it gets DefaultTable |
22:29:13 | FromDiscord | <Elegantbeef> Concepts are compile time interfaces, you define a Concept and use it as a type class to limit what types can be used |
22:29:31 | FromDiscord | <Elegantbeef> No the issue is the otherway around |
22:29:40 | FromDiscord | <Elegantbeef> B is `DefaultTable` but it gets `Table` |
22:30:04 | FromDiscord | <Elegantbeef> I think we should only skip generics if they dont have `tfFromGeneric` in the type flags |
22:30:12 | FromDiscord | <Elegantbeef> Though that might be wrong |
22:30:19 | FromDiscord | <Elegantbeef> Sorry "only skip types"\ |
22:31:24 | FromDiscord | <SirOlaf> Can we verify what B is |
22:32:11 | FromDiscord | <SirOlaf> In reply to @Elegantbeef "I think we should": And in what step would this be done |
22:32:12 | FromDiscord | <Elegantbeef> B in our case is going to be what ever type `val` gets so it should be the B parameter of DefaultTable which in this case is `DefaultTable[string, string]` |
22:32:33 | FromDiscord | <Elegantbeef> When making the call in search for borrow i think |
22:32:34 | FromDiscord | <Elegantbeef> I could be wrong |
22:33:14 | FromDiscord | <Isofruit> > Now I know why I don't know of Concepts! |
22:33:25 | FromDiscord | <Isofruit> I have never even looked at experimental features |
22:33:41 | FromDiscord | <Isofruit> https://nim-lang.org/docs/manual_experimental.html#concepts↵Good to know there's docs on it though |
22:35:29 | FromDiscord | <Isofruit> Ohhh and that way I could've narrowed down the generic type I use in `getRelatedFieldName` to types that have these characteristics that I need |
22:36:21 | FromDiscord | <Elegantbeef> Well concepts dont need a flag and i've used them a fair bit |
22:36:22 | FromDiscord | <Elegantbeef> The syntax might be a bit confusing, but otherwise they're nice |
22:37:12 | FromDiscord | <Elegantbeef> Yep if you're doing something where you want duck typing but it to be more concrete this is how you get it. |
22:37:16 | FromDiscord | <Isofruit> Which... I don't think would've spared me from writing that logic out in the first place on how to extract a given tablename from either a norm-model-type directly, an fk-pragma or an Option[norm-model-type]... I think I'd have still needed to write that out |
22:37:52 | FromDiscord | <Isofruit> (edit) "Which... I don't think would've spared me from writing that logic out in the first place on how to extract a given tablename from either a norm-model-type directly, an fk-pragma ... or" added "on a field of a norm-model-type" |
22:38:21 | FromDiscord | <Isofruit> Would (and still can) narrow down the interface nicely though |
22:38:56 | FromDiscord | <Isofruit> (edit) "interface nicely" => "types you can throw into that function" |
22:39:07 | FromDiscord | <Isofruit> (edit) "Would (and still can) narrow down the types you can throw into that function ... though" added "nicely" |
22:39:34 | FromDiscord | <SirOlaf> sent a code paste, see https://paste.rs/4SW |
22:39:44 | FromDiscord | <Elegantbeef> No |
22:39:49 | FromDiscord | <Elegantbeef> I mean inside searchForBorrowProc |
22:39:59 | FromDiscord | <Elegantbeef> Skip over the parameters that come from generic |
22:40:17 | FromDiscord | <Elegantbeef> Since when borrowing anything that's from generic is not going to be the distinct we want |
22:41:02 | FromDiscord | <SirOlaf> Why would basically removing parameters help |
22:41:09 | FromDiscord | <Elegantbeef> We arent removing |
22:41:15 | FromDiscord | <Elegantbeef> We're not skipping over generics |
22:41:51 | FromDiscord | <Elegantbeef> in the example we have `var DefaultTable[string, DefaultTable[...]], key: string, val: DefaultTable[...]` |
22:42:16 | FromDiscord | <Elegantbeef> we're presently making it `Table[string , DefaultTable[...]], key: string, val: Table[...]` |
22:42:27 | FromDiscord | <Elegantbeef> The B of the first does not match the B of the proc, so there is a mismatch |
22:42:38 | FromDiscord | <Elegantbeef> It expects B to be a `DefaultTable`, but got `Table` |
22:42:47 | FromDiscord | <Elegantbeef> `<Table[system.string, DefaultTable[system.string, system.string]], string, Table[system.string, system.string]>` |
22:42:54 | FromDiscord | <Elegantbeef> Look at that error message |
22:43:17 | FromDiscord | <Elegantbeef> The proc def is `proc mgetOrPut[A, B](t: var Table[A, B]; key: A; val: B): var B` |
22:43:35 | FromDiscord | <Elegantbeef> The B in `Table[A, B]` does not match the B of `val: B` |
22:43:40 | FromDiscord | <SirOlaf> I see that, but whatever you mean by skip does not make sense to me |
22:44:00 | FromDiscord | <Elegantbeef> do not get the distinct base of any thing that comes from generic, just put the type you have there |
22:44:13 | FromDiscord | <Elegantbeef> So instead of writing `Table` in `val` we write `DefaultTable` |
22:45:04 | FromDiscord | <SirOlaf> Do you want the desiredTypes to be changed or something? There is nothing else being used for skipping, is there |
22:45:05 | FromDiscord | <Elegantbeef> The idea being i dont think it makes any sense to implement a generic proc where you want to get the base over any parameter that comes from generic |
22:45:20 | FromDiscord | <Elegantbeef> Inside search for borrow |
22:45:26 | FromDiscord | <Elegantbeef> Presently we do `t.getDistinctBase` or whatever it's called |
22:45:29 | FromDiscord | <Elegantbeef> On all parameters |
22:45:45 | FromDiscord | <Elegantbeef> We should only do it on parameters that arent from generic afaict |
22:46:08 | FromDiscord | <Elegantbeef> I cant give you a line number but it's in the for loop of search for borrow |
22:47:11 | FromDiscord | <SirOlaf> Can't hurt to try I guess |
22:48:19 | FromDiscord | <Isofruit> Leorize, you still reading? |
22:48:46 | FromDiscord | <Elegantbeef> We're on matrix saying our name pings us |
22:49:42 | FromDiscord | <Elegantbeef> Leroize they cant see reactions across the bridge |
22:49:56 | FromDiscord | <leorize> oh yea |
22:50:04 | FromDiscord | <leorize> o/ @Isofruit |
22:50:38 | FromDiscord | <Isofruit> I'm about to make an SO question + answer it myself (regarding the entire "access type within an option generically") so I can have an easier time googling that kind of problem in the future.↵Just wanted to ask whether you wanted a shoutout in the answer and to whom I should do that |
22:50:44 | FromDiscord | <SirOlaf> In reply to @SirOlaf "Can't hurt to try": What does hurt is that I am still not quite sure what the plan is. x gets set to t.baseOfDistinct, so stopping that makes x a bit questionable |
22:51:05 | FromDiscord | <Elegantbeef> This is what i have right now |
22:51:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LqY |
22:51:08 | FromDiscord | <Isofruit> Since you significantly helped me in that regard |
22:51:12 | FromDiscord | <SirOlaf> In reply to @Elegantbeef "This is what i": And does it work |
22:51:19 | FromDiscord | <leorize> I don't have an SO account unfortunately↵(@Isofruit) |
22:51:19 | FromDiscord | <Isofruit> ~~Aka pushed me face first towards the solution~~ |
22:51:20 | FromDiscord | <Elegantbeef> It does not |
22:51:39 | FromDiscord | <Elegantbeef> It still fails sem overload, but this is the correct thing to do afaict |
22:52:29 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LqZ |
22:52:30 | FromDiscord | <Elegantbeef> Which is what we want |
22:53:00 | FromDiscord | <Elegantbeef> We now just have the issue that semoverloadedcall doesnt like the types |
22:53:43 | FromDiscord | <Isofruit> In reply to @leorize "I don't have an": Discord name mention in the SO answer it is 😛 |
22:53:46 | FromDiscord | <SirOlaf> It has never liked the types |
22:54:09 | FromDiscord | <Elegantbeef> We finally have the right types though |
22:54:36 | FromDiscord | <Elegantbeef> So now we only have to question "why does sem overload not like us" |
22:56:06 | FromDiscord | <SirOlaf> Culprit is still semResolvedCall |
22:56:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Lr1 |
22:57:08 | FromDiscord | <SirOlaf> resolveOverloads decides on ` proc (t: var Table[mgetOrPut.A, mgetOrPut.B], key: A, val: B): var B` which should be right |
22:57:13 | FromDiscord | <SirOlaf> (edit) "` proc" => "`proc" |
22:58:36 | FromDiscord | <SirOlaf> Or maybe I'm in the wrong section, but something does decide on that signature |
22:59:15 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Lr2 |
23:01:33 | FromDiscord | <SirOlaf> In reply to @SirOlaf "Or maybe I'm in": I was checking pickBestCandidate, but that just returns good candidates so resolveOverloads does decide on it |
23:01:50 | FromDiscord | <Elegantbeef> Have you tried to start on the macro patito? |
23:02:02 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Lr5 |
23:02:06 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Have you tried to": yes lol |
23:02:31 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3Lr5" => "https://play.nim-lang.org/#ix=3Lr6" |
23:02:47 | FromDiscord | <Elegantbeef> content is going to be a `nnkCurly` with `colonExprExpr` as each value |
23:03:27 | FromDiscord | <Patitotective> where is that documented? |
23:03:28 | FromDiscord | <Elegantbeef> So what you'll want to do is iterate over everything in content getting the second element `[1]` and making it `infix(yourExpr[1], "as", ident"PContentTypes")` |
23:03:41 | FromDiscord | <Elegantbeef> do `echo treeRepr content` |
23:03:48 | FromDiscord | <Elegantbeef> It's documented in the AST of Nim |
23:04:04 | FromDiscord | <Elegantbeef> Actually this probably will be a `nnkTableConstr` |
23:04:09 | FromDiscord | <Elegantbeef> Eitherway same thing internally |
23:04:30 | FromDiscord | <Elegantbeef> It'll have a list of `a: b` in AST you want to grab `b` and replace it with `b as PTypeContent` |
23:04:56 | FromDiscord | <Elegantbeef> Then finally you'll do `newCall(bindSym"toOrderedTable", content)` |
23:05:01 | FromDiscord | <Elegantbeef> And that'll do it all for you |
23:05:32 | FromDiscord | <Elegantbeef> `bindSym` is needed if you `import std/tables` in the macro module and want to ensure it calls it regardless where you go if you dont `export tables` |
23:05:33 | FromDiscord | <Patitotective> let me try (btw i wasn't importing `std/macros` lol) |
23:05:35 | FromDiscord | <Patitotective> Thanks |
23:05:37 | FromDiscord | <Patitotective> 🙃 |
23:06:16 | FromDiscord | <leorize> if you'd like to see an auto-union for arrays and KV pairs, please open an issue |
23:06:21 | FromDiscord | <SirOlaf> So, I think this actually does work |
23:06:55 | FromDiscord | <SirOlaf> Comment out the ``result = nil` in the compareTypes branch |
23:06:58 | FromDiscord | <SirOlaf> For testing |
23:07:01 | FromDiscord | <SirOlaf> (edit) "``result" => "`result" |
23:07:50 | FromDiscord | <Patitotective> In reply to @leorize "if you'd like to": i will open a pull request when i solve it hehe |
23:08:49 | FromDiscord | <Elegantbeef> Ah so it perhaps may be my fault |
23:09:56 | FromDiscord | <SirOlaf> Question is why the type check fails even though it can be run |
23:11:37 | FromDiscord | <Elegantbeef> I dont even get what that branch is for |
23:12:05 | FromDiscord | <SirOlaf> Not sure either, but I discovered before that commenting out the result reset makes things work |
23:12:25 | FromDiscord | <SirOlaf> Because resolve does succeed |
23:12:38 | FromDiscord | <SirOlaf> It's probably an extra check in case the candidate is bad |
23:17:36 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/21C |
23:18:03 | FromDiscord | <Elegantbeef> I mean you can use return but it's not idiomatic |
23:18:10 | FromDiscord | <Elegantbeef> you need to annotate the macro with `: untyped` |
23:19:08 | FromDiscord | <Patitotective> Yeeey, it worked↵Thanks |
23:19:09 | FromDiscord | <Patitotective> 🙃 |
23:21:45 | FromDiscord | <SirOlaf> So yeah, with this line commented out, the original example from the github issue compiles too |
23:21:57 | FromDiscord | <SirOlaf> In other words, you were 100% right about skipping those types |
23:22:13 | FromDiscord | <SirOlaf> (edit) "So yeah, with this line commented out, the original example from the github issue compiles too ... " added "(after adding a []=)" |
23:22:21 | FromDiscord | <Elegantbeef> Dont say that it'll go straight to my head |
23:22:27 | FromDiscord | <Elegantbeef> Why are the types not equal is now the question |
23:22:52 | FromDiscord | <Elegantbeef> Dont add `[]=` |
23:22:58 | FromDiscord | <Elegantbeef> Just do `(nested["key1"]["key2"])` 😀 |
23:23:07 | FromDiscord | <Elegantbeef> That way you set the var that it returns |
23:23:26 | FromDiscord | <SirOlaf> Imagine choosing the ugly way |
23:24:01 | FromDiscord | <Elegantbeef> Hey it's the entire point of this |
23:24:17 | FromDiscord | <Elegantbeef> Someone didnt realize that `[]=` would need to be defined |
23:24:32 | FromDiscord | <Elegantbeef> Anyway we now need to figure out why compare types fails, the echo'd values were identical |
23:24:35 | FromDiscord | <Elegantbeef> So it's odd |
23:28:07 | FromDiscord | <SirOlaf> This problem never stops giving I guess |
23:29:24 | FromDiscord | <Elegantbeef> Hey you're "adding" a feature |
23:29:30 | FromDiscord | <Elegantbeef> It's complicated |
23:30:02 | FromDiscord | <SirOlaf> Oh no, it's great |
23:30:09 | FromDiscord | <SirOlaf> But it's surprising how deep it goes |
23:31:37 | FromDiscord | <Elegantbeef> Also you'll probably want/need to add that this and the composite type class works in the manual |
23:31:49 | FromDiscord | <Patitotective (Patitotective)> do you mean an issue to nim? lol↵(@Patitotective) |
23:32:30 | FromDiscord | <SirOlaf> In reply to @Elegantbeef "Also you'll probably want/need": Honestly have no idea what a composite type class is |
23:32:45 | FromDiscord | <SirOlaf> Just keep seeing it in the compiler but ignore it every time |
23:33:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Lrh |
23:33:44 | FromDiscord | <Elegantbeef> A composite typeclass is the magic typeclass for all generics of a given type |
23:34:08 | FromDiscord | <SirOlaf> Doesn't that get expanded to A[any] |
23:34:23 | FromDiscord | <Elegantbeef> No it's a composite typeclass |
23:34:27 | FromDiscord | <Elegantbeef> It doesnt expand |
23:34:34 | FromDiscord | <Elegantbeef> It's a `tyCompositeTypeClass` or w/e |
23:35:32 | FromDiscord | <SirOlaf> That works though, and I think I saw it getting expanded internally |
23:36:32 | FromDiscord | <Elegantbeef> Anyway araq said it should be documented and i havent got around to it |
23:36:49 | FromDiscord | <Elegantbeef> So as it's related seems like something you could take the time to do 😛 |
23:37:04 | FromDiscord | <Isofruit> Elegantly delegating beefy documentation |
23:37:08 | FromDiscord | <Isofruit> I see I see |
23:37:16 | FromDiscord | <Isofruit> 😄 |
23:37:47 | * | cyraxjoe joined #nim |
23:37:52 | * | MightyJoe quit (Ping timeout: 256 seconds) |
23:37:57 | FromDiscord | <Elegantbeef> Eh i fixed the issue didnt think it needed to be documented |
23:38:02 | FromDiscord | <Elegantbeef> Someone merged it before i could add documentation |
23:38:05 | FromDiscord | <Elegantbeef> It's not my fault! |
23:38:59 | FromDiscord | <Isofruit> Fully fair 😄 I just saw an opportunity and had to take it |
23:41:52 | FromDiscord | <Isofruit> Alrighty, enough coded for today, solving this damn "get me the related field between two models based on tablenames" issue took like 3h |
23:42:20 | FromDiscord | <Elegantbeef> Code review time? |
23:44:08 | FromDiscord | <Isofruit> Look, I barely managed to code that monstrosity up there, I barely managed to find a single way to write this, I got leorize to see if he couldn't do it via macro rather than try the path of generics.↵I don't see myself writing a better version of the above until I've gained a lot more experience in the language |
23:44:41 | FromDiscord | <Isofruit> I think my remaining brain cells will just implode |
23:44:51 | FromDiscord | <Elegantbeef> Ok |
23:45:21 | FromDiscord | <Isofruit> unless |
23:45:24 | FromDiscord | <Elegantbeef> Can i atleast see the code? |
23:45:30 | FromDiscord | <Isofruit> I noticed it is an utter pain in the neck to chain when conditions |
23:46:30 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3Lrn |
23:47:37 | FromDiscord | <Isofruit> That code tries to find the foreign-key-field of the model that points from Model B to Model A.↵But it makes sure to check this based on tablename and not just the model-type |
23:47:40 | FromDiscord | <SirOlaf> sent a code paste, see https://play.nim-lang.org/#ix=3Lro |
23:47:52 | FromDiscord | <Elegantbeef> You can reduce the number of when statements! |
23:48:09 | FromDiscord | <Isofruit> I tried to throw them together with "and" statements, I got compilation issues |
23:48:26 | FromDiscord | <Isofruit> So at some point I just gave up and made one when per expression |
23:50:16 | FromDiscord | <Isofruit> ~~There's only so much you can do before you just submit to the compiler~~ |
23:50:59 | FromDiscord | <Elegantbeef> Is it the `var distinct`?↵(@SirOlaf) |
23:51:25 | FromDiscord | <SirOlaf> Not quite sure yet |
23:51:43 | FromDiscord | <SirOlaf> But possible I guess |
23:52:28 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
23:52:38 | FromDiscord | <SirOlaf> result = sameFlags(a, b) |
23:52:39 | FromDiscord | <SirOlaf> This fails |
23:52:45 | FromDiscord | <SirOlaf> The flags just aren't the same |
23:54:58 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3Lrq |
23:56:46 | FromDiscord | <SirOlaf> One of the two types has the tfVarIsPtr flag |
23:56:51 | FromDiscord | <SirOlaf> Other doesn't |
23:57:03 | FromDiscord | <SirOlaf> What does this flag mean |
23:59:00 | FromDiscord | <Elegantbeef> `# 'var' type is translated like 'ptr' even in C++ mode` |
23:59:25 | FromDiscord | <SirOlaf> Oh, it has documentation |
23:59:34 | FromDiscord | <SirOlaf> Nice |
23:59:44 | FromDiscord | <Elegantbeef> Yea rare Nim compiler comments |