Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Abstract Packages

by japhy (Canon)
on Aug 04, 2004 at 13:27 UTC ( [id://379984]=note: print w/replies, xml ) Need Help??


in reply to Abstract Packages

I'll give you merlyn's "don't do my $class = ref($obj) || $obj" advice. Don't do it.

When I need abstract methods, I usually do:

sub some_abstract_method { __abstract($_[0], caller); # ... } sub __abstract { my ($thing, $pkg, $file, $line) = @_; return if $thing ne __PACKAGE__; my $func = (caller 1)[3]; die "$func is abstract; in $file line $line\n"; }
Same general principle, but I think it's a little cleaner.
_____________________________________________________
Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: Abstract Packages
by Velaki (Chaplain) on Aug 05, 2004 at 11:47 UTC

    For abstract methods, that's practically the same as the code I use. The code I posted was for abstract classes, although I could see how you could always make the constructor abstract, and handle it from there.

    -v
    "Perl. There is no substitute."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379984]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found