ES4 draft: Namespace

Waldemar Horwat waldemar at
Thu Mar 13 16:35:06 PDT 2008

Lars Hansen wrote:
> The natural behavior on < etc would be as in ES3, ie, if valueOf
> on namespace returns "this", as is most natural, then the
> toString() operator ends up being called, and the string
> names of the namespaces would be compared.  Since the string
> representation is not specified, there is no specified ordering,
> but unless the implementation randomizes the output of toString,
> it should at least be dependable per-implementation.  We could
> add a constraint to toString that says that if two namespaces
> N1 and N2 are created from strings S1 and S2 then N1 and N2
> compare the same as S1 and S2.  (For unforgeable namespaces --
> those created without an explicit string name -- all bets are 
> off, and no two are equal.)

Do we ever want to allow for any ordered containers analogous to C++'s map<> and set<>?  If we were to define one then this could cause problems because an ordered container typically uses a less-than comparison function and considers x and y to be equal if neither x < y nor y < x holds.

The actual order wouldn't matter, as long as two different namespaces wouldn't appear equal to each other in the above sense.


More information about the Es4-discuss mailing list