in reply to Object Method Call
In Perl 5, the difference between a function, a class method, a non-virtual method and a virtual method is entirely in the call.
| Function call | foo(...) |
| Class method call | $class->foo(...) |
| Non-virtual method call (Hardcoded) | $o->Class::foo(...) |
| Non-virtual method call (Dynamic) | my $method = __PACKAGE__->can('foo'); $o->$method(...) |
| Virtual method call | $o->foo(...) |
Needless to say, people only create virtual instance methods in Perl.
You're expected to use the correct calling convention for a given sub.
|
|---|