ES4 draft LAST CALL: Object

Mark S. Miller erights at google.com
Thu Mar 20 18:05:28 PDT 2008


2008/3/20 Lars Hansen <lhansen at adobe.com>:
> The only substantive change since the previous draft is a rename of
>  __createProperty__ to __defineProperty__ in order to mirror the names
>  __defineSetter__ and __defineGetter__.  The latter two are not in ES4
>  but in some browsers and could be expanded to accept additional flags to
>  control enumerability and so on.


* I still prefer __defineProperty__ (under whatever name) to be a
static property rather than an instance property, so that an object
can reliably perform this operation on itself without worrying about
whether it is shadowed by an own property of the same name. As an
instance method, to protect against this shadowing, one must instead
write:

    Object.prototype.__defineProperty__.call(this, ...)

This is so much less convenient than the unsafe

   this.__defineProperty__(...)

that people will get sloppy. Part of programming language design is to
make the safer way also generally be the easier way. The innumerable
places where

   Object.prototype.hasOwnProperty.call(this, ...)

were or needed to be written should have already taught these lessons.


* I also continue to think that any of the other alternatives for
parameterizing __defineProperty__ were more readable than a bunch of
positional flag parameters whose order will often be mis-remembered.
My favorite remains a C-style or-ing of bit flags, with manifest
constants defining the bits.

-- 
 Cheers,
 --MarkM



More information about the Es4-discuss mailing list