Dan Sugalski writes: > At 05:14 PM 12/5/2003 +0100, Leopold Toetsch wrote: > > set I2, P1["Foo\x00i"] # I1 == I2 > > > >gets currently the attribute idx (0) of "$Foo::i". > >Q: Should the assembler mangle the "Foo::i" to "Foo\0i" > > I don't like it either, but the alternative is to impose an external > hierarchic structure. Which we certainly could do, though it may make > some things more difficult. > > I'm more than willing to entertain arguments for and against the > hierarchic structure, but we're closing in on the point where we fix > the scheme and don't change it any more.
I'm not sure mangling is a good idea: think about anonymous classes. If we assign a name to each lexical class, then there are problems when one instance of a class inherits from another instance of the same class. That is:
sub make_class(Class $parent) { return class is $parent { has $.stuff; } }
my $class1 = make_class(Object); my $class2 = make_class($class1);
So, if you name that lexical class _class_0001 or something, "_class_0001\0$.stuff" refers to both attributes.
I don't think so. I'm definitely not up to your level regarding Perl6 but I believe
the example you give translates to:
1st call return class is Object { has $.stuff # Object::_class_0001::$stuff } 2nd call return class is "_class_0001" { has $.stuff # Object::_class_0001::_class_0002::$.stuff }
No collision.
$class2 has 2 $stuffs but at different class scopes.
I'm also not disagreeing, I prefer a hierarchical approach as well but I need to
take time to formulate a good argument for Dan.
If you generate a name for each instance of a lexical class, you're setting yourself up for some major runtime cost -- concatenating the class name to the attribute on each access (or memory cost if you want to cache).
This is why I don't like the non-hierarchical approach.
There are, of course, disadvantages. It would be slower for cases where $something::or::other are acessed a lot, as it's three lookups in the absence of cache. Also, it's not as easy to tell where a symbol table
I think this is a Perl6 problem more than a Parrot problem since no matter how many optimizations we add to Parrot, Perl6 may or may not be able to use them due to the dynamic nature it has.
I definitely want to tie namespaces though.
Me 2.
-Melvin