I noted some open issues on "Classes with Trait Composition"

Bob Nystrom rnystrom at google.com
Thu May 19 18:08:19 PDT 2011

On Thu, May 19, 2011 at 5:40 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Of the 88 fields I looked at, 10 were straight copies of a constructor
> argument. Another 4 are copies with an "if undefined then use this default
> instead" check.
> ??=, check (http://wiki.ecmascript.org/doku.php?id=strawman:default_operator
> -- this is going for Harmony gold next week!).

Yup, I like it. :)

> Also, Closure library, right? Opinions vary on the style used there.

Yeah, code built on top of that, but not part of Closure itself. It would
definitely be good to look at other JS too. My professional JS experience is
all Closure-style so that likely gives me all sorts of weird biases.

> Are the 4 cases all such that the calls to the constructors leave off
> trailing arguments, or do they pass undefined? Or perhaps they pass other
> falsy default values, in which case ||= not ??= (and again not parameter
> default values) could help?

For the most part, it's trailing values, but a couple were stuff like:

function SomeClass(opt_a, opt_b) {
  this.a = goog.isDef(opt_a) ? opt_a : SOME_DEFAULT;
  this.b = goog.isDef(opt_b) ? opt_b : SOME_DEFAULT;

And there may be call sites like new SomeClass(undefined, "blah") I think
most people try to minimize those cases, but they seem to crop up,
especially as code accretes arguments over time.

- bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110519/4c5dfc00/attachment.html>

More information about the es-discuss mailing list