in reply to Re: Handling cascading defaults
in thread Handling cascading defaults
One programming principle is "optimizing for the common case". The common case here is that I create a new "err" call in a script, as above. If I switch the OO style, instead of writing out 'err' each time, I'm now writing out '$err->err', so the solution makes more work in the common case.
What about the magic that CGI.pm uses, where you can call routines with an OO style, or with a procedural style, and you don't even have to start with "new CGI", because there's a default object created. Can someone explain that?
As far as fetching the caller's package, perl makes that easy: $callers_pkg = caller;
I did end up using that in an inbetween module once, with the logic of "If my caller's package has defaults use those, otherwise use the defaults in CGI::Err". It worked, but that didn't seem clean either...
Thanks for any further comment. -mark
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE (tilly) 1: OO vs. procedural style
by tilly (Archbishop) on Aug 19, 2000 at 18:35 UTC |