11 ms·
> Syntax extensions are a cool feature (and Rust is the only language I know of that supports something like this) that allows you to modify the AST at compile
by pron 12y ago
> Syntax extensions are a cool feature (and Rust is the only language I know of that supports something like this) that allows you to modify the AST at compile time, so you can generate your own code or modify existing code.
Java has had this feature for about 10 years now. The standardized API (required by all conformant compilers) defines only reading a partial AST (just declaration) and generating new source files, but javac supports full AST transformations.
Two famous Java projects making use of javac AST transformations are the good-old Lombok project and Checker, Java 8's new pluggable type systems.
- ajross 12y agoLisp has had this feature for... never mind.
- nickmain 12y agoHaxe has a full AST available to its macros.
- dukerutledge 12y agoHaskell has it