July 25, 2012 - TC39 Meeting Notes

Herby Vojčík herby at mailbox.sk
Sat Jul 28 09:07:25 PDT 2012



Brandon Benvie wrote:
> It seems like you're indicating that changing a property to a value,
> presumably a primitive, is somehow different from setting it to a

I never mentioned a primitive, please don't put into my mouth what I did 
not say.

> function. Regardless of anything else, that's not true even in the way

It does not depend what the value is at all. Function is as good as 
number or plain object or array or whatever.

The distinction is whether the property is used to store (published) 
state (from the API PoV) (and that state can be anything) or it is more 
an infrastructure of an object. That is, what is the primary API of the 
property name:

1. To hold a (settable) state (so it is primarily read by a.foo and used 
afterwards in various ways)? Then it should be set by assignment.

2. To use otherwise (most often |a.foo(args)|, other such use is maybe 
|if (a.isAnimal)| defined in prototype)? Then it should be set by 
defineProperty; it is not meant to have "I am something you should be 
setting by =" API.

Most often 1. is enumberable and 2. is non-enumerable. It is more or 
less the same philosophical distinction: between "public API" and 
"private API".

> you mean it because a function can have a thunk that contains state and
> accomplishes the same thing as setting primitive data type. It just can
> almost be used for other non-data things too like methods. There's no
> way to differentiate from a naive standpoint though.

Herby


More information about the es-discuss mailing list