Re: [svn:perl6-synopsis] r14520 - doc/trunk/design/syn

2008-03-16 Thread Daniel Hulme
On Sat, Mar 15, 2008 at 06:09:40PM -0700, [EMAIL PROTECTED] wrote:
 Author: larry
 Date: Sat Mar 15 18:09:39 2008
 New Revision: 14520

 @@ -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()
s/and/for/ in this last line, I think.

-- 
I think you look like the Mona Lisa.  You always seem to be at a window
admiring the landscape that is actually behind you.Herve Le Tellier
http://surreal.istic.org/   Habit is a good slave but a poor master.


signature.asc
Description: Digital signature


Re: [svn:perl6-synopsis] r14520 - doc/trunk/design/syn

2008-03-16 Thread Nicholas Clark
On Sat, Mar 15, 2008 at 06:09:40PM -0700, [EMAIL PROTECTED] wrote:

 @@ -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)


Given the last paragraph, wouldn't the earlier example be more correctly
described as

@x[f()]   = +g();   # list context for f(), number context for g()

and more general example instead be

@x[f()]   = $ g();  # list context for f(), scalar context for g()

given that the obvious hash analogy of

@x[+f()]  =  g();   # scalar context for f(), list context for g()

is

%x{+f()}  =  g();   # number context for f(), list context for g()

and (if I understand context and its coercion correctly) actually that's
probably not what the novice wanted. In that what they probably wanted was

%x{~f()}  =  g();   # string context for f(), list context for g()


So instead of emphasising + and ~, it feels to me that that is less to
remember (and less to teach) if the examples were prominent in their use of
(generic) scalar context:

%x{$ f()}  =  g();  # scalar context for f(), list context for g()


Nicholas Clark


[svn:perl6-synopsis] r14520 - doc/trunk/design/syn

2008-03-15 Thread larry
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.podSat 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 (CSignature) 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
-CCapture 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 CCapture argument, the signature allows you to
+take the types of the capture's arguments from CMySig, 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 *