[LA.pm] Classes with heterogeneous objects?

Uri Guttman uri at stemsystems.com
Fri Mar 2 21:27:50 PST 2012


On 03/03/2012 12:06 AM, Randal L. Schwartz wrote:
>>>>>> "Mike" == Mike MacKenzie<mackenziemikebus at yahoo.com>  writes:
>
> Mike>  Can any of you guys think of an interesting use case for a class
> Mike>  that creates objects with disparate internal structures like
> Mike>  this?   Or do you know of an existing module that does this?
>
> The big problem would be the amount of sheer navel-gazing you'd need
> within the class to do anything like accessing the attributes.
>
> Hint:  if you have to use "ref" a lot in your design, you lose.

and ref won't help as it will just return the class name on any blessed 
object regardless of the underlying type. reftype from scalar::util will 
do what you want. and a simple dispatch table keyed on the ref type 
would eliminate the need for many calls to reftype.

now as for a use case, i am stumped. some questions are best left 
unanswered. but i bet damian could find one if asked!

uri


More information about the Losangeles-pm mailing list