Nathan Wiger wrote:
>
> > =head1 TITLE
> >
> > Keep default Perl free of constraints such as warnings and strict.
>
> I second this. If the current definition of "lexical" remains unchanged
> (which I strongly suspect it will),
Lexical scope has a standard non-Perl definition. It means you can
tell which variable an identifier refers to simply by looking at the
context, i.e., a lexical variable declared within a function is in
scope only within that function; this is in contrast to dynamic scope,
where an identifier refers to a variable from the current scope or the
scope of the caller. In other words, with lexical scoping a variable
lookup starts in the current block and proceeds outwards according to
the scope in which the block was declared, while with dynamic scoping
a variable lookup starts in the current scope and proceeds outwards
according to the scope in which the subroutine was called.
That's not exactly a textbook definition (probably more confusing,
actually), but the end result is that dynamic scope varies at runtime:
$x = 5;
sub one_x {
$x *= 3;
}
sub two_x {
local($x) = @_;
$x += 2;
one_x();
}
Notice that the $x in one_x refers either to the global $x if called
from the main program, or to the "local" $x in two_x when called from there.
> I think Perl should remain loosely
> typed by default.
"Loosely typed" is not a synonym for the types of scoping under
discussion. Loosely typed refers to whether a variable can just be a
scalar (integer, real, object, string, whatever) or whether you have
to declare a type for it, like in C. It doesn't have anything to do
with lexical scoping.
(I'm pointing all this out to avoid confusion. When issues get
confused, we can all wind up on a bandwagon we didn't intend to be on.)
For the record, I'm very much in favor of keeping Perl loosely
typed, too.
J. David