Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Tricky subclassing problem: Parent class method uses static value from child class (http://www.velocityreviews.com/forums/t900057-tricky-subclassing-problem-parent-class-method-uses-static-value-from-child-class.html)

don.hosek@gmail.com 09-26-2006 08:45 AM

Tricky subclassing problem: Parent class method uses static value from child class
 
I want to be able to do something along the lines of:

package A;
@ISA = ('B');
use Class::Std;

my $foo='this';

package C;
@ISA = ('B');
use Class::Std;

my $foo='this';

package B;
use Class::Std;

sub method {
do something with $foo
}

(obviously, there's a bit more to this, but I'm trying to abstract
things as much as possible).

But I can't seem to find anyway to make $bar->method(); see the
appropriate value of $foo depending on whether $bar is an object of
type A or C. Am I going to have to have a method (or AUTOMETHOD) to
copy $foo into the B namespace when method is called? Or is there a
more elegant way of handling this? [As a note, in actuality, I'm
dealing with a %foo rather than a $foo].



All times are GMT. The time now is 06:01 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57