||= is much needed?
Allen Wirfs-Brock
allen at wirfs-brock.com
Tue Jun 12 15:32:20 PDT 2012
On Jun 12, 2012, at 3:26 PM, John Tamplin wrote:
> On Tue, Jun 12, 2012 at 3:09 PM, Brendan Eich <brendan at mozilla.org> wrote:
> And (to be clear) the semantics for
>
> LeftHandSideExpression ?= AssignmentExpression
>
> are roughly
>
> Let lref = evaluate A.
> Let lval = GetValue(lref).
> Let rref = evaluate B.
> Let rval = GetValue(rref).
> Throw a SyntaxError exception if the following conditions are all true:
> • Type(lref) is Reference is true
> • IsStrictReference(lref) is true
> • Type(GetBase(lref)) is Environment Record
> • GetReferencedName(lref) is either "eval" or "arguments"
> If lval is undefined, call PutValue(lref, rval).
>
> to assign the default value if and only if the left-hand side's current value is undefined.
>
> Wouldn't you want B to be evaluated only if A is undefined?
Yes, that makes it consistent with the semantics of ? :
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120612/615fee35/attachment.html>
More information about the es-discuss
mailing list