Object IO (Typedef problem)

Michael P plumpy at krimedawg.org
Mon Jul 22 19:46:34 CDT 2002


On Mon, 22 Jul 2002, Jason Annin-White wrote:

> I know how to typedef a reference to a scalar, array, or hash, however,
> I do no know how to typedef the reference to be of type PDX::service.

By the way, just for clarification, you're talking about two different
things here.

In perl, you can have references to scalars, arrays, hashes, code or
globs.  You can then dereference them to get the original value.

"objects" (like PDX::service), however, are not a seperate type.  Your
PDX::service "object"  is not actually its own type, but rather is itself
a reference (99% of the time it's a reference to hash, but it could also
be a reference to a scalar, array, or anything else).  So on most objects,
you can treat them as hashrefs and do things like $object->{barf} = "dog";

Your PDX::service object just contains some magic to allow you to call
methods on it.  You create that magic when you use the bless() function.
Using bless() does NOT change the fact that you still have a hashref.  It
just adds some special magic to the hashref that allows you to say
$object->method();

I don't know if that helps clear up any confusion or not.  Anyway, the
point is: there are no typedefs.

TIMTOWTDI



More information about the Pdx-pm-list mailing list