Object Initialiser Extensions Strawman

Daniel Friesen lists at nadir-seen-fire.com
Tue Aug 11 15:11:41 PDT 2009


This is just a comment from someone outside the group, but...
Taking a look at the method properties and const modifiers I notice one
thing that seams superfluous and another that seams missing.

If I read the proposals there correctly, then the proposed:
var obj = {
method foo() {/* ... */}
};
Is syntactically the same as:
var obj = {
const: function foo() {/* ... */}
};

The thing that I see missing is functions that are just non-enumerable.

Personally during programming, most of the time I wouldn't want to
create methods of an object that are non-enumerable (though I do see
reasons other might) but I do see reason to want to create methods that
are still writable and configurable, but are non-enumerable.

Taking a look at some of the engines, it seams that methods on most of
the standard prototypes are non-enumerable, however they are still
writable and configurable.

I can see reasons for someone to want to create prototypes for their
classes with non-enumerable methods.

Also from my perspective the word "method" doesn't exactly signify
non-writable, non-configurable to me, I can understand non-enumerable
since it's being declared that's it's not a normal property, but it
doesn't signify permanency any more than function does imho.


Rather than using the keyword method, I'd propose at least reusing
const, and using method to refer to non-enumerable, but still writable
and deletable methods on an object.
var obj = {
method foo() {/* this function property is deletable and configurable,
but not enumerable },
const bar() {/* this function property is non-deletable,
non-configurable, and non-enumerable (going by what was written in the
const proposal) */ }
};
The idea of `const fn() {}` comes from the `const fn() { /* ... */ }`
pseudonym I've seen used here on this list and in the strawmans to refer
to non-modifiable functions.

A little stretch but alternatively `const method fn() { }` could be used
instead, but I don't see to much reason for that unless the decision to
tie certain keywords to certain attribute states and combine them
together in this way (like how other languages like Java may use
something like public static final ...).

~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]

Allen Wirfs-Brock wrote:
>
> At the last TC39 meeting we talked briefly about a few possible ways 
> to extend object literals in Harmony in order to improve their utility 
> as an abstraction mechanism.
>
> I’ve written up a strawman proposal that covers a few possible such 
> extensions. It can be found here at 
> http://wiki.ecmascript.org/doku.php?id=strawman:object_initialiser_extensions
>
> Allen
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> es-discuss mailing list
> es-discuss-4eJtQOnFJqFAfugRpC6u6w at public.gmane.org
> https://mail.mozilla.org/listinfo/es-discuss
>   

-- 
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]


More information about the es-discuss mailing list