Wes Garland wrote:
> This breaks from JS's C-inspired assignment operators, but perhaps
we can live with it.
FWIW -- I was confused when I first read ||=, I thought it was
supposed to be some kind of Boolean-coercing variant on |=. Now I see
that it is more like ?= from GNU make.
We could use ?= instead. Good point. This avoids the dual semantics for
A op= B split on whether op is || (an existing operator, unlike lone ?).
What do you think of GCC's ?: operator? It is basically a special form
of the ternary operator, and while not the same as your propsal, it
addresses many of the same use cases.
That's ok as an alternative to ?? but would you want ?:= as the
assignment form? I'd rather lose the colon.
Given ?=, people may wish for A ? B instead of A ?? B, but then we have
nasty issues with respect to ternary:
A ? B ? C : D
Is this (A ? B) ? C : D or A ? (B ? C) : D. We can disambiguate in the
formal grammar but readers may rebel.
It's possible ?? or however we spell it isn't worth adding, while ?= is.
The conditional assignment to default or normalize is the prime use-case.
Even then, we have lingering debates over falsy vs. null-or-undefined
vs. undefined only. CoffeeScript does null-or-undefined, IIRC.
/be
(I've been happy with it for a long time).
Wes
--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
_______________________________________________
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