On Jul 19, 2011, at 11:07 AM, Bob Nystrom wrote:

> // "new" lets you declare members on new instances. these would presumably be

> // invoked on the new object before the constructor body is run.
> new:
>   numAttacks = 0;
>   // declaring an instance property here mainly so you can document it. could 
> be
>   // useful later for guards or other annotations.
>   name;

The plain name; also looks like a useless expression-statement.

Beyond this, I'm concerned that per-instance properties need initializers that 
use constructor parameters. So they ought to be initialized in the constructor.

Whether they can be declared outside the constructor is a separate issue. 
Perhaps if they have constant or constructor-invariant initializers, they can 
be initialized where declared too.

But declarations should look different from expressions. The alternative we 
keep returning to is the property assignment sub-grammar of object literals, 
which would want

    numAttacks: 0;

with a semicolon not a comma.

Anyway, this is a detail, and we could even defer it and still have a better 
class proposal using your C++-inspired label idea. I'm quite taken with that!


es-discuss mailing list

Reply via email to