in reply to Re^2: Using perlclass 'methods'
in thread Using perlclass 'methods'
Simple things first: It is not the message Undefined subroutine &main::ratio because we are not in package main but in a class Gear where the method is defined.
Whether Perl could imply $self->ratio when a method is called without an invocant is an interesting question. I guess it is a real challenge to the interpreter: It needs to figure out that ratio is a method and not a sub. As far as I know, this is not possible today. Whether this insurmountable, I can't say. Perhaps we should open an issue for Perl?
And... of course the class feature is half baked. It is rather new and will take time to mature. For this issue, it behaves like all other OO systems in Perl. It could do different because it has the class and method contexts which the other systems don't have. Perhaps it will, at some point in the future?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Using perlclass 'methods'
by bliako (Abbot) on Jul 18, 2024 at 12:54 UTC |