:($obj) syntax (was Re: [svn:perl6-synopsis] r14479 - doc/trunk/design/syn)

2008-01-05 Thread Trey Harris

In a message dated Thu, 3 Jan 2008, [EMAIL PROTECTED] writes:

+But these bindings Ido autovivify:

my %hash;
my $val := %hashfoobar;

my @array;
-my $obj = [EMAIL PROTECTED]; # $obj is a Capture object - see S02
+my $cap = [EMAIL PROTECTED]; # $obj is a Capture object - see S02
+my :($obj) := $cap;   # @array[0][0] created here


I'm wondering about that last line there.  Going by S02, I see:

   * There is now a generalized adverbial form of Pair notation. The
   following table shows the correspondence to the fatarrow notation:

   Fat arrow   Adverbial pair  Paren form
   =   ==  ==
   [...]
   '' = $x:($x)

which looks like C:($obj).  So I was reading the line

   my :($obj) := $cap;   # @array[0][0] created here

as saying, create an anonymous Pair, with $obj bound to its value, and 
bind the Pair to $cap (causing $obj to be bound to the value portion of 
$cap).


But I was told on #perl6 that :($obj) refers to a Signature.  If so, I 
think the relevant passage in S02 for deciphering the syntax is:


  A signature object (Signature) may be created with colon-prefixed
  parens:
  my ::MySig ::= :(Int, Num, Complex, Status :mice)

So in that case, $obj refers to... what?  The variable's just been 
created, so its value is undef, so it's equivalent to a one-arg Signature 
with an undef item, and it's being used as an lvalue, so I don't 
understand.


Also, someone on #perl6 said that the colon could be omitted with no 
change in effect.  I don't get that, either.


Given its use in the autovivification discussion in S09, the Pair idea 
made sense to me, but the Signature explanation is very confusing.  I'd 
appreciate some help understanding it.


Trey


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

2008-01-05 Thread larry
Author: larry
Date: Sat Jan  5 17:24:55 2008
New Revision: 14481

Modified:
   doc/trunk/design/syn/S02.pod

Log:
Removal of false indication of correspondence between fatarrow and adverbial 
special forms,
and much clarification of special adverbial forms, requested by Trey Harris++


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podSat Jan  5 17:24:55 2008
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 10 Aug 2004
-  Last Modified: 1 Jan 2008
+  Last Modified: 5 Jan 2008
   Number: 2
-  Version: 123
+  Version: 124
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -2140,46 +2140,87 @@
 a = $$a:$$a
 a = @$$a   :@$$a (etc.)
 a = %fooa%fooa:p
-'' = $x:($x)
-'' = x   :x
-'' = ($x,$y)   :($x,$y)
-'' = [$x,$y]   :[$x,$y]
-'' = {$x = $y}:{$x = $y}
 
 The fatarrow construct may be used only where a term is expected
 because it's considered an expression in its own right, since the
-fatarrow is parsed as a normal infix operator (even when autoquoting an
-identifier on its left).  The adverbial forms are considered special
-tokens and are recognized in various positions in addition to term
-position.  In particular, when used where an infix would be expected
-they modify the previous operator, ignoring the intervening term or
-parenthesized argument.  The form is also used to rename parameter
-declarations and to modify the meaning of various quoting forms.
-When appended to an identifier, the adverbial syntax is used to
-generate variants of that identifier; this syntax is used for
-naming operators such as C infix:+  and multiply dispatched
-grammatical rules such as statement_control:if.  When so used the
-adverb is considered part of the name, so C infix:+  and C
-infix:-  are two different operators.  Likewise C prefix:+
- is different from C infix:+ .
-
-Either fatarrow or adverbial pair notation may be used to pass named arguments 
as
-terms to a function or method.  After a call with parenthesized arguments,
-only adverbial syntax may be used to pass additional arguments.  This is 
typically
-used to pass an extra block:
+fatarrow itself is parsed as a normal infix operator (even when
+autoquoting an identifier on its left).  Because the left side is a
+general expression, the fatarrow form may be used to create a Pair
+with Iany value as the key.  On the other hand, when used as above
+to generate CPair objects, the adverbial forms are restricted to
+the use of identifiers as keys.  You must use the fatarrow form to
+generate a CPair where the key is not an identifier.
+
+Despite that restriction, it's possible for other things to
+come between a colon and its brackets; however, all of the possible
+non-identifier adverbial keys are reserved for special syntactical
+forms.  Perl 6 currently recognizes decimal numbers and the null key.
+In the following table the first and second columns do Inot mean
+the same thing:
+
+Simple pair DIFFERS fromwhich means
+=== ===
+2 = 101010   :2101010  radix literal 0b101010
+8 = 123  :8123 radix literal 0o123
+16 = 123 :16deadbeef   radix literal 0xdeadbeef
+16 = 123 :16($somevalue) radix conversion function
+'' = $x:($x)   arglist or signature literal
+'' = ($x,$y)   :($x,$y)arglist or signature literal
+'' = x   :xidentifier extension
+'' = «x»   :«x»identifier extension
+'' = [$x,$y]   :[$x,$y]identifier extension
+'' = { .say }  :{ .say }   adverbial block
+
+All of the adverbial forms (including the normal ones with
+identifier keys) are considered special tokens and are recognized
+in various positions in addition to term position.  In particular,
+when used where an infix would be expected they modify the previous
+operator, ignoring the intervening term or parenthesized argument:
+
+1 .. 100 :by(3) # count to 100 by threes
+
+Within declarations the form is used to rename parameter declarations:
+
+sub foo ( :externalname($myname) ) {...}
+
+Adverbs modify the meaning of various quoting forms:
+
+q:x 'cat /etc/passwd'
+
+When appended to an identifier (that is, in postfix position),
+the adverbial syntax is used to generate unique variants of that
+identifier; this syntax is used for naming operators such as C
+infix:+  and multiply-dispatched grammatical rules such as
+Cstatement_control:if.  When so used, the adverb is considered an
+integral part of the name, so C infix:+  and C infix:- 
+are two different operators.  Likewise C prefix:+  is different

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

2008-01-05 Thread larry
Author: larry
Date: Sat Jan  5 17:42:13 2008
New Revision: 14482

Modified:
   doc/trunk/design/syn/S11.pod

Log:
Module names are in Unicode even on non-Unicode filesystems.  Juerd++


Modified: doc/trunk/design/syn/S11.pod
==
--- doc/trunk/design/syn/S11.pod(original)
+++ doc/trunk/design/syn/S11.podSat Jan  5 17:42:13 2008
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 27 Oct 2004
-  Last Modified: 6 Aug 2007
+  Last Modified: 5 Jan 2008
   Number: 11
-  Version: 20
+  Version: 21
 
 =head1 Overview
 
@@ -229,6 +229,7 @@
 
 The internal API for package names is always case-sensitive, even if
 the library system is hosted on a system that is not case-sensitive.
+Likewise internal names are Unicode-aware, even if the filesystem isn't.
 This implies either some sort of name mangling capability or storage
 of intermediate products into a database of some sort.  In any event,
 the actual storage location must be encapsulated in the library system