Thus wrate Dan Sugalski:...At 10:13 AM -0800 1/13/04, Jeff Clites wrote:Short version: I was originally going to argue for fully hierarchical namespaces, identified as above, but after turning this over in my head for a while, I came to the conclusion that namespaces are not conceptually hierarchical (especially as used in languages such as Perl5 and Java, at least), so I'm going to argue for a single string (rather than an array) as a namespace identifier.
Performance-wise, I would guesstimate that it's more-or-less a wash between parsing strings and parsing multidimensional keys, so as long as we precreate the keys (keep thm in a constant table or something), I see no performance issues.
It turns out that it makes a big difference in lookup times--doing one hash lookup v. several. I did this experiment using Perl5 (5.8.0): Create a structure holding 1296 entries, each logically 12 characters long--either one level of 12 character strings, or 2 levels of 6 character strings, or 3 levels of 4 character strings, or 4 levels of 3 character strings, and look up the same item 10 million times. Here is the time it takes for the lookups:
1-level: 14 sec. 2-level: 20 sec. 3-level: 25 sec. 4-level: 32 sec.
Conclusion: It's faster to do one lookup of a single, longer string than several lookups of shorter strings.
Of course, as Uri pointed out, even if we go with hierarchical namespaces, we could implement these internally as a single-level hash, behind the scenes, as an implementation detail and optimization.
JEff