Namespaces as Sugar (was: complexity tax)

Jeff Dyer jodyer at
Wed May 28 16:20:27 PDT 2008

On 5/27/08 8:45 AM, Maciej Stachowiak wrote:

>> Is the cost too high? I think that depends on how the name lookup
>> algorithm works on real-world code. AS3 developers have data to
>> share. Let's get into that.

You looking at me? ;-) I don't have that data, but I'll gladly see if I can
find some.

> I'd love to hear the data. AS3 developers, can unqualified lookup of
> object properties on untyped references in the presence of property
> namespaces be as fast as when there aren't namespaces at all?

Seems unlikely since more work is being done.

> If so, how? The most obvious way to do property lookup when there is no
> static type info is a hashtable lookup on each prototype chain entry,
> but I do not see an obvious way that a single hashtable lookup can
> look in multiple namespaces. I suspect the answer to this in AS3 is
> that if you want performance, you have to use type declarations.

Some of the complexity in the name resolution algorithms is to ensure that
references to fixed properties cannot be shadowed. This means, with or
without static type information, references to fixtures need only be
resolved once. So the incremental cost that is incurred during unqualified
name lookup is amortized across multiple evaluations of the reference in
which it occurs. 

Other bits of complexity in those algorithms is there to disambiguate names
in the case of conflicts. It would be interesting to study how often this
code gets invoked in practice. It might not come into play all that often.


More information about the Es4-discuss mailing list