"J. David Blackstone" <[EMAIL PROTECTED]> writes:
[...]
> I agree with you. However, I am unable to find a case in which a
> package global could not be replaced with a lexical defined in the
> module's .pm file and an accessor method for it. Even if you are
> extending a class, you can still provide this.
Modes. Emacs Lisp uses this (I'm not convinced that's a
recommendation). Suppose I have a flag $PKG::verbose which prints
descriptive messages to LOG if 1 (but if 2 does something else, since
bits are significant). If it's a global, I can do this:
{
local $PKG::verbose = 1;
PKG::frobnicate;
}
# Back to previous verbosity level
Lacking true dynamic variables, this doesn't work (although
unwind-protect, if we had that, could also provide for restoring
variables).
The best we can do is:
{
my $old_verbosity = PKG::get_verbose;
PKG::set_verbose(1);
PKG::frobnicate;
PKG::set_verbose($old_verbosity);
}
but that doesn't work in the presence of eval{}/die. So you also need
unwind-protect.
[...]
--
Ariel Scolnicov |"GCAAGAATTGAACTGTAG" | [EMAIL PROTECTED]
Compugen Ltd. |Tel: +972-2-6795059 (Jerusalem) \ We recycle all our Hz
72 Pinhas Rosen St. |Tel: +972-3-7658514 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555 http://3w.compugen.co.il/~ariels