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

Re: return() in pointy blocks

Thread Previous | Thread Next
July 4, 2005 10:01
Re: return() in pointy blocks
Message ID:
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} };

TSa (Thomas Sandlaß)

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