Default operator strawman - ||| rather than ??

T.J. Crowder tj at crowdersoftware.com
Fri Jun 15 06:28:10 PDT 2012


I think the original thrust of this thread may have got lost a bit in the
(useful) discussion of null and undefined, so coming back to the original
point:

On 12 June 2012 16:29, T.J. Crowder <tj at crowdersoftware.com> wrote:

> In the current default operator strawman[1], the operator is ??, e.g.:
>
> a = b ?? 5;
>
> is shorthand for
>
> a = b !== undefined ? b : 5;
>
> Would it be possible to use ||| instead? E.g.:
>
> a = b ||| 5;
>
> I ask because I was planning (prior to knowing about this strawman!) to
> suggest that, along with a different form of ?? (or ???) which introduces
> a new ternary operator:
>
> a = b ?? 5 : 6;
>
> ...which would be a shorthand form of
>
> a = b !== undefined ? 5 : 6;
>
> [1] http://wiki.ecmascript.org/doku.php?id=strawman:default_operator
>

Does anyone have an opinion on a second ternary a'la the above (syntax
notwithstanding). So far we have only my opinion (I like it and would have
uses for it; I don't _need_ it), Brendan's ("too thin")[1], and Herby's
("wouldn't hurt")[2].

(Speaking syntactically, I think we all agreed in the other thread that |||
[above] won't work for the infix, because the assignment form just becomes
too confusing, as Wes pointed out.[3])

[1] https://mail.mozilla.org/pipermail/es-discuss/2012-June/023468.html
[2] https://mail.mozilla.org/pipermail/es-discuss/2012-June/023510.html
[3] https://mail.mozilla.org/pipermail/es-discuss/2012-June/023386.html

-- T.J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120615/d19f6811/attachment-0001.html>


More information about the es-discuss mailing list