Hello again, Eric. :)
Eric Wilhelm schrieb:
I really think the term you want is singleton. That is, there is only
one loader object no matter how many objects are created?
Yes. It is an utility function the "dataholder module" shall provide to
all subclasses. (Well, in this case I decided to move the loader method
into the base class itself 'cause it will be used very often, but there
are lots of other utility classes, like a debugger, I'd prefer to separate.)
To formalize it a bit, you might do:
package MyLoader;
my $loader;
sub get_loader {$loader ||= CM::Module::Loader->new();}
So, MyLoader->get_loader() always returns the same object. However, if
every subclass inherits the original loader attribute, you only need
the default => $loader lexical closure that I mentioned earlier.
Yes, I see. I found an example like this when I was looking around for
inspiration ;) last week, but your explanation helped me to realize that
this should be the right way for my case, too. ;)
Thanks again, that was very helpful to see the thing's a bit clearer. :)
Greetings, Bianka