||= is much needed?

Brendan Eich brendan at mozilla.org
Tue Jun 12 16:44:30 PDT 2012


Ok, that (cited below) was wrong too.

This should be right: 
http://wiki.ecmascript.org/doku.php?id=strawman:default_operator#semantics

Comments welcome. Thanks again, I needed some caffeine!

/be

Brendan Eich wrote:
> Heh, I did write *roughly* :-P.
>
> Let lref = evaluate LeftHandSideExpression.
> Let lval = GetValue(lref).
> 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, then:
>    Let rref = evaluate AssignmentExpression.
>    Let rval = GetValue(rref).
>   Call PutValue(lref, rval).
>
> Thanks, fixing and transcribing into
>
> http://wiki.ecmascript.org/doku.php?id=strawman:default_operator
>
> /be
>
> John Tamplin wrote:
>> On Tue, Jun 12, 2012 at 3:09 PM, Brendan Eich <brendan at mozilla.org 
>> <mailto: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?
>>
>> -- 
>> John A. Tamplin
>> Software Engineer (GWT), Google
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list