With respect, I have to say that I vastly prefer the current class proposal
(http://wiki.ecmascript.org/doku.php?id=harmony:classes). I remember being
struck when I first read it (only recently, about a month ago) at how
incredibly sensible that proposal was.

Some issues I see with this alternative:

1. It's not clear how I can call the superclass constructor with different
arguments than the ones I was called with, as they seem to be passed in the
`extends` clause.

2. Conflating the constructor's execution context with the context defining
prototype properties seems unnecessarily confusing. The current proposal is
immediately clear to anyone used to JavaScript, and very familiar ("class"
body, constructor and other methods separately) to those coming from more
class-based OOP backgrounds.

3. As others have said, the syntax complicates understanding of execution
contexts and scope by making it seem like the constructor arguments would
be in-scope throughout, when presumably they wouldn't. I'm not keen on
introducing new magic to execution context definition if we can avoid it,
and I think we can avoid it here.

FWIW,
--
T.J. Crowder
Independent Software Engineer
www / crowder software / com
tj / crowder software / com


On 22 May 2012 17:38, David Herman <[email protected]> wrote:

> On May 22, 2012, at 9:29 AM, Erik Arvidsson wrote:
>
> > I think this proposal has one fatal flaw and that was what brought it
> > down the last time we had a proposal which used the same concepts.
> > Given:
> >
> > class C(x) {
> >  public method() {
> >    return x;
> >  }
> > }
> >
> > It seems like the arguments to the constructor are in scope for the
> > entire class body when they really aren't. The above would raise an
> > error that "x is undefined".
>
> Or worse:
>
>    var x = "WAT";
>     class C(x) {
>        public method() {
>            return x
>        }
>    }
>     (new C("inner")).method() // WAT
>
> I'm afraid this is just not a workable approach.
>
> Dave
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to