How to fix the `class` keyword

Matthew Robb matthewwrobb at gmail.com
Wed Mar 4 19:13:23 UTC 2015


Making the following two things no longer interchangeable completely breaks
my mental model for JS:
```
var x = new X;
```
and
```
var x = {}; X.call(x);
```

Yes the above is useless for built in types but it's very widely employed
in user code, libraries, and frameworks. Making the above no longer true is
a huge mistake imo and it changes the language in a fundamental way. We
used to have objects and objects that you could call (functions). Now we
have objects, functions, and something else... For what?

I thought the idea of max/min classes was to stay as true to the OOP
patterns used today as possible? So shouldn't the question be reversed and
classes should work like sugar for functions intended for use as
constructors instead of breaking that model and requiring justification in
a later draft to restore expected behavior?


- Matthew Robb

On Wed, Mar 4, 2015 at 2:03 PM, Matthew Robb <matthewwrobb at gmail.com> wrote:

>
> On Wed, Mar 4, 2015 at 1:47 PM, Kevin Smith <zenparsing at gmail.com> wrote:
>
>> Allowing the user to specify the "call" behavior for class constructors
>> is something to consider for post-ES6.
>
>
> ​Unfortunately, based on this kind of logic (not the first I have seen it
> on here) I would ask that we stop calling ES6 classes "simple sugar on
> existing conventions". This is a major breaking difference in the most
> surface-y aspect of classes and how they are used in people's code. ​
>
>
>
> - Matthew Robb
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150304/b856c2c9/attachment-0001.html>


More information about the es-discuss mailing list