-
Notifications
You must be signed in to change notification settings - Fork 577
Add LOCAL method; was "local first sets to undef then assigns, but is documented to 'initialize'" #14294
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
Comments
From @epaCreated by @epaThe documentation of local() in perlsub says The argument list may be assigned to if desired, which allows This led me to believe that local $x = 5; would initialize $x with the value 5; that is, save the old value of local $x; which saves the value of $x, sets $x to undef, and then in the next #!/usr/bin/perl Here I expected to see store 1 # first assignment but instead the output is store 1 Why is the value undef being assigned to the variable before setting Perl Info
|
From @cpansproutOn Tue Dec 02 06:19:28 2014, eda@waniasset.com wrote:
�local� is a can of worms that nobody wants to touch, because it is so hard to fix anything. See #119683, for instance. -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From @epaYou seem to be implying that the behaviour of first assigning undef and then If so, it could just be noted in the documentation that for reasons of About #119683, at first glance it appears that one should just forbid -- |
From @cpansproutOn Tue Dec 02 09:08:37 2014, eda@waniasset.com wrote:
I don�t mean to imply anything more than this is a very fuzzy area and may not get much attention. And also the behaviour is likely to change in future versions if we do ever get localisation straightened out.
But you have to be able to localise $!. -- Father Chrysostomos |
From @epaAh... I wasn't aware that localizing ______________________________________________________________________ |
From @LeontOn Tue, Dec 2, 2014 at 3:19 PM, Ed Avis <perlbug-followup@perl.org> wrote:
I have hit this too, causing a race condition. I would love to see this Leon |
From @exodistTest::Builder localises On Tue, Dec 2, 2014, 1:42 PM Ed Avis <eda@waniasset.com> wrote:
|
From @LeontOn Tue, Dec 2, 2014 at 10:42 PM, Ed Avis <eda@waniasset.com> wrote:
It's fairly essential in for example a signal handler, because otherwise $! Leon |
From @epaYes, I see the issue with signal handlers setting $!. Innocent code might hit a race with $ok = close $fh; and then the wrong error would be reported. One way out might be to make ______________________________________________________________________ |
From [email protected]Le 02/12/2014 22:42, Ed Avis a écrit :
Localizing
see also File::Copy for direct manipulations of |
From @epaYes, the File::Copy error reporting interface seems like a bit of a misdesign with the benefit of hindsight. ______________________________________________________________________ |
From @iabynOn Tue, Dec 02, 2014 at 06:19:28AM -0800, Ed Avis wrote:
No, it doesn't save the *value*, it saves the *container*. $x = 1; The action of local has to be to create a new, undef SV and insert it -- |
From @epaDave Mitchell wrote:
This makes sense but it implies that it would be impossible to localize a tied scalar? our $x; It looks like there may be some conceptual muddling. Normally you localize the symbol table Conceivably, local() could be split into localalias(), which always makes a new symbol table -- ______________________________________________________________________ |
From @AbigailOn Tue, Dec 02, 2014 at 05:07:52PM +0000, Ed Avis wrote:
localizing punctuation variables accounts for about 98% of my uses The 2% is optimistic, it's likely to be lower than that. Abigail |
From @LeontOn Wed, Dec 3, 2014 at 12:39 PM, Ed Avis <eda@waniasset.com> wrote:
Magic explicitly supports copying (or not) the magic to the new temporary
In case of ties, they will still share the tied object though, which makes Leon |
From [email protected]2014-12-03 14:39 GMT+03:00 Ed Avis <eda@waniasset.com>:
Keep in mind that any object is a scalar reference (RV) to a blessed SV.
-- |
From @janduboisOn Wed, Dec 3, 2014 at 9:09 AM, Leon Timmermans <fawaka@gmail.com> wrote:
There is some code in Perl that is supposed to prevent the https://rt.perl.org//Public/Bug/Display.html?id=60360 There is a comment in the original bug report why the patch only fixes https://rt.perl.org/Public/Bug/Display.html?id=60360#txn-493526 Cheers, |
From @epaThanks all for your explanations. So, although local works by making a new -- |
From @LeontOn Wed, Dec 3, 2014 at 10:34 PM, Ed Avis <eda@waniasset.com> wrote:
Actually, this problem may be fixable by adding a LOCALIZE method to the Leon |
From @cpansproutOn Wed Dec 03 13:45:35 2014, LeonT wrote:
I think that�s a good idea, but it should be called LOCAL after the keyword that invokes it. -- Father Chrysostomos |
From @rjbs* Father Chrysostomos via RT <perlbug-followup@perl.org> [2014-12-03T21:07:59]
That sounds useful, and I agree on the name. -- |
Migrated from rt.perl.org#123346 (status was 'open')
Searchable as RT123346$
The text was updated successfully, but these errors were encountered: