dherman at mozilla.com
Thu Nov 17 06:10:57 PST 2011
On Nov 17, 2011, at 5:16 AM, Dmitry Soshnikov wrote:
>> And `extends` fails completely as the syntax.
> This is why it's so wide-spread in other languages for inheritance, right? ;)
In other languages it's not a stand-alone operator but a part of class syntax. (I don't know Ruby, so maybe you'll correct me there.)
> `extends' is here for years in many langs for exactly to chain an object with its prototype or class (the langs which first come in mind are: Java, PHP, Scala, CoffeeScript, Dart, others). It's not used to copy own properties!
> As well, as it's not used to copy own properties in Ruby (in case if you want to argue with that Object.extend copies own properties in JS libs)! -- exactly from there was borrowed Object.extend to Prototype.js. In Ruby it just chains an object with yet another "prototype" (hidden meta-class which inherits from mixin module).
> So `extends' is for inheritance. And was even reserved in ES.
I've never had a problem with using `extends` as part of a `class` syntax. There's no need for `extends` to stand on its on.
> Hope I made it more clear.
Sorry I misunderstood which syntax you were promoting (prefix rather than infix). I explained in my reply to Russ why I think it doesn't work.
> Once again (sorry, Axel Rauschmayer, you may skip this phrase ;)), I'm not against `with', I'm just worry about that it had/has diff. semantics. But. We may re-use it for mixins.
I'm not sure how much I agree with your argument about confusion with the old semantics. Re: "once again" -- I *did* reply to that point last night, and you didn't reply to that. But maybe my answer was too cute. To elaborate:
On the one hand: for JS programmers who already know the language, I don't think it's that confusing to learn that `with` statements were banned and now there's a new `with` expression. For newbies, they arguably don't have to learn the old form, so there's nothing to confuse.
On the other hand: there is the fact that ES3 and non-strict ES5 code will exist indefinitely into the future, so when reading code, people would probably end up having to disambiguate what they're looking at based on the language version. That's a valid concern.
I also agree that `with` fits very well as future syntax for mixins or traits, and that's a direction we ought to work towards (post-ES6). And it might also be confusing to use `with` as both a part of the class syntax *and* an expression operator.
As I say, I'm not sure how much I agree, but they're valid concerns.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss