This is the discussion page for enumerability.

Old Proposal (not taken)

Instead of a meta DontEnum bit on each property, define a builtin namespace called enumerable:

namespace enumerable

The for-in and for-each-in operators will find all the enumerable properties and no others. Dynamic properties go in the enumerable namespace automatically. Enumerable namespace is open automatically for ordinary code as if the program included

use namespace enumerable


  • as currently proposed, properties can only be in one namespace at a time. Putting them in the enumerable namespace effectively makes them public. This is compatible with ECMA-262 but may be too limited.
  • an alternative is to define enumeration in terms of the proposed iterators and generators
  • E4X: do we extend iteration statements to allow user to specify which namespace to iterate over? Then again perhaps this conflicts with E4X filter syntax.
  • in ECMA-262, does !DontEnum imply !DontDelete? In other words we have examples of non-enumerable, dynamic, properties, but no examples of enumerable fixed properties.

The spec grammar allows multiple attributes, there doesn’t seem to be any restriction on “public English var foo”. So “enumerable” could be an internal namespace, like “public”?

DontEnum looks like something we should not encourage, better to use iterators.

Lars T Hansen 2006/03/17 13:10

discussion/enumerability.txt · Last modified: 2006/05/30 23:14 by graydon
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki