But isn’t a clear separation of responsibility better?

Want a constructor => use a class declaration.
Want a callable => use an arrow function.

I always disliked that some functions in ECMAScript 5 can be invoked as either 
a function or a constructor. What would you want an entity Foo for that can be 
invoked in two ways? E.g.:
     new Foo(...)
     Foo(...)

Axel

On Apr 9, 2012, at 1:14 , Kevin Smith wrote:

> I can't give you a use case (it's just a felling of being a good design 
> thing), but I would like the classes be higher-level construct based on 
> low-level ones. If new()/static() gets in, it defines its own exclusive 
> semantics not possible to do by plain constructor 
> 
> I agree in general, but as you say, differentiating between [[Call]] and 
> [[Construct]] is not really possible from within a called function (AFAIK).  
> There is a functionality gap here, and I believe that classes are the right 
> place to fill in that gap.
> 
> What does class do if you add new(){} but not static(){}? I presume it 
> [[Call]]s new(){} body...
> 
> My intuition says that if you did not specify a "static() {}", then 
> MyClass(...) and new MyClass(...) would be equivalent (ala the more common 
> pattern in the Chapter 15 "classes").
> 
> kevin
> 
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss

-- 
Dr. Axel Rauschmayer
[email protected]

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to