> -----Original Message----- > From: Igor Bukanov [mailto:[EMAIL PROTECTED] > Sent: 25. juli 2008 14:36 > To: Lars Hansen > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; es4- > [EMAIL PROTECTED]; Ingvar von Schoultz > Subject: Re: function hoisting like var > > One way to get that extension comes from an observation that ES4 > allows to drop the braces around function body and the return keyword > if the body is the single return exp. If ES3.1 would support it, then > to simulate an effect of let expression like > > let (a = arg1, b = arg2) expression > > one could write > > (function(a, b) expression)(arg1, arg2) > > or > > (function(a, b) a = arg1, b = arg2, expression)() > > If, in addition to this shortcut, ES4 would allow to drop an empty > argument list from a function with a requirement that function { } > always means an expression and ES3.1 would also support that, then in > place of a block with let variables one can write: > > function { > > }();
Even neater, using default argument values the syntax is actually (function (a=arg1, b=arg2) expression)() at which point 'let' is a trivial transformation. --lars _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
