||= is much needed?

T.J. Crowder tj at crowdersoftware.com
Wed Jun 13 00:45:48 PDT 2012


On 13 June 2012 06:52, Brendan Eich <brendan at mozilla.org> wrote:

> People don't default on the caller side (at the callsite) much, in my
> experience. Dave may be seeing other sources, but it's extremely rare in my
> experience to see
>

I'm with Dave on this, I do it fairly regularly, usually when a function
turns around and calls another one with the arg and has no other use for
the arg:

function doSomethingNifty(a, b) {
    return doSomethingVerbose({
        x: 1,
        y: a,
        z: b ?: 5
        // ...
    });
}

?= looks great, and Wes' point about confusion re ||= (or even |||=) and
boolean logical operators definitely kills my preferred ||| for the
non-assignment form if there's going to be an assignment form -- and we all
want an assignment form.

Is the reason for using ?: rather than ?? because we may want it for my
desired second ternary? E.g., from my other message:

a = b ?? c : d;

meaning

a = b !== undefined ? c : d;

Or that we want it (now, or in reserve) for something else? Because if not,
I'd prefer to see ?? rather than ?:. It's easier to type and the
double ??calls back to the related
||. But again, only if we don't want ?? (now, or in reserve) for something
else.

Very much looking forward to ?: (however we spell it) and ?=.

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


More information about the es-discuss mailing list