Open Raynos opened 10 years ago
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.
This is more about parsing ES5 with a macro for let/const then parsing ES6 with real let/const.
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.