Author: audreyt
Date: Fri Aug 11 20:28:03 2006
New Revision: 10855
Modified:
doc/trunk/design/syn/S06.pod
Log:
* S06: dconway++ suggested that we still provide convenience methods
on Signature level, to reduce line noise in common "want" operations.
* Also remove a stray paragraph miscommitted with the previous commit.
Modified: doc/trunk/design/syn/S06.pod
==============================================================================
--- doc/trunk/design/syn/S06.pod (original)
+++ doc/trunk/design/syn/S06.pod Fri Aug 11 20:28:03 2006
@@ -13,9 +13,9 @@
Maintainer: Larry Wall <[EMAIL PROTECTED]>
Date: 21 Mar 2003
- Last Modified: 11 Aug 2006
+ Last Modified: 12 Aug 2006
Number: 6
- Version: 47
+ Version: 48
This document summarizes Apocalypse 6, which covers subroutines and the
@@ -1766,10 +1766,6 @@
Specifies that the parameter cannot be modified (e.g. assigned to,
incremented). It is the default for parameters.
-$x = 5;
-
-sub f ($x) {}
-
=item C<is rw>
Specifies that the parameter can be modified (assigned to, incremented,
@@ -1902,16 +1898,24 @@
...
}
-You can also use the postfix signature syntax to test for compatibility:
+Or use its shorthand methods to reduce line noise:
+
+ if want.item {...} # called in non-lvalue scalar context
+ elsif want.list {...} # called in list context
+ elsif want.void {...} # called in void context
+ elsif want.rw {...} # expected to return an lvalue
+
+The C<.arity> and C<.count> methods also work here:
- if want:($) {...} # called in scalar context
- elsif want:(*@) {...} # called in list context
- elsif want:($ is rw) {...} # expected to return an lvalue
- elsif want:($,$) {...} # expected to return two values
+ if want.arity > 2 {...} # must return more than two values
+ if want.count > 2 {...} # can return more than two values
-The C<.arity> method also works here:
+Their difference is that C<.arity> considers only mandatory parts,
+while C<.count> considers also optional ones, including C<*$>:
- if want.arity > 2 {...} # expected to return more than two values
+ ($x, $y) = f(); # Within &f, want === :(*$?, *$?, *@)
+ # want.arity === 0
+ # want.count === 2
=head2 The C<leave> function