New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable suicide considered out of fashion #708
Comments
From mjtg@cus.cam.ac.uk=head2 What is variable suicide and how can I prevent it? is still there? It refers to a bug which was mended well before I suggest its removal. Mike Guy |
From [Unknown Contact. See original ticket]M.J.T. Guy wonders:
Inline Patch--- perlfaq.orig Tue Dec 19 14:36:08 2000
+++ perlfaq.pod Tue Dec 19 14:37:23 2000
@@ -496,8 +496,6 @@
=item * What's a closure?
-=item * What is variable suicide and how can I prevent it?
-
=item * How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?
=item * How do I create a static variable?
@@ -761,6 +759,10 @@
=head1 Changes
=over 4
+
+=item 19/December/2000
+
+Removed variable suicide question.
=item 1/November/2000
--- perlfaq7.orig Tue Dec 19 14:36:17 2000
+++ perlfaq7.pod Tue Dec 19 14:37:42 2000
@@ -322,27 +322,6 @@
hypothetical timeout() function to access the lexical variable
$line back in its caller's scope.
-=head2 What is variable suicide and how can I prevent it?
-
-Variable suicide is when you (temporarily or permanently) lose the
-value of a variable. It is caused by scoping through my() and local()
-interacting with either closures or aliased foreach() iterator
-variables and subroutine arguments. It used to be easy to
-inadvertently lose a variable's value this way, but now it's much
-harder. Take this code:
-
- my $f = "foo";
- sub T {
- while ($i++ < 3) { my $f = $f; $f .= "bar"; print $f, "\n" }
- }
- T;
- print "Finally $f\n";
-
-The $f that has "bar" added to it three times should be a new C<$f>
-(C<my $f> should create a new local variable each time through the loop).
-It isn't, however. This was a bug, now fixed in the latest releases
-(tested against 5.004_05, 5.005_03, and 5.005_56).
-
=head2 How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?
With the exception of regexes, you need to pass references to these |
Migrated from rt.perl.org#1610 (status was 'resolved')
Searchable as RT1610$
The text was updated successfully, but these errors were encountered: