Minimalist Classes

Brendan Eich brendan at mozilla.com
Thu Nov 3 08:55:38 PDT 2011


On Nov 3, 2011, at 1:23 AM, Kam Kasravi wrote:

> I noticed the absence of setter's, getter's. Would this be valid syntax?

Yes, that's already in object literal syntax.

My gist is a fork of Jeremy's, he didn't add 'em so I didn't either. At this point they are context, assumed. They're in ES5!

/be


> 
>   set health(value) {
>     if (value < 0) {
>       throw new Error("Health must be non-negative.");
>     }
>     @health = value;
>   }
> 
> 
> 
> On Nov 3, 2011, at 12:17 AM, Brendan Eich <brendan at mozilla.com> wrote:
> 
>> What is "super-intuitive" about running 'class C' up against an arbitrary expression, which is then evaluated and *copied* (details fuzzy here) as the class prototype?
>> 
>> Arguments about feelings and intuition are not that helpful. Saying why you need to construct a class that way, where no such object copying primitive exists in JS, would be more helpful. IOW, what's the use-case?
>> 
>> /be
>> 
>> On Nov 2, 2011, at 11:03 PM, Matthew J Tretter wrote:
>> 
>>> So to clarify, is the dynamic super issue the whole reason that Jeremy's dynamic construction of classes is considered not doable? Because it seems to me that super may not be worth that trade off. Besides, Python's super implementation requires the hardcoding of the class and that doesn't cause much of a stink. If something similar would give us this super-intuitive syntax and the ability to build classes from arbitrary object literals, it seems like not a big loss.
>> 
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111103/adc0109d/attachment.html>


More information about the es-discuss mailing list