develooper Front page | perl.perl6.language | Postings from July 2005

Re: return() in pointy blocks

Thread Previous | Thread Next
From:
=?ISO-8859-1?Q?=22TSa_=28Thomas_Sandla=DF=29=22?=
Date:
July 4, 2005 10:01
Subject:
Re: return() in pointy blocks
Message ID:
42C96B4C.6010105@orthogon.com
Larry Wall wrote:
> On Wed, Jun 08, 2005 at 12:37:22PM +0200, "TSa (Thomas Sandlaß)" wrote:
> : BTW, is -> on the 'symbolic unary' precedence level
> : as its read-only companion \ ?.
> 
> No, -> introduces a term that happens to consist of a formal signature
> and a block.  There are no ordinary expressions involved until you
> get inside the block.  (Or set a default on one of the parameters, to
> the extent that those are ordinary expressions.)

So without a block there is a syntax error?

   $x = -> $y;

Or could this be understood as a short form of

   $x = -> { $y } # $y from outer scope

I still think the pointy looks really cute as a prefix operator
for constructing rw refs. Especially if we use () to evaluate
the blockref returned. For plain variable assignment this is
not overly usefull because it amounts to the same as

   $x := $y;

but in lists it is quite nice

   %h = { foo, 'bar', blah, -> $y };

or not?

   %h = { foo => 'bar', blah => -> $y };

hmm, can the following be interpreted as spoiling pair notation?

   %h = { :foo<bar>, :blah< -> $y> }; # would blah<-> $y> parse at all?

I think not because this works

   %h = { :foo<bar>, :blah{-> $y} };

Regards,
-- 
TSa (Thomas Sandlaß)



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