(sorry, last mail was sent by mistake)

This seems pretty easy to enforce to me.

function a(x) {

   let count = 0;
   let arr = [
       (x+1)^(x-1),
       (x*x),
       (2*x-1)
   ]

   arr.forEach({|x|
       if((x&1)==0) count++;
   });

   return count;
}

can be compiled as :

function a(x) {

   let count=0;
   let arr = [...];
   let $lambda = {
       [Call]: {||
           ...
       }
   };

   arr.forEach($lambda);

   $lambda.[Call] = function() { throw new InvalidTargetException(); }

   return count;
}

So, if the 'Array.prototype.forEach' function of has been modified to call the iter function asynchronously, it will not work.

As a plus, it allows a very powerful optimisation (block-lambda running in the same frame as the function itself).

Regards,
François

-----Message d'origine----- From: Brendan Eich
Sent: Saturday, January 21, 2012 7:17 AM
To: Axel Rauschmayer
Cc: es-discuss
Subject: Re: Block lambda is cool, its syntax isn't

Axel Rauschmayer <mailto:a...@rauschma.de>
January 20, 2012 9:24 PM

- Hard to type: reading is far more important than typing, it is very easy to adapt tools to help with typing.

ƒ is not particularly readable IMHO. It's florin, not mathematical
notation I've ever seen. Anyway we can't assume the compatibility break
is ok since it can occur in operand context in any expression.

- Not ASCII: I hardy every encounter non-UTF text files, any more. Non-ASCII seems to work well for Fortress.

Fortress, please. I invite @samth to comment now. I admire Fortress, but
it is not an exemplar or nearby language for JS.

I think "use fn;" (real pragma syntax), with the low-precedence assignment-expression fn (params) assign-expr production, wins. What do you think?

Having fn would be sweet. For many kinds of pragmas, it would be great if one could configure these per project (or per directory). Then one could put legacy code in one directory and ES6 code in another. And the weight of the pragmas would be negligible. Not sure how to do this, though; reminds me very loosely of CSS (centralized management of style).

You make a good point: "use fn;" may be too much to require in every
<script> element content.

Would fn make sense as an ES6 breaking change? I’d expect many people to be strongly in favor, possibly as many strongly opposed.

Don't forget that JQuery uses fn as an identifier (and not just
following a dot) all over.

Possible research (applies to ƒ, too):
- Poll people for their opinion

These are not decisive. I've been straw-polling audiences for a while.
Block-lambdas are doing well, but one must ask "nothing, just
'function'" and usually get a stronger response than any new syntax.

- Search JS code bases for how often the identifier "fn" is used (how?).

See JQuery sources. Unconditionally reserving 'fn' is a non-starter
IMHO. Recall also that we are trying to hew to "One JavaScript" -- few
to no refactoring woes moving code in and out of a module {...}
container or "use strict"; code block.

/be

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to