Classes and class namespaces
plobsing at gmail.com
Wed Mar 10 04:06:10 UTC 2010
Working on tt1015 I've run into some snags.
Is the namespace of a class a property of the class? I'm pretty sure
it is, but it leads to questions I don't know how to answer.
Can there be more than one class that has the same namespace even if
looking up a class using this namespace returns only one, or possibly
none, of these?
If classes have their namespaces and are unique per namespace, if I
clone a class, I should get the exact same class back, right? If I
clone, I want an object that has all the same properties, but there's
only one class tobject that can have this namespace.
If classes have their namespaces and aren't unique, I should get back
a copy with the same namespace, correct?
We have a test that says clones should be anonymous, but this doesn't
quite make sense to me from either perspective. The only way I can see
this making sense is if classes don't have their names, but I'm pretty
sure that's not the case.
In the current system, if you freeze a class and thaw it in a new
parrot that has not loaded this class, it will install itself in its
namespace. If there's already a class loaded in that namespace, it
won't. But if the class is not loaded but its parent is, the parent
will be anonymous (and separate from the already loaded class), but
the child will be installed in its namespace. This could be confusing,
for example, when monkey patching.
I just can't see how that is right. Either classes are unique
per-name, in which case the child should reference the official
version of the parent class, or classes aren't unique, in which case,
it should be perfectly normal to have a class not be in its namespace
and classes shouldn't be put into their namespaces automatically on
BTW, the tt1015 branch is based on the assumption that clone(x) =
thaw(freeze(x)). If this shouldn't be true, I would very much
appreciate an explanation as to why.
More information about the parrot-dev