>===== Original Message From "Conrad Schneiker" <schneik / us.ibm.com> =====
>Apparently sleep-deprived Hal wrote:
[...]
>I don't know the history of 'my' in Perl, but I'd wager that the gurus
>involved had a lot of prior experience *without* it, and that such
>experience was a major cause for *adding* it. (Why they took the 'my'
>route is another issue--I suspect that possibly nicer solutions were
>precluded by the entropic MONSTER of backwards compatibility.)
[...]

Yes.

Perl originally was all globals.  Then they added the idea of
local, which is dynamic scoping.  Then they discovered what the
Lisp folks had discovered a couple of decades earlier, that
dynamic scope lent itself to some very interesting confusions.
So they introduced lexical scoping through my even though
introducing it meant completely redoing the internals of how
variables are accessed in Perl.  (Global and local variables are
looked up at run-time through the symbol table.  Lexical
variables do not exist in the symbol table.)

I believe that they would have used the name local for lexical
variables because that was what people expected to see.  But
local already had a well-defined meaning.  Therefore they named
the new thing my, and put a note in the documentation for local
(try 'perldoc -f local' to see it) saying that if you were
reaching for local then you probably wanted my.

Ruby will hopefully never have dynamic scope.  Hopefully it will
some day have easily declared lexical scope.  If Matz ever tries
to add lexically scoped access to a global variable ala Perl's
new our declaration, I will be the first to recommend that he be
put in an insane asylum for our general protection...

The fact that Perl calls it my is not a good reason to call it
that since it is a name that the Perl folks are not too happy
with.  The fact that Perl folks are used to it is no reason to
include it in Ruby.  Perl tried a lot of things and some worked
better than others.  (I don't think that Matz copied reset..I
wonder why not?)

However the idea of have an easy way to guarantee private
lexical scope is one that I really like, is supported in a lot
of languages, and I hope is something that Ruby gets.

Cheers,
Ben