NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Why submethods (Score:2)
But factoring method implementations out into a subroutines is also extremely annoying, because a subroutine doesn't provide the internal conveniences that a method does. In particular, it doesn't have an invocant and so you can't call $.attrs or &.methods. Instead you would have to pass the invocant to the subroutine call as an argument and then call accessors and methods explicitly through that argument.
So we need a mechanism that is externally (i.e. from a class interface point-of-view) a subroutine, but internally has the features of a method (i.e. has an invocant). Since it's externally sub-like but internally method-like, we call this useful construct a submethod.
Reply to This