Perhaps it helps if i use "attribute" instead of "member", so one can't confuse "member" with "instance"...
Abigail's proposal is to store attribute values of instances in lexical (or only package-global) hashes to make them safe from subclasses that might clobber attributes that are private to the superclass:
sub some_method {
my $self = shift;
$self->{'_very_internal_flag'} = 1;
#...
}
A subclass might also need a '_very_internal_flag' (stored as attribute of an instance) and suddenly it all breaks.
So the idea is to store the attribute data in kind-of "registry": a central repository that keeps thes attributes in it's defining class.
My first thought on that was to write a module that is a superclass and contains such a registry for all classes. It gives you two methods: get( attribute ) and set(attribute,value) (probably with diofferent names). These methods get/store these values in that central registry and determine the class, in which that actual attribute was defined and thus must be kept apart from other descending classes defining the same attribute. I thought of something like that because of my lazyness: it would save typing for many classes based on that principle.
Such a module is easy to write:
--
http://fruiture.de |