in reply to Re^3: Setting signal handlers considered unsafe?
in thread Setting signal handlers considered unsafe?
It's not a side-effect. It's not a bug. local undefines its argument.
The documentation Temporary Values via local() says:
.... The argument list may be assigned to if desired, which allows you to initialize your local variables. (If no initializer is given for a particular variable, it is created with an undefined value.)This does not say that the lvalues in the local argument list will be set undef and later the result of any initialiser will be assigned to it.
Taking the empirical approach:
gives:use strict ; use warnings ; our $fred = 78 ; { local $fred = $fred ? 'Was Defined' : '*undef*' ; print "\$fred = $fred\n" ; } ; print "\$fred = $fred\n" ;
$fred = Was Defined $fred = 78which reenforces the feeling that the variable being localised retains its old value up to the moment the new value is set.
Were it not for the side effect of setting $SIG{ALRM} to undef, nobody would ever be able to tell that being set undef is apparently a step in the initialisation of the local. The implementation may assume it doesn't matter -- we live and learn !
IMO, this quacks like a bug.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Setting signal handlers considered unsafe?
by ikegami (Patriarch) on Nov 09, 2008 at 20:03 UTC | |
by gone2015 (Deacon) on Nov 10, 2008 at 00:06 UTC | |
by ikegami (Patriarch) on Nov 10, 2008 at 08:58 UTC | |
by gone2015 (Deacon) on Nov 10, 2008 at 16:22 UTC | |
by ikegami (Patriarch) on Nov 10, 2008 at 17:07 UTC | |
|