Re: (re Mail::Reporter INIT block ) Re: Mail-Box-2.057 errors

Mark Overmeer <[email protected]> Tue, 21 Sep 2004 11:52:44 +0200
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* DH ([email protected]) [040921 11:42]:
> This message just for you (last message about this).
> 
> > > No there aren't (Mail::Reporter doesn't have circlar dependencies).
> > > Besides, circular dependencies are design flaws.
> > > Why do you keep trying to imagine a hypothetical?:)
> > 
> > .... because in my experience, module users often create those hypothetical
> > situations....
> 
> And why is that a concern of yours?
> (you should worry about your code)

... because often these cases are still valid.  Don't worry, even with
my uttermost carefulness, I still get enough reports for things in
border cases.  See the change-log :-(

> > Circular dependencies do happen, but happily not so often.  The main point
> > was, that using a BEGIN or INIT is "nicer" (for some definition of "nice")
> 
> They always happen by mistake.
> My main point was that you imagined a problem where one doesn't exist.
> BEGIN is not neccessary, and INIT is not neccessary
> (and INIT just creates problems in persistent enviroments).

An example: I like to use Perl as configuration script, where all my
config is located in one file.  Configuration must be as simple as possible.

 package Server;
 use Server::Config;

 sub new(@)
 {   my $class = shift;
     bless {netmask = shift || $Server::Config::default_netmask}, $class;
 }


 package Server::Config;  # in user-space
 use Server;
 
 our $default_netmask = ...;
 our $firewall  = Server->new(...);
 our $webserver = Server->new(...);


 package main;
 use Server::Config;
 $Server::Config::firewall->start;
 
In this case, I was not succesfull in removing the circular dependencies
without adding a lot of complexity.  (in reality, the code is a little
cleaner, using Exporter and such).

There has never been a case besides config files that I get stuck in
these circles.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net