Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Static method vs virtual method

by moritz (Cardinal)
on May 09, 2009 at 10:41 UTC ( [id://763025]=note: print w/replies, xml ) Need Help??


in reply to Static method vs virtual method

In C++, a virtual method is one that can be redefined in inheriting classes. In that sense, all methods in Perl are virtual.

In Java and C++ a method is called static, if it can be called on the class, not the object itself. In that sense, all methods in Perl are also static by default. You can explicitly disallow the static usage of a method with something like this:

use Scalar::Util qw(blessed) sub non_static { my $self = shift; die "Don't use as a static method" unless defined blessed($self) ... }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found