[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl6-language
Subject:    r27264 - docs/Perl6/Spec
From:       pugs-commits () feather ! perl6 ! nl
Date:       2009-06-26 14:37:04
Message-ID: 20090626143704.22803.qmail () feather ! perl6 ! nl
[Download RAW message or body]

Author: lwall
Date: 2009-06-26 16:37:04 +0200 (Fri, 26 Jun 2009)
New Revision: 27264

Modified:
   docs/Perl6/Spec/S06-routines.pod
Log:
[S06] only prefix:<foo> makes named unary, not sub foo ($)


Modified: docs/Perl6/Spec/S06-routines.pod
===================================================================
--- docs/Perl6/Spec/S06-routines.pod	2009-06-26 12:05:11 UTC (rev 27263)
+++ docs/Perl6/Spec/S06-routines.pod	2009-06-26 14:37:04 UTC (rev 27264)
@@ -4,19 +4,20 @@
 
 Synopsis 6: Subroutines
 
-=head1 AUTHOR
+=head1 AUTHORS
 
-Damian Conway <damian@conway.org> and
+Damian Conway <damian@conway.org>
 Allison Randal <al@shadowed.net>
+Larry Wall <larry@wall.org>
 
 =head1 VERSION
 
-  Maintainer: Larry Wall <larry@wall.org>
-  Date: 21 Mar 2003
-  Last Modified: 23 May 2009
-  Version: 109
+  Created: 21 Mar 2003
 
+  Last Modified: 26 Jun 2009
+  Version: 110
 
+
 This document summarizes Apocalypse 6, which covers subroutines and the
 new type system.
 
@@ -1742,17 +1743,37 @@
     sub postfix:<!> ($x) is equiv<++> {...}
     sub postfix:<!> ($x) {...}      # since equiv<++> is the default
 
-Prefix operators that are identifiers are handled specially.  Both of
+Prefix operators that are identifiers are handled specially.  The
+form with one argument defaults to named unary precedence
+instead of autoincrement precedence:
 
-    sub foo ($) {...}
-    sub prefix:<foo> ($) {...}
+    sub prefix:<foo> ($x) {...}
+    foo 1, 2, 3;        # means foo(1), 2, 3
 
-default to named unary precedence despite declaring a prefix operator.
 Likewise postfix operators that look like method calls are forced to
 default to the precedence of method calls.  Any prefix operator that
 requires multiple arguments defaults to listop precedence, even if it
-is not an identifier.
+is not an identifier:
 
+    sub prefix:<☎> ($x,$y) {...}
+    ☎ 1;                # ERROR, too few arguments
+    ☎ 1, 2;             # okay
+    ☎ 1, 2, 3;          # ERROR, too many arguments
+
+You must use the C<< prefix:<foo> >> form in order to mutate
+the grammar to parse as a named unary operator.  Normal function
+definitions never change the grammar, and when called always parse
+as listops, even if defined with a single argument:
+
+    sub foo ($x) {...}  # a listop
+    foo(1), 2, 3;       # okay
+    (foo 1), 2, 3;      # okay
+    foo 1, 2, 3;        # ERROR, too many arguments
+
+Likewise 0-ary functions parse as listops.  Use C<< term:<foo> >>
+(or a constant or enum declaration) to declare a term that expects
+no arguments.
+
 =item C<is assoc>
 
 Specifies the associativity of an operator explicitly.  Valid values are:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic