News for hackers. Stuff that matters.
Re:Compiling JSX with Sweet.js using Readtables by jlongster on Wednesday July 02, 2014 @04:40PM (#7979595)
There's a big difference: that's basically just a pipeline for AST tranforms. That's not very hard. Basically just a bunch of different JS libraries that you hand an AST through.

That's not actually that useful. In my post, I mentioned adding syntax for literal persistent objects, using something like Mori data structures. The syntax could look like this:

* #[1, 2, 3] <- persistent vector

* #{x: 1, y: 2} <- persistent map

An AST pipeline makes the "analyze" phase extensible, but it doesn't do anything to the parser. You can't actually add syntax, ever. So it's just not that useful for extending the language. It's good for something like implementing various parts of ES6.

Actually, it's even better for something like types or modules, which really need the whole AST. But in my opinion, everything else is better as macros.

sweet.js works on a tree of tokens, and it allows extending actual syntax. It's also way easier to transform code because it has a pattern matching language and you don't have to manually wrangle AST nodes.

Lastly, sweet.js keeps track of scoping, and in the future it will have modules, so you will be able to do something like:

``` import JSX from "jsx-reader";

import # from "mori";

// code ... ```

And those language extensions are only available inside the module. Everything is scoped.

Re:Compiling JSX with Sweet.js using Readtables by davedx on Thursday July 03, 2014 @04:29AM (#7982077)
"Reliable source maps" - going to give this a try. If it works I'll buy you a beer.
Re:Compiling JSX with Sweet.js using Readtables by modarts on Monday July 07, 2014 @04:15AM (#7997647)
Where can I check out the macros for persistent data structures? That sounds awesome