IIAFEs?

David Bruant bruant.d at gmail.com
Sat Jun 1 17:00:25 PDT 2013


Le 01/06/2013 16:52, Jorge a écrit :
> On 02/06/2013, at 01:22, Brandon Benvie wrote:
>> On 6/1/2013 3:44 PM, Jorge wrote:
>>> But they're not fully interchangeable, for example I can exit a function at any point with a return, but can I exit a block at any point with a break or something?
>>     block: {
>>       if (true) {
>>         break block;
>>       }
>>     }
> What might happen with this is that if you concatenate a bunch of .js files that use this pattern, they might end redefining the same label (which would be an error, I guess). Wrapping it all in another block would solve that?
>
> {
>    block: {
>      if (true) {
>        break block;
>      }
>    }
> }
>
> But then... I'm not sure this is any better than an IIFE!
You can also use a less naive concatenator. Labels seem to be very 
static parts of a JS program. It sounds doable to find and rewrite them.

Given what people have been doing with esprima recently [1], I have the 
impression it would be even easy (?)

David

[1] https://github.com/olov/defs


More information about the es-discuss mailing list