Call for opinions: attribute defaults and renaming "flexible"

Ingvar von Schoultz ingvar-v-s at comhem.se
Sun Aug 24 07:05:50 PDT 2008


Allen Wirfs-Brock wrote:
> At the Thursday, August 21, ES3.1 design conference call we debated two 
> decision points relating to property attributes but did not reach 
> consensus on either item.
> [...]
> If, after 
> reviewing the alternatives below, you have an opinion replay to the list 



Executive summary:

I think the best name is "configurable". It becomes very concrete
indeed if Object.defineProperty() is changed to Object.configure().

I think defaulting the attributes to false is best.



Reasons, apart from those mentioned by Allen:

-- Many people will use abstracting helper functions that manipulate
these attributes. When you're reasoning about several such functions
at a time, negatively written attributes can become confusing.

-- If instead you manipulate the attributes directly, you'll probably
still want helper functions, for brevity and to get the defaults
that suit you best. Then the above applies again.

-- If you're not using any helper functions, and want positive
defaults, you can get this by first creating and then modifying:

        obj.hidden = ...;
        Object.defineProperty (obj, "hidden", {enumerable: false});

-- When people are uncertain about the consequences of touching
a setting, some will see the default as a strong recommendation,
to be disobeyed only if you have an even more compelling reason
and have thought through the consequences.

Regarding the name:

-- If you work on your helper functions so seldom that you forget
the details, "configurable" helps you remember by saying what it's
for, "flexible" doesn't.

-- The name "configurable" makes a surprisingly big difference
in clarity. Try reading parts of the ES3.1 draft while imagining
[[Flexible]] replaced with [[Configurable]]. The text feels very
much clearer and more specific.

-- If Object.defineProperty() were changed to Object.configure(),
the names would reinforce each other so that both would become more
concrete. The name .configure() could be used both for singular and
plural, distinguished by the different parameters. .getProperty()
could become .getConfig().

-- 
Ingvar von Schoultz



More information about the Es-discuss mailing list