defineProperty/getProperty design sketch

Mark Miller erights at gmail.com
Wed Apr 23 20:22:11 PDT 2008


On Wed, Apr 23, 2008 at 8:36 AM, John Resig <jresig at mozilla.com> wrote:
>
>  I'm confused as to why an API is being proposed which clashes with existing JavaScript-style APIs. The one case that I had seen previously, at least related to the implementation within Mozilla, is that it would look something like:
>
>   Object.defineProperty(obj, name, value,
>     Object.NOT_WRITABLE | Object.NOT_ITERABLE | Object.NOT_DELETABLE)
>
>  Which makes much more sense than the proposal (not forcing the user to create temporary objects just to insert values).


Hi John,

My impression had been that the bit-field API style, which I had
previously advocated, was also rejected on the same grounds: that it
conflicts with JS style APIs. Instead, people were talking about a
bunch of positional boolean flag parameters, which is a call-site
readability disaster:

    Object.defineProperty(obj, name, value, true, false, true)

Say what?

I do find the descriptor proposals more readable than the bit-field
proposals. Also, the descriptor proposals can more naturally
distinguish beween true, false, and left-out-so-use-default. There's
no pleasant enough way to do three valued logic with bit fields.

-- 
Text by me above is hereby placed in the public domain

 Cheers,
 --MarkM



More information about the Es4-discuss mailing list