(Almost) everything is expression

Brendan Eich brendan at mozilla.com
Fri Nov 11 15:47:11 PST 2011

On Nov 11, 2011, at 10:25 AM, gaz Heyes wrote:

> On 11 November 2011 18:01, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote:
> var foo = {
>  // do stuff
>  100;
> };
> What would be the result of a labelled statement? You'd need labels to work within expressions since you'd probably want to do:
> x=loop:for(i=0;i<10;i++){
> }
> but then what if you do:
> x=1/loop:for(i=0;i<10;i++){
> }
> Is 1 divided by the result of the for loop or is it divided by undefined?

My last reply suggested making unlabeled keyword-statement (statements that start with a reserved identifier) be assignment expressions, so if you remove the loop: label, you would have to parenthesize:


to get it to compile. If we extend things to support LabelledStatement as well as KeywordStatement as right parts of AssignmentExpression, then you'd still need parens and it would all work.

I haven't thought through other potential issues with labels, though.

As noted, blocks in parentheses are *out*. No can do.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111111/97a231f4/attachment-0001.html>

More information about the es-discuss mailing list