John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
That is really simple for a single category having the same name as the module, but you would need to generate additional catagory names for fine-tuning which things are warnings or not.
Another approach is to have a global $verbose flag in the module. This is easily extended to how ever many control variables are needed.
A hibrid approach is to use warnings for on/off, and a global module variable for fine tuning.
What's the best, proper way to do this?
Here's a deeper issue: shouldn't the warning state be scoped by caller? One module wants Win32::OLE to throw exceptions, another wants the same module to emit warnings but return. I don't think any common mechanism can handle this, can it?
As a design point, I'd say that what Win32::OLE does should be avoided: don't make major semantic changes to the function calls based on a mode; instead have multiple functions.
An exception to that would be versioning. One piece of code wants v1 and another wants v2. One way to handle that is to actually import different functions. But sometimes it would be simpler just to know what the caller wanted, via dynamic scoping.
I guess that's turned into more of a Meditation. But, has anyone else dealt with this?
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Warnings from reusable code
by John M. Dlugosz (Monsignor) on Jul 31, 2001 at 00:55 UTC |