|
|
|
|
|
by Jugglerofworlds
2230 days ago
|
|
Do dependent types really eliminate the need for macros? As far as I can tell you cannot pattern match against values of type Type in dependent languages, so I don’t see how you could generate a JSON parser without some kind of reflection. |
|
1 - 'compile-time' code execution of some arbitrary code with the result of that execution then being available at run time
2 - a specific type of function which takes the AST of some language and then uses some procedural methodology to mutate/alter that AST transforming it into some other AST
I would say, that while dependent types can be a useful basis for covering several of the typical use cases of macros, they do not without some additional structure, provide a firm proof/type theory for the whole scope of macros.
I would suggest that the most sound attempts at describing the computational phenomena encapsulated by the most common usage of the term 'macro' would be found in the following: a) implementation of Temporal Logic (per Frank Pfenning's interpretation) for description of compile-time code execution and b) implementation of Modal Logic, describing multi-staged compilation, as in Davies and Pfenning
So, I would not say that dependent types can eliminate macros, but they do cover a chunk of the areas that are often implemented by macros, including generics and other type based compile time code patterns.