What are the semantics of your macros? If they are FEXPRs, then you won't be able to do much in the way of static typing for your language.
You could take a look at Alan Bawden's first-class macros [1].
Either system F or type dependency will require type annotations, although the type systems literature contains a number of workarounds to keep the overhead low. I'd recommend a simpler type system if you don't have a clear need for impredicative or dependent typing.
This is really a no-risk, learning project, so I'll probably try to implement System F in some form; eventually. It isn't an assignment and I have no deadlines.
But, yes, I agree that starting with some simpler type system (Hindley Milner maybe) will probably be more approachable and will give me a good base to build on.
Right now, the macros are very naive -- they are passed the entire unevaluated AST on which the macro is invoked and the new AST they return is used instead. I think this makes them FEXPRs. They do capture the defining lexical environment.
The best semantics for fexprs are probably Kernel's: a fexpr receives as parameters (1) the AST (2) the lexical environment in which the fexpr is called. (This dynamic lexical environment is given in addition to the captured static lexical environment - the env in which the fexpr was defined.)
I believe this two-argument fexpr design goes way back, but I'm not sure.
4 comments
[ 2.5 ms ] story [ 9.5 ms ] threadYou could take a look at Alan Bawden's first-class macros [1].
Either system F or type dependency will require type annotations, although the type systems literature contains a number of workarounds to keep the overhead low. I'd recommend a simpler type system if you don't have a clear need for impredicative or dependent typing.
[1]: http://lambda-the-ultimate.org/node/2987
But, yes, I agree that starting with some simpler type system (Hindley Milner maybe) will probably be more approachable and will give me a good base to build on.
Thanks for the link, looks very helpful.
I believe this two-argument fexpr design goes way back, but I'm not sure.
http://web.cs.wpi.edu/~jshutt/kernel.html