Am I crazy to think that "Nil" could allow the Existential Operator to be
used in assignments as well?
var a = undefined;
a?.b?.c?.d = 1;
console.log(a); // {b: {c: {d: 1}}}
Too powerful / abusive?
Day dreaming, use U+02D9 (DOT ABOVE) as the operator.
a˙b˙c.d
On Tue, Apr 7, 2015 at 1:09 PM, Herby Vojčík <[email protected]> wrote:
>
>
> Kevin Smith wrote:
>
>>
>> > Plus, it can be used for "normalizing" null/undefined to undefined:
>> >
>> > var normalizedFoo = ?foo;
>> >
>> > Seems sort of nice that it is separated and there are no special
>> operations for ?., ?(, ?[.
>>
>> I agree, that is nice. But how does Nil get transformed into undefined?
>>
>
> While you do operations like call, construct, get on the reference
> (obtaining another reference), it shortcuts to return Nil. Whenever you are
> not in position to shortcut ref-to-ref (end of expression, for example),
> and you actually needs a value, it just converts to undefined.
>
> ?a.b()['foo'] => "smalltalk-like"
> (((('a' asRefIn: env) nilRefIfValueNullOrUndefined "ref, may be nil"
> at: 'b') "returns ref, may be Nil"
> callWithArguments: #()) "returns ref, may be Nil"
> at: 'foo') "returns ref, may be Nil")
> value "now, value is needed, ref needs to dereference"
>
> Hopefully this sheds some light. If not, then I don't know how to explain
> it someone with better pedagogy skill must weight in.
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss