[Israel.pm] Objects and classes

Yuval Kogman lists at woobling.org
Wed Jan 14 12:18:17 PST 2004

On Wed, Jan 14, 2004 at 09:22:18PM +0200, semuel wrote:

> But in these languages, when you subclass, the new class have a name
> of its own.
> So you say that in perl subclasses lives in their superior class
> name space.

If that's the namespace the author decided to give it.  In short, not
necessarily. Any class can subclass any class...

FireTruck can subclass Truck, and Truck::Fire can also do that.

Truck can subclass Vehicle, or Vehicle::Big, and Vehicle::Big can
subclass Thing.

They're all different namespace.
Perl namespace have no meaning except the one you give to them.

To Perl, wether a class is the same or not is like

   'Apache::RequestRec' eq 'Apache::RequestIO';

If you want, for the sake of organization, someting similar, like
putting them both under Apache. But there is no meaning except that
which is implied to the user. The user knows this has to do with
Apache. But perl would be happy with Apache::RequestRec and

It might have been different if there was a notion of current class,
and namespaces relative to it, like in a file system. That way you
could do

package Person::Nice;
our @ISA = ('..::');

and Person::Nice would be a Person.

But, AFAIK (not that it isn't possible - the stash /is/ heriarchal),
that logical notion does not exist.

 ()  Yuval Kogman <nothingmuch at woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me groks YAML like the grasshopper: neeyah!!!!!!

More information about the Perl mailing list