On 29 March 2012 22:26, Brendan Eich <bren...@mozilla.org> wrote:

> Andreas Rossberg wrote:
>
>> For me, the biggest blow against TCP lambda forms in general was Mark's
>> observation regarding the incompatibility with 'yield' that you mention in
>> the other post.
>>
>
> It seems 'yield' may be a red herring. We all forgot that it is
> contextually defined as a keyword only in generator functions, which have a
> distinguished head (* after function or before method name).
>

Well, in the same way 'return' is contextually defined as a keyword in
ordinary functions. ;)

Arrows cannot be generator functions, so yield is not reserved in arrow
> bodies.


Wait, that isn't the issue. The issue is that if 'yield' does not work,
then control-flow abstractions (which are the main motivation for TCP
lambdas) won't generally work, because they could not be used in
generators. Just to give a stupid example, consider:

function* squares(a) {
  for (int i = 0; i < a.length; ++i)
    yield a[i]*a[i];
}

This cannot be turned into:

function* squares(a) {
  a.forEach(x => yield x*x);
}

To me, that seems like a complete roadblock wrt the primary motivation for
TCP lambdas.

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

Reply via email to