In a comment on my hygienic macros for Java idea, Ken Meltsner points out Java Syntactic Extensions, a macro system for Java. Great stuff, thanks for pointing it out!!
Check out in the slides how the forEach statement (slide 30) is implemented in the system: the implementation fits in only one slide! The slides also show as example an accessible keyword (slide 39) which, when used to declare an instance variable, automatically generates setter and getter methods.
One thing I liked about the system is that it's procedural, thus potentially easier to understand and master than the declarative syntax macros in Scheme. Even then however, it could still be a challenge to understand and master.
Such a macro system would be the only thing needed in Java, everything else could be implemented using it. This is the case in most implementations of Scheme, which have a very small core and everything else is implemented as macros.
|