Conversation

Idly wondering if it'd be possible to extend Rust procedural macros with some sort of interface to the name resolver, typechecker, and const eval. Sort of a principled approach to template metaprogramming...
8
56
name resolution yes, that's already hooked up into it. however, we'd have to replace the mess that it is right now with some kind of generalized "5D chess with multiverse time-travel" typeck/const-eval have a similar but worse issue wrt traits - you'd have to ban new impls (1/2)
1
8
i.e. you cannot allow a proc macro that has *observed* typeck/const-eval (or anything else that can involve trait impls) from producing (anything that expands to) a new impl theoretically you can do the "multiverse time-travel" thing for trait coherence but it's quite mad (2/2)
2
10
like at that point you just need to throw the query system out the window and replace it with graph computation that runs to a fixpoint and can keep invalidating itself. and you have to error on anything that causes the grandparent paradox, like we do rn in name resolution (3/2)
2
7
it's conceptually nice and it might be the only way Rust can hope to ever have a spec but... idk who else I can get on board that we can't keep reimplementing the "5D chess with multiverse time-travel" thing by hand in a million little subtly-different ways all over rustc (4/2)
2
9
can either of these "feed back", from a later stage back into an early stage? this is what I mean by "time travel". the "multiverse" part refers to the possibility of creating multiple timelines by doing so (which may be allowed if they "converge" again to the same result)
1
my understanding is that pretty much every single existing system is DAG-shaped, if it's general enough, and the circular dependencies arise more often in unprincipled implementations that "do whatever" and "let things happen"
2
Replying to and
I'd be interested to know if Klister is DAG shaped or not… but not sure if it would help much? Thinking about stuff like adding impls makes my brain hurt…
Quote Tweet
Replying to @pcwalton
tydeworkshop.org/2020-abstracts > Klister’s macros are hygienic in that they prevent variable capture by default, and they are type-driven in that macros have access to the type that is expected for the expression that is to be produced By @d_christiansen, @haskell_cat and Langston B.