private attributes in objects

Brendan Eich brendan at mozilla.com
Sun Oct 11 13:48:22 PDT 2009


On Oct 11, 2009, at 1:28 PM, memolus at googlemail.com wrote:

> Thanks for your answer.
>> This sketch could use a function-valued property of this to use the  
>> private id member, for motivation.
> Does your expression "a function-valued property of this" mean  
> "method"?

Sure, informally that's a "method".


>> Sorry, I don't know what you mean. What in ES5 prevents you from  
>> using which getter or setter syntax?
> You're right, there's the complex "defineProperty" methode I could
> use, but they are not so handy.

ES5 standardizes the obj = {get foo() { return 42; }, ...} syntax  
already supported by most browsers out there.


> Anyway why shouldn't I be able to set private attributes in {}-styled
> object definitions?

I'm just trying to understand your post. I didn't say anything against  
the idea of var in object initialisers, was is proposed for Harmony:

http://wiki.ecmascript.org/doku.php?id=strawman:object_initialiser_extensions
http://wiki.ecmascript.org/doku.php?id=strawman:obj_initialiser_private

/be


More information about the es-discuss mailing list