develooper Front page | perl.perl5.porters | Postings from February 2023

Re: PERL_RC_STACK branch: first cut

Thread Previous | Thread Next
"Ruud H.G. van Tol" via perl5-porters
February 27, 2023 11:45
Re: PERL_RC_STACK branch: first cut
Message ID:

On 2023-02-27 12:20, demerphq wrote:
> For those who want a simple example of the bug that this patch fixes 
> here is a simple example:
> With blead perl this program should print out "foo", but does not.
> $ perl -le'my @a=("foo"); sub t {@{$_[0]}=(); print $_[1];} 
> t(\@a,$a[0]);'
> With Dave's branch it behaves as expected:
> $ ./perl -le'my @a=("foo"); sub t {@{$_[0]}=(); print $_[1];} 
> t(\@a,$a[0]);'
> foo

To me that is a confusing example.

I don't see (yet) how/why it should print out "foo".
Details below.

-- Ruud

-- -- -- -- -- -- -- --

Why would you want/expect it to print "foo",
when you are using aliased parameters,
and are deliberately emptying the array?

If you really want it to print "foo", just code differently, to have 
copies where needed?

perl -Mv5.28 -wE'my @a=("foo"); sub t {@{$_[0]}=(); say $_[1];} t(\@a, 

perl -Mv5.28 -wE'my @a=("foo"); sub t ($p1, $p2) {@$p1=(); say $p2;} 
t(\@a, $a[0]);'

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About