es6-macros icon indicating copy to clipboard operation
es6-macros copied to clipboard

What's possible with `let` and `const` macros

Open Raynos opened this issue 11 years ago • 2 comments
trafficstars

I know there's a compiler for it ( https://github.com/olov/defs ) but it would be cool to have it as a macro as well.

Raynos avatar Mar 07 '14 18:03 Raynos

So sweet.js already is aware of the scopes of everything, and it handles let/const scoping properly. It even already renames all the variables because of the hygiene system. It's probably easiest to just add a flag to sweet.js to tell it to compile out everything to var statements instead of keeping the original type. Otherwise you'd have to do some pretty extensive expansion to imitate the let/const behavior.

jlongster avatar Mar 24 '14 04:03 jlongster

This is more about parsing ES5 with a macro for let/const then parsing ES6 with real let/const.

Raynos avatar Mar 24 '14 06:03 Raynos