How much sugar do classes need?

Jon Zeppieri jaz at bu.edu
Tue Dec 2 11:35:27 PST 2008


On Tue, Dec 2, 2008 at 1:54 PM, Peter Michaux <petermichaux at gmail.com> wrote:
> On Mon, Dec 1, 2008 at 12:01 PM, David-Sarah Hopwood
> <david.hopwood at industrial-designers.co.uk> wrote:
>
>>  var self = {
>>    method toString: {|| '<' + self.getX() + ',' + self.getY() + '>'},
>>    method getX: {|| x},
>>    method getY: {|| y},
>>    field pubInstVar: 4,
>>    const pubInstConst: -4,
>>  };
>>  return self;
>>
>> where the extensions to the object literal syntax used here are:
>>  - a 'field' modifier to declare a property non-[[Configurable]],
>>  - a 'const' modifier to declare a property non-[[Configurable]]
>>   and non-[[Writable]],
>>  - a 'method' modifier to declare a property non-[[Configurable]],
>>   non-[[Writable]] and non-[[Enumerable]].
>
> I don't think only a "method" would have the combination of attributes
> listed above.

Agreed.  The proposed names do not denote what they appear to denote.

> Also because functions are first class in JavaScript, I
> think of a function valued property as a field so don't like the name
> "field". Also would "method" be able to be a lambda or function?



More information about the Es-discuss mailing list