Author: larry Date: Sat Mar 15 18:09:39 2008 New Revision: 14520 Modified: doc/trunk/design/syn/S02.pod
Log: Suboptimalities noted by John M. Dlugosz++ Modified: doc/trunk/design/syn/S02.pod ============================================================================== --- doc/trunk/design/syn/S02.pod (original) +++ doc/trunk/design/syn/S02.pod Sat Mar 15 18:09:39 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 15 Feb 2008 + Last Modified: 15 Mar 2008 Number: 2 - Version: 129 + Version: 130 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1367,9 +1367,10 @@ If you need to force inner context to scalar, we now have convenient single-character context specifiers such as + for numbers and ~ for strings: + $x = g(); # scalar context and g() @x[f()] = g(); # list context for f() and g() @x[f()] = +g(); # list context for f(), scalar context for g() - @x[+f()] = g(); # scalar context for f() and g() + @x[+f()] = g(); # scalar context for f(), list context for g() # -- see S03 for "SIMPLE" lvalues @x[f()] = @y[g()]; # list context for f() and g() @@ -1377,6 +1378,18 @@ @x[+f()] = @y[g()]; # scalar context for f(), list context for g() @x[f()] = @y[+g()]; # list context for f(), scalar context for g() +Sigils used as list prefix operators may also be used to force context: + + @x = $ g(); # scalar context for g() + $x = @ g(); # list context for g() + $x = % g(); # list context for g() (and coercion to hash) + +These may also be used in functional form: + + @x = $(g()); # scalar context for g() + $x = @(g()); # list context for g() + $x = %(g()); # list context for g() (and coercion to hash) + =item * There is a need to distinguish list assignment from list binding. @@ -1432,18 +1445,21 @@ A signature object (C<Signature>) may be created with colon-prefixed parens: - my ::MySig ::= :(Int, Num, Complex, Status :mice) + my ::MySig ::= :(Int, Num, Complex, Status) Expressions inside the signature are parsed as parameter declarations rather than ordinary expressions. See S06 for more details on the syntax for parameters. -Signature objects bound to C<::t> variables may be used within another -signature to apply additional type constraints. When applied to a -C<Capture> argument of form C<\$x>, the signature allows you to specify -the types of parameters that would otherwise be untyped: +Signature objects bound to type variables (as in the example above) may +be used within other signatures to apply additional type constraints. +When applied to a C<Capture> argument, the signature allows you to +take the types of the capture's arguments from C<MySig>, but declare +the (untyped) variable names yourself via an addition signature +in parentheses: - :(Num Dog|Cat $numdog, MySig \$a ($i,$j,$k,$mousestatus)) + sub foo (Num Dog|Cat $numdog, MySig $a ($i,$j,$k,$mousestatus)) {...} + foo($mynumdog, \(1, 2.7182818, 1.0i, statmouse()); =item *