Precedence of yield operator

Rick Waldron waldron.rick at gmail.com
Sat Jun 15 19:23:58 PDT 2013


On Saturday, June 15, 2013, Mark S. Miller wrote:

> If we do provide such special syntax, then I suggest (a variant on some
> else's suggestion -- I forget who) that "yield" is to "function* as "await"
> is to "function!", amplifying the association of "!" with asynchrony.
> Rather than say "async function" or whatever, we'd just say "function!".
> Since "function!" would be new in ES7, there's no reason to reserve
> anything in ES6 to prepare for this.
>

Mark, is there a particular rationale for the reuse of "!" as the eventual
send operator and here for similar semantics? I recall this also appeared
in you Distributed Electronic Rights paper. Putting its strong existing
meaning aside (negation), when I see "!" I think of "urgent" things—quite
the opposite of the behavior described in the paper and above.

Rick




>
>
>
>
> On Sat, Jun 15, 2013 at 2:40 AM, Bruno Jouhier <bjouhier at gmail.com> wrote:
>
> If this is on the agenda for ES7 maybe ES6 should at least reserve "await"
> as a keyword in function* scopes.
>
>
> 2013/6/15 François REMY <francois.remy.dev at outlook.com>
>
> I'm maybe biased, but I would love to consider "yield" as a function.
> Indeed, it calls another code, which can return you a value. That looks
> very similar to a function call to me. If we do this, the predecence
> becomes intuitive again:
>
>    var x = yield(a) + yield(b);
>    yield(a+b);
>
> I think there was a proposal to allow parenthesis-free function call at
> some point at the root of a statement. When it lands, you'll be able to do
> things like
>
>    yield a+b;
>
> as a normal statement again. In the mean time we can just use parentheses,
> that's not a huge issue and it helps clarity.
>
>
>
> But maybe this is too late to change ES6, it's just an idea I had while
> reading this thread, not a strong call for change.
>
>
>
>
>
>
> -----Message d'origine----- From: Brendan Eich
> Sent: Saturday, June 15, 2013 6:17 AM
> To: Dean Tribble
> Cc: Bruno Jouhier ; es-discuss at mozilla.org
> Subject: Re: Precedence of yield operator
>
>
> This is all on the agenda for ES7. It cleanly missed ES6 in May 2011(!).
>
> https://mail.mozilla.org/**pipermail/es-discuss/2011-May/**014748.html<https://mail.mozilla.org/pipermail/es-discuss/2011-May/014748.html>
>
> /be
>
> Dean Tribble wrote:
>
> This is a familiar discussion from C#. I forwarded it to the mediator of
> that convresation and got a nice summary, pasted here:
>
> ---------- Forwarded message ----------
> From: *Mads Torgersen* <Mads.Torgersen at microsoft.com <mailto:
> Mads.Torgersen@**microsoft.com>>
> Date: Fri, Jun 14, 2013 at 2:11 PM
> Subject: RE: Precedence of yield operator
> To: Dean Tribble <tribble at e-dean.com <mailto:tribble at e-dean.com>>
>
>
> I’m not on the mailing list. Feel free to forward to it.
>
> In C# we have separate keywords too, and indeed the precedence differs as
> described below. For “yield return” (our yield) the lower precendence falls
> out naturally since it engenders a statement, not an expression.
>
> “await” is not a reserved keyword in C# either, but we managed to wedge it
> in all the same. Just adding await as an operator would lead to all kinds
> of ambiguity; e.g. “await (x)” could be a function call or an await
> expression, and the statement “await x;” could be a variable declaration or
> an await statement.
>
> However, in C# “await” is only allowed inside methods marked “async”, and
> since there weren’t any of those around before the feature was introduced,
> it is not a breaking change. Inside non-async methods, therefore, “await”
> continues to be just an identifier.
>
> I don’t know if a similar thing is possible in EcmaScript. But I believe
> that a low-precedence yield as a substitute for a high-precedence await is
> problematic: you never want “yield a + yield b” to mean “yield (a + (yield
> b))”: the things you await – Task, Promises, Futures, whatever you call
> them – just don’t have operators defined on them, and it would be silly to
> parse them as if they might and then give errors (at runtime in EcmaScript,
> at compile time in e.g. TypeScript).
>
> Mads
>
>
> On Fri, Jun 14, 2013 at 11:07 AM, Brendan Eich <brendan at mozilla.com<mailto:
> brendan at mozilla.com>> wrote:
>
>     Bruno Jouhier wrote:
>
>         While playing with my little async/await library, I noticed
>
> --
>     Cheers,
>     --MarkM
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130615/f213e7ba/attachment-0001.html>


More information about the es-discuss mailing list