On Jun 12, 2012, at 10:52 PM, Brendan Eich 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
>
> foo(arg1 || callers_idea_of_default_arg1_value);
I'm sure it's more rare than the assignment form, but that's partly because the
assignment form is needed to make up for lack of pdv's.
> whereas we all see
>
> function foo(a, b, c) {
> a = a || default_a;
> b.x = b.x || default_b_x;
> b.y = b.y || default_b_y;
> c.z = function (w) {
> // long body here
> }
> ...
> }
Well, you wouldn't argue against having || in the language. Yes, I know it
serves other roles as well. But only providing the assignment form strikes me
as over-specialization. Operators are a straightforward generalization of
assignments. When you specialize the syntax to provide an assignment form only,
you force people to create temporary variables when they aren't needed.
Compound expressions are good things!
And why break the pattern of compound assignments being based on binary
operators? Why should ?= or ??= be different from +=, -=, *=, /=, %=, <<=, >>=,
>>>=, &=, |=, ^=? It just seems like a pointless restriction.
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss