>>>>> "SQ" == Sean Quinlan <[EMAIL PROTECTED]> writes:
SQ> OK, I have this method, gripe, in my base class (Foo) which does some
SQ> verbosity sensitive error message control. I have another class
SQ> (Foo::Bar) that base's the first.
SQ> package Foo::Bar;
SQ> use base(Foo);
SQ> Now in my code things like:
SQ> $baz = Foo::Bar->new();
SQ> $baz->gripe("What happened?");
SQ> Work just fine, like expected. Where I'm having trouble is in that new
SQ> up there. What I wanted to do is be able to call gripe from inside new,
SQ> before $self has been blessed (while I'm validating parameters):
SQ> # self as first arg so gripe doesn't need recoding
SQ> gripe($self,"Now what?");
that is a direct sub call and doesn't do any method lookup in the @ISA
tree.
SQ> But that doesn't work. Now I thought use'ing base meant it inherited all
SQ> of the base class' methods. But apparently it can't find them until
SQ> after the object hass been blessed and gripe is called in OOP syntax
SQ> $self->gripe("yeah yeah yeah");.
that is irrelevant. if you don't use a method style call, you don't get
any OO semantics. so you have to have a blessed $self before you make
the call and you need to make a method call.
if Foo::gripe is written to take a class OR an object (and it could be
done that way), then you can call it like:
Foo->gripe( blah ) ;
or even Foo::Bar->gripe( blah ) ;
since you did he use base line earlier.
or even:
__PACKAGE__->gripe( blah ) ;
:)
but then you would need to use some default or package params to control
how it behaves vs what is normally passes in $self.
SQ> If not, could those on the list working on newer versions of Perl kindly
SQ> fix this please. Or explain why this has to be (preferably in samll
SQ> words)? Thanks!
it isn't a problem in perl, but in your understanding of perl OO
semantics.
and now, how can i help you get your money into my account?
uri
--
Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm