function hoisting like var

Igor Bukanov igor at mir2.org
Sun Jul 27 16:42:43 PDT 2008


2008/7/28 Ingvar von Schoultz <ingvar-v-s at comhem.se>:
>
> {{ }} is just the same as a scoping function used on ES3:
>
>    (function() { code })()

As Lars Hansen has pointed out any proposal for a shorthand for
(function() { code })() has to deal with break/continue/return inside
the code. This is the the reason if anything I would prefer in ES3.1
just shorthands for function definitions like

function() expr  - equivalent to function () { return expr; }. This is
already in ES4 and is implemented by at least on implementation
(SpiderMonkey).

or

function optional_name { code } - equivalent to function
optional_name() { code } - a hypothetical shortcut that would allow to
write a pseudo-blocks like

function {
}();

with clear emphasis that this is a lambda with usual rules for
break/continue/return.

Regards, Igor



More information about the Es4-discuss mailing list