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
Folded constants are not deparsed correctly #14304
Comments
From @cpansproutBecause constant folding is just an optimisation, we hide the fact that it has happened when you write things like \(3+4). That will give a reference to a new scalar each time, even though the + has been executed at compile time. (The flags on the constant are such that \ will copy it.) B::Deparse outputs \(3+4) as \7, which is a truly read-only value. That means the code behaves differently after deparsing (and core tests fail). So, the question is: How should something like this be deparsed? I could do 0+7 for numbers and ""."foo" for strings, but what about other values? Something like do { my $dummy = ... }? Is this something we need to fix, or is this drawback that should just be documented as a known limitation? -- Father Chrysostomos |
From @bulk88Father Chrysostomos wrote:
What is the optree difference between folded \(3+4) and \7? |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Fri Dec 05 08:49:24 2014, bulk88 wrote:
The SV associated with 3+4 has the SVs_PADTMP flag on. -- Father Chrysostomos |
From @ap* Father Chrysostomos <perlbug-followup@perl.org> [2014-12-05 02:40]:
$ perl -e '++$$_ for \(3+4)' What am I missing? |
From @maukeAm 06.12.2014 um 18:20 schrieb Aristotle Pagaltzis:
$ perl -wE 'my @xs; for (1 .. 3) { push @xs, \7; say $xs[-1]; }' $ perl -wE 'my @xs; for (1 .. 3) { push @xs, \(3+4); say $xs[-1]; }' Apparently it's making a copy but the copy is still read-only (as I -- |
From @cpansproutOn Sat Dec 06 09:21:18 2014, aristotle wrote:
s/perl/perl5.20/ There was a big discussion leading up to the change. Basically the conclusion was that the documentation that says constant folding makes no observable changes should be considered correct, and the implementation changed to match it. Another consideration was that this opened up new venues for even more optimisations than it the past, without the risk of breaking code that expect to modify scalars returned by operators. Take join, for instance, which recently became subject to constant folding. -- Father Chrysostomos |
Migrated from rt.perl.org#123368 (status was 'open')
Searchable as RT123368$
The text was updated successfully, but these errors were encountered: