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

Re: (func()){key}?

Thread Previous | Thread Next
From:
hv
Date:
July 30, 2003 19:33
Subject:
Re: (func()){key}?
Message ID:
200307310237.h6V2bhI29330@zen.crypt.org
Michael G Schwern <schwern@pobox.com> wrote:
:I'm sure this has come up before, but I'm curious.  Why doesn't this DWIM:
:
:    sub foo {
:        return( this => 42, that => 23 );
:    }
:    
:    $this = (foo()){42};
:
:Similar to:
:
:    sub foo {
:        return(42, 23);
:    }
:
:    $this = (foo())[1];

Well, that'd be because a) we don't have a WANTHASH context and b) you
can't do C<< $a = ( this => 42, that => 23 ){42}; >>.

Given that you can do this:
  sub foo { return { this => 42, that => 23 } };
  $this = foo()->{42};
.. and more efficiently at that, I've never felt the lack to be a problem.

Hugo

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