On Wed, Nov 16, 2011 at 3:11 PM, Dmitry Soshnikov < [email protected]> wrote:
> ** > On 16.11.2011 23:53, Rick Waldron wrote: > > > > On Wed, Nov 16, 2011 at 2:34 PM, Dmitry Soshnikov < > [email protected]> wrote: > >> But why do we need new keyword? >> > > The discussion originated around how ugly <| is; an infix operator > keyword is easier to introduce into the language then an infix operator > made of symbols > > > Yes, I understand, but it doesn't answer the question -- why do we need > _additional_ keyword if to represent e.g. like this: > > // declaration > > var foo extends bar { > x: 100 > } > > // or via expression: > > var foo = extends (debug ? bar { x: 100 } : baz { y : 200}); > This would not work - extends should take one expression and one proto-literal > > // or even > var foo = extends (debug ? bar : baz) {x : 100} > However, this one should work. > > Anyway, forms with assignment are additions. The main part which I notice > is the declarative form. Once again, a good thing is that we have the same > syntactic form for defining/inhering simple objects and classes (only > var/let and class keywords change). > > The problem I would have with 'var foo extends...' is that it is very specific to the extends keyword. I think it's pretty intuitive still, so I can't say I'm totally opposed - but it does seem like tightly coupling two things which are orthogonal. In my proposal of the class operator, it would basically work like function, only the class body is allowed to be any expression resulting in an object. //expression form var Foo = class <Expression>; //expression form with name //Bar is the variable, but MyName is the name of the constructor function var Bar = class MyName <Expression>; //definition form, creates a hoisted variable Baz, and makes //that the name of the constructor function class Baz <Expression> > > P.S.: on <| -- speaking the truth I don't think it's ugly. Well, perhaps > maybe I use to Ruby's < inheritance op. Maybe it's just "pipe part" | of it > is ugly? :P > > I think its a new operator, and I haven't seen it anywhere else. Ruby's use of < is not as bad because it can only be used in a class definition, and therefore can be inferred a little better what's going on. - Russ
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

