Apr 4, 2012, 9:13 PM
I don't think I follow on the base class needing to know its subclasses.
Re: [ChopperCharles] private and protected methods
When TacoBell inherits from foobar, TacoBell extends foobar but its identity is still TacoBell. When you issue, use parent fooBar, this uses fooBar to load its methods into TacoBell's namespace/package, and then pushes fooBar onto @ISA. @ISA is used as a method lookup table, that sets a lookup precedence for method calling. When a method is requested, it searches TacoBell, in case of any overrides, and then fooBar.
Perl doesn't really support "Private" anything. Its all Public. We are using a hack to simulate Private functions. Python has the same issue, but decided to remove any methods from its lookup tables that begin with an underscore. However, this can be bypassed very easily, because even though it may appear to be private, its still public.
In Perl and Python, private is done by convention only. It's up to the programmer to respect this.
Now in Perl 6, there has been requests to add 'private' which will do exactly as you expect. So this may find it's way into Perl 5 as well.
As for Moose, there is an extension that does private and protected modes. But, they are still remain public.
Also, there are other ways, using trait and writer attribs in Moose to simulate private.
(This post was edited by budman on Apr 4, 2012, 9:16 PM)