[Melbourne-pm] Closures and scope warnings

Damian Conway damian at conway.org
Tue Jul 27 22:58:28 PDT 2010


Alfie mused:

> It's funny because 'my' will warn, but 'local' is fine:

That's because 'my' creates two separate variables that happen to have
the same name; whereas 'local' creates two separate snapshots of what is
intrinsically the same variable.

Yeah, I know. It *is* mainly a *philosophical* difference. ;-)

But in practical terms, repeatedly (and temporarily) modifying a
particular package variable in a single scope is a fairly common
technique (e.g. for input parsing tricks that require messing
about with $/).

In contrast, declaring two identically named lexicals in the same scope
is almost always a thinko.

Damian


More information about the Melbourne-pm mailing list