On Fri, Oct 04, 2002 at 12:03:44AM -0400, Trey Harris wrote:
> In a message dated Thu, 3 Oct 2002, John Williams writes:
> 
> > On Thu, 3 Oct 2002, Trey Harris wrote:
> >
> > > Incidentally, has there been any headway made on how you DO access
> > > multiple classes with the same name, since Larry has (indirectly) promised
> > > us that?  I.e., I import two classes "LinkedList" and "BTree", both of
> > > which define a "Node" class?
> >
> > Hopefully, LinkedList defines a LinkedList::Node class, and BTree defines
> > a BTree::Node class.  Either by explicitly naming them that or by virtue
> > of being defined as an "inner" class (which might also make it private).
> 
> Ah, but that's the way you do it now--name the classes differently.
> (Easy--assuming you control the source code!)  In Perl 6, we're supposed
> to be able to use multiple versions of the same class concurrently, which
> I think would imply also being able to use multiple classes that happened
> to be named the same thing.

It doesn't imply that. The currently proposed solution is that the true
name of a class will include at least the version. But, you can alias
classes just like variables:

    # compile time
    class Foo is really (Acme::Kung::Foo-1_54);

    # runtime
    class Foo := Acme::Kung::Foo-1_54;

        # (the full classname format hasn't been hashed out yet, this is
        # just for sake of illustration)

So, you could reuse the same short name for multiple different classes,
as long as you lexically scoped your aliases. I wouldn't recommend it
though, unless you're trying to confuse people. Even in the rare case
when you need to use two different versions of the same class in the
same code, there will be a clearer way to do it.

More useful: keep a site-wide or company-wide file of version aliases to
make sure everyone uses the same version, and to make upgrades to the
next version as simple as editing a single file.

Allison

Reply via email to