Closed p5pRT closed 11 years ago
Consider the following program:
use strict; my $i = 0; sub A::TIESCALAR {bless [] => 'A'} sub A::FETCH {print ++ $i\, "\n"} my @a = (""\, ""\, "");
tie $" => 'A'; "@a"; __END__
For perl 5.001 up to perl 5.6.0 (and also perl 5.7.0)\, this prints '1'. That is\, if stringification of an array needs the value of $"\, its value is fetched only once for this stringification\, even if $" is required more often.
In 5.6.1 and from 5.7.1 onwards\, this prints '1'\, '2'\, '3'. It looks like the value of $" is fetched each time it appears in the resulting string - but then it's called once too often. If @a is an empty array\, "@a" results in the value of $" being fetched!
While the multiple fetching of $" is arguably a change for the better (was this done intentionally\, or was it a side effect?)\, it does contradict the documentation. Perldata says:
The following are equivalent:
$temp = join($"\, @ARGV); system "echo $temp";
system "echo @ARGV";
This is no longer the case.
On 12 Apr 2002 10:45:18 -0000\, abigail@foad.org said:
Cute testscript.
The responsible patch is 8248.
-- andreas
On Fri\, Apr 12\, 2002 at 02:39:23PM +0200\, Andreas J. Koenig wrote:
On 12 Apr 2002 10:45:18 -0000\, abigail@foad.org said:
Cute testscript.
The responsible patch is 8248.
.... which maans that 8264 didn't really fully retract 8248?
-- andreas
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
On Fri\, 12 Apr 2002 16:05:55 +0300\, Jarkko Hietaniemi \jhi@​iki\.fi said:
> On Fri\, Apr 12\, 2002 at 02:39:23PM +0200\, Andreas J. Koenig wrote:
On 12 Apr 2002 10:45:18 -0000\, abigail@foad.org said:
Cute testscript.
The responsible patch is 8248.
> ... which maans that 8264 didn't really fully retract 8248?
Correct. After 8248 I see always the same result.
-- andreas
On Fri\, Apr 12\, 2002 at 03:29:00PM +0200\, Andreas J. Koenig wrote:
On Fri\, 12 Apr 2002 16:05:55 +0300\, Jarkko Hietaniemi \jhi@​iki\.fi said:
On Fri\, Apr 12\, 2002 at 02:39:23PM +0200\, Andreas J. Koenig wrote:
On 12 Apr 2002 10:45:18 -0000\, abigail@foad.org said:
Cute testscript.
The responsible patch is 8248.
... which maans that 8264 didn't really fully retract 8248?
Correct. After 8248 I see always the same result.
Well\, in any case\, the change for $" in particular was certainly unintentional.
-- andreas
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
On Fri\, Apr 12\, 2002 at 02:39:23PM +0200\, Andreas J. Koenig wrote:
On 12 Apr 2002 10:45:18 -0000\, abigail@foad.org said:
Cute testscript.
If one has a history of writing Japhs (it's been a while since I wrote the last one)\, one has a bunch of cute test cases.....
It seems that 5.8 is going to break less Japhs than 5.6 did.
The responsible patch is 8248.
But that patch was retracted by patch 8264 according the Changes file.
Abigail
On Fri\, Apr 12\, 2002 at 03:36:13PM +0200\, abigail@foad.org wrote:
If one has a history of writing Japhs (it's been a while since I wrote the last one)\, one has a bunch of cute test cases.....
It seems that 5.8 is going to break less Japhs than 5.6 did.
So we need t/japh/*.t then? :-)
Nicholas Clark
On Fri\, Apr 12\, 2002 at 03:36:13PM +0200\, abigail@foad.org wrote:
On Fri\, Apr 12\, 2002 at 02:39:23PM +0200\, Andreas J. Koenig wrote:
On 12 Apr 2002 10:45:18 -0000\, abigail@foad.org said:
Cute testscript.
If one has a history of writing Japhs (it's been a while since I wrote the last one)\, one has a bunch of cute test cases.....
It seems that 5.8 is going to break less Japhs than 5.6 did.
The responsible patch is 8248.
But that patch was retracted by patch 8264 according the Changes file.
Apparently 8264 is lying. My first candidate for the behavioral change goes for this
for (; items > 0; items--\,mark++) { - sv_catpvn(sv\,delim\,len); + sv_catsv(sv\,del); sv_catsv(sv\,*mark); } }
in the beginning of the 8248: instead of the PV delim being fetched once and used for all the catenations\, the original delimiter sv is "invoked" anew at every iteration.
Abigail
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
On Fri\, Apr 12\, 2002 at 02:41:22PM +0100\, Nicholas Clark wrote:
On Fri\, Apr 12\, 2002 at 03:36:13PM +0200\, abigail@foad.org wrote:
If one has a history of writing Japhs (it's been a while since I wrote the last one)\, one has a bunch of cute test cases.....
It seems that 5.8 is going to break less Japhs than 5.6 did.
So we need t/japh/*.t then? :-)
I think Abigail's arsenal on that would bloat the distribution too much :-)
Nicholas Clark
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
On Fri\, Apr 12\, 2002 at 02:41:22PM +0100\, Nicholas Clark wrote:
On Fri\, Apr 12\, 2002 at 03:36:13PM +0200\, abigail@foad.org wrote:
If one has a history of writing Japhs (it's been a while since I wrote the last one)\, one has a bunch of cute test cases.....
It seems that 5.8 is going to break less Japhs than 5.6 did.
So we need t/japh/*.t then? :-)
I jokely said something like that on #perl a few hours ago\, and sky said that where I to make such a test suite\, he would put it in.
I'll work on it ASAP. (After I finish complaining to HP about their Perl course material)
Abigail
En réponse à abigail@foad.org:
On Fri\, Apr 12\, 2002 at 02:41:22PM +0100\, Nicholas Clark wrote:
So we need t/japh/*.t then? :-)
I'd prefer a single t/lib/japh.t (or whatever) that does something like :
require "./test.pl"; # take advantage of runperl() $/ = "#\n"; while (\) { # check the output\, print (not )?ok... } __DATA__ print "Just another Perl hacker\,\n"; # ....other japhs listed there.
(of course this is in the case where some japhs needs to be run in separate processes / use command-line options. Otherwise an eval() is sufficient.) Beware the execution time also : no need to bloat the test suite -- you know that already\, you run smokes. (or should this be skipped by default ? are obfuscated regression tests that useful ?)
I jokely said something like that on #perl a few hours ago\, and sky said that where I to make such a test suite\, he would put it in.
On Fri\, Apr 12\, 2002 at 04:32:02PM +0200\, rgarciasuarez@free.fr wrote:
(or should this be skipped by default ? are obfuscated regression tests that useful ?)
I think the advantage of "obfuscated" tests is that they combine features in a surprising way.
The test suite probably checks whether $" works as intended\, it also tests whether tieing works correctly. But it's the combination that failed here: $" being tied to a function with side effects.
Abigail
On Fri Apr 12 00:54:59 2002\, RT_System wrote:
On Fri\, Apr 12\, 2002 at 04:32:02PM +0200\, rgarciasuarez@free.fr wrote:
(or should this be skipped by default ? are obfuscated regression tests that useful ?)
I think the advantage of "obfuscated" tests is that they combine features in a surprising way.
The test suite probably checks whether $" works as intended\, it also tests whether tieing works correctly. But it's the combination that failed here: $" being tied to a function with side effects.
Abigail
Actually\, it's worse than that:
my $i = 0; sub A::TIESCALAR {bless [] => 'A'} sub A::FETCH {print ++ $i\, "\n"}
tie my $a => 'A'; join $a\, 1..10;
Will call $a's magic for every element. So it's not tie+$"\, but tie+join that are broken. Weird that this ticket ended up creating a whole new section of the test suite\, but didn't get the issue fixed\, eh? In any case\, the attached patch seems to do the trick. It's just one line\, which probably means that it's broken somehow.
--hugmeir
On Thu May 24 22:51:45 2012\, Hugmeir wrote:
In any case\, the attached patch seems to do the trick. It's just one line\, which probably means that it's broken somehow.
Not broken at all. :-)
Thank you. Applied as 760209f.
--
Father Chrysostomos
@cpansprout - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#8931 (status was 'resolved')
Searchable as RT8931$