Re: Accessor to module

[email protected] (Bianka Martinovic)
Newsgroups perl.moose
Message-ID <[email protected]>
Hi Eric. :)

Thanks for your response!

> You mean the default => sub {} is called whenever an object in that 
> class or a derived class is created?  That is by-design.

In fact, I implemented a BUILD method in the loader object and let it 
print a message. It is called when a submodule calls the loader 
accessor. So, yes, I mean that.

> You want it to be a singleton that is shared across all objects?  

Yes, that's right. I am going to have a base class for my application 
that 'collects' the methods of some helper classes (dynamic module 
loading at runtime, debugging, etc) and provides them to all objects 
that inherit from it. (I know, that's evil...)

 > If so,
> you've got a valid solution in the code above.  Another alternative 
> would be to construct CM::Module::Loader->new to return this singleton 
> (but that changes the policy at a different level.) 

I thought about that, too, but as you said, that would change the policy 
at a different level. I just don't want to do that.

> You mentioned "overhead", which implies that you're only thinking in 
> terms of optimizing?  If so, you can't do that.  If you want each 
> object to have a distinct instance of 'loader', you need to create a 
> loader every time you create an object, which is what default => sub {} 
> usage is intended to support.

Ahm, no, I'm just going to provide a - hm - let's say, a single entry 
point for a bunch of helper modules. I am no aware of a term to describe 
this right, I'm afraid.

Thanks again. :)

Greetings, Bianka
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.