home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: Local variable assignment bug in 4.035?
- Message-ID: <1992Aug12.231738.23823@netlabs.com>
- Date: 12 Aug 92 23:17:38 GMT
- References: <1992Aug11.025222.26759@athena.mit.edu> <1992Aug11.171836.20143@reed.edu>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 36
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <1992Aug11.171836.20143@reed.edu> mjeffery@reed.edu (Mark Jefferys) writes:
- : In article <1992Aug11.025222.26759@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:
- :
- : _% $num = 5;
- : _%
- : _% &foo($num);
- :
- : _% sub foo {
- : _% local($num);
- : _%
- : _% ($num) = @_;
- : _%
- : _% print "foo: $num\n";
- : _% }
- :
- : _% foo:
- :
- : Maybe Larry can tell us whether this is [will be treated as] a bug or
- : a feature.
-
- Perl 5 will handle this by introducing static scoping of some sort or
- other. Perl 4 handles this by blessing only the "local($num) = @_"
- form for use by anyone who doesn't understand dynamic scoping.
- Assignment to a local() takes specific pains to copy the value of the
- right-hand side before localizing the variables on the left. This
- is the sense in which "variable suicide" was fixed. It has not
- been fixed in any other sense--the general way to fix dynamic scoping
- is with static scoping.
-
- Just to satisfy your curiosity, I suspect that static scoping will
- be done with "my":
-
- my($arg1,$arg2) = @_; # list context for right-hand side
- my $foo = <>; # scalar context for right-hand side!
-
- Larry
-