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

Re: [perl #22027] undef appears as scalar return value for a list

Thread Previous | Thread Next
From:
Rick Delaney
Date:
April 24, 2003 18:42
Subject:
Re: [perl #22027] undef appears as scalar return value for a list
Message ID:
20030424214150.C25139@cs839290-a.mtth.phub.net.cable.rogers.com
On Thu, Apr 24, 2003 at 01:40:54PM -0400, Mark Jason Dominus wrote:
> mike@stok.co.uk:
> > > > my $rv = ('a', 'b', 'c');
> > > > show $rv;
> > > > my $rv2 = ('a', 'b', 'c', ());
> > > > show $rv2;
> > > > 
> > > > I would have expected $rv2 to be 'c' as I thought ('a', 'b',
> > > > 'c', ()) should be flattened to ('a', 'b', 'c').  The warnings
> > > > indicate that in the first case two values are useless, and in
> > > > the second three values are useless.
> 
> I'm with Mike on this.  
> 
>         my $rv2 = ('a', 'b', 'c', ());
>         my $rv2 = ('a', 'b', 'c', );
> 
> These two should not be different.

Should these be different?

    my $rv2 = ('a', 'b', 'c', f());
    my $rv2 = ('a', 'b', 'c', );
    sub f { () }

If so, why should the inline expression behave differently from the
function call?

-- 
Rick Delaney
rick.delaney@rogers.com

Thread Previous | Thread Next


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