Late last night, PerlJam posted in #parrot a small Perl 6
program which gave the wrong answer in Rakudo: my $foo = 'fred';
my $bar = 'fred'; The correct output is obviously: PerlJam and
Infinoid both correctly diagnosed the problem as a COW problem.
What's that, and why does it matter? The Rakudo compiler turns
this code into PIR code. PIR is the native high level language
of Parrot. Inside Parrot, the PIR compiler (IMCC) turns PIR into
Parrot bytecode. As part of that process, IMCC identifies
constant string literals and treats them specially. Like the
Perl 6 code, the PIR code produced by Rakudo contains the string
literal fred twice. The PBC produced by IMCC doesn't; it refers
to a single internal data structure twice. This is usually the
right approach. In this case, where the literal string appears
twice and is only four characters long, there's little benefit,
but in a complex program, you can save a lot of memory and time
with judicious caching. Now of course sometimes people want to
mutate these strin