develooper Front page | perl.perl5.porters | Postings from March 2003

Re: [perl #21624] \(1 .. 3) returns a reference to an array.

Thread Previous
From:
Enache Adrian
Date:
March 29, 2003 10:13
Subject:
Re: [perl #21624] \(1 .. 3) returns a reference to an array.
Message ID:
20030329180925.GA8323@ratsnest.hole
On Wed, Mar 19, 2003 at 10:09:52PM -0000, abigail@abigail.nl (via RT) wrote:
>     print \(1 .. 3);
> 
> gives
> 
>     ARRAY(0x8175fe8)

I think (that's my humble opinion) that the fact that
	print \(1..3)
and
	my $i=3; print \(1..$i)
produce different things is a bug.

However, the code that takes care that Perl work like that seems
to be very deliberate - and very old.

pp_hot.c:695
	    if (PL_op->op_flags & OPf_REF) {
		SETs((SV*)av);
		RETURN;
	    }
	    else if (LVRET) {

I failed to see other case that this test covers - removing it
(but leaving the if LVRET .. branch there, of course) gives
no test failures ( inutile to say that it makes also \(1..2)
return a list of references ..)

More expert advise appreciated.

Regards
Adi

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About