News for hackers. Stuff that matters.
Re:Stop Writing JavaScript Compilers, Make Macros Instead by aaronem on Wednesday January 08, 2014 @05:19PM (#7027205)
Huh. This is what I get for talking something up before I've had a chance to play with it for myself -- you're right, Sweet.js doesn't allow for arbitrary syntax definitions, just those of the form keyword arguments body, with macro-expansion only on body, and no way of capturing the symbol prior to keyword.

I can still see a potential method of rewriting functions, whose arguments were decorated with type specifiers, to provide type checking. But that would involve prefixing the function body with type checking code to be evaluated at runtime, which would probably produce a monstrous increase in execution time, and would be ugly either way.

Well. I suppose I shouldn't have expected anything different, knowing that a real macro system requires support at the language level, and that a retrofit like sweet.js is perforce going to be limited in what it can hope to accomplish. But I find myself disappointed nonetheless that sweet.js is what it is, rather than what I wanted it to be -- and, I think, what a lot of people, not least of whom the author of the linked article, imagine it to be.

Re:Stop Writing JavaScript Compilers, Make Macros Instead by disnet on Wednesday January 08, 2014 @09:25PM (#7028362)
Actually sweet.js just landed infix macros [1] so you can match on syntax that comes before the macro name. This just happened last week so we haven't updated the docs or made an official release just yet.

[1] https://github.com/mozilla/sweet.js/pull/162

Re:Stop Writing JavaScript Compilers, Make Macros Instead by bad_user on Thursday January 09, 2014 @01:13AM (#7029083)
That's awesome.
Re:Stop Writing JavaScript Compilers, Make Macros Instead by aaronem on Thursday January 09, 2014 @08:56AM (#7030440)
Sweet!