On Tue, Dec 2, 2008 at 1:54 PM, Peter Michaux <[EMAIL PROTECTED]> wrote:
> On Mon, Dec 1, 2008 at 12:01 PM, David-Sarah Hopwood
> <[EMAIL PROTECTED]> 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?

>From David-Sarah's description, it seemed to me that 'method' merely
means that the property is non-configurable, non-writable, and
non-enumerable and has nothing to do with the 'type' (as it were) of
its value.  And that's a good example of how the proposed names are
misleading.

>
> There are 2^3 = 8 combinations of Configurable, Writable, Enumerable
> and potentially more attributes in the future. I'd prefer to control
> them independently. If multiple prefix modifiers are not appealing,
> what about some flags like the 'g' that can follow a regexp literal
> (e.g. /a/g)
>
>
> var self = {
>  toString[]: {|| '<' + self.getX() + ',' + self.getY() + '>'},
>  getX[]: {|| x},
>  getY[]: {|| y},
>  pubInstVar[WE]: 4,
>  pubInstConst[E]: -4,
> };

I find this ugly, but I don't have any great ideas.  I do want to
point out, however, that one important combination is omitted in
David-Sarah's proposal (modifier names aside).  Private instance
variables would likely be represented as non-configurable,
non-enumerable, yet writable properties.  I'm guessing that 'x' and
'y' (which are suggested by, but left out of the examples above) would
fit that description.

-Jon



>
> If no brackets are included then it would be equivalent to [WEC] as
> that is backwards compatible (I think).
>
> I'm not sure I like this idea. It is just an idea.
>
> Peter
> _______________________________________________
> Es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to