On 2018-06-16 07:48, Nick Sabalausky (Abscissa) wrote:
If only D hadn't given up on the AST macros idea, we could actually implement most of this sugar AS A LIBRARY SOLUTION, just like modern D wants. AST macros are seriously awesome though: There's this one CLR language, Nemerle, kind of obscure (and kind of dead-ish now unfortunately), that has this one really weird, stupid limitation: If you want an "if" statement WITHOUT an "else", you have to say "when" instead of "if". Stupid idea. *BUT* the language supports AST macros. So in 12 lines of code (Yes, twelve!!!!), I added support for "if without else"...IN LIBRARY!! https://github.com/Abscissa/plainIf/blob/master/plainIf.n Seriously, AST macros turn a language into "LISP without parenthesis-hell". So freaking awesome. Wish D hasn't given up on them in favor of ugly unhygienic string mixins.
A couple of years ago I started trying to implement AST macros [1], it's pretty stale now.
[1] https://github.com/jacob-carlborg/dmd/tree/macro -- /Jacob Carlborg