ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: return() in pointy blocks
by Larry Wall other posts by this author
Jul 4 2005 11:32AM messages near this date
Re: return() in pointy blocks | Re: return() in pointy blocks
On Mon, Jul 04, 2005 at 07:01:00PM +0200, "TSa (Thomas SandlaÃ?)" wrote:
: 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;

Yes.

: Or could this be understood as a short form of
: 
:   $x = ->  { $y } # $y from outer scope

Could, but I'm prejudiced against implicit lexical scopes.  && and ||
and ??:: are okay as standard forms of indirect quotation, but natural
languages are notorious for getting into ambiguous situations with
that kind of laziness.  So that's one of the "features" I'm slow to
copy from human languages.  Curlies are already short, and in Perl
6 have the (almost) universal meaning of direct quotation of code.

: 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 };

I don't think the semantics pass the Pooh test.   It's also confusing
syntactically.  What state is the parser supposed to be in when it
gets to the end of this:

    foo =>  'bar', blah => -> $x, $y, $z

If the precedence of ->  is list operator (and it needs to be to gobble
up pointy sub arguments), then you have to write one of

    foo =>  'bar', blah => -> ($x), $y, $z
    foo =>  'bar', blah => (-> $x), $y, $z

to limit it to the first argument, and you might as well have put some
curlies there.  We're not going to do arbitrary lookahead to find a {
to decide the precedence of ->  on the fly.  That would be insane.

: hmm, can the following be interpreted as spoiling pair notation?
: 
:   %h = { :foo<bar> , :blah< -> $y> }; # would blah<-> $y> parse at all?

That won't parse.

: I think not because this works
: 
:   %h = { :foo<bar> , :blah{-> $y} };

That won't parse either.

Larry
Thread:
Ingo Blechschmidt
Matt Fowles
Luke Palmer
=22TSa_=28Thomas_Sandla=DF=29=22
=22TSa_=28Thomas_Sandla=DF=29=22
Larry Wall
"TSa (Thomas Sandlaß)"
Larry Wall
Matt Fowles

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved