Author: larry
Date: Fri May 12 14:55:00 2006
New Revision: 9216

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

Log:
Major whackage: Prefix * and ** are dead!  Long live [,] and eager!
By unpopular demand, reduce operators no longer triangulate in list context.
(Triangulate explicitly using [\*] instead.)


Modified: doc/trunk/design/syn/S02.pod
==============================================================================
--- doc/trunk/design/syn/S02.pod        (original)
+++ doc/trunk/design/syn/S02.pod        Fri May 12 14:55:00 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 10 Aug 2004
-  Last Modified: 8 May 2006
+  Last Modified: 12 May 2006
   Number: 2
-  Version: 39
+  Version: 40
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -476,6 +476,41 @@
 Note, though, that if you remap a section of C<buf32> memory to be
 C<buf8>, you'll have to multiply all your positions by 4.
 
+=item *
+
+Ordinarily a term beginning with C<*> indicates a global function
+or type name, but by itself, the C<*> term captures the notion of
+"Whatever", which is applied lazily by whatever operator it is an
+argument to.  Generally it can just be thought of as a "glob" that
+gives you everything it can in that argument position.  For instance:
+
+    if $x ~~ 1..* {...}                        # if 1 <= $x <= +Inf
+    my ($a,$b,$c) = "foo" xx *;                # an arbitrary long list of 
"foo"
+    if /foo/ ff * {...}                        # a latching flipflop
+    @slice = @x[*;0;*];                        # any Int
+    @slice = %x{*;'foo'};              # any keys in domain of 1st dimension
+    @array[*]                          # flattens, unlike @array[]
+    (*, *, $x) = (1, 2, 3);            # skip first two elements
+                                       # (same as lvalue "undef" in Perl 5)
+
+C<Whatever> is an undefined prototype object derived from C<Any>.  As a
+type it is abstract, and may not be instantiated as a defined object.
+If for a particular MMD dispatch, nothing in the MMD system claims it,
+it dispatches to as an C<Any> with an undefined value, and usually
+blows up constructively.  If you say
+
+    say 1 + *;
+
+you should probably not expect it to yield a reasonable answer, unless
+you think an exception is reasonable.  Since the C<Whatever> object
+is effectively immutable, the optimizer is free to recognize C<*>
+and optimize in the context of what operator it is being passed to.
+
+Other uses for C<*> will doubtless suggest themselves over time.  These
+can be given meaning via the MMD system, if not the compiler.  In general
+a C<Whatever> should be interpreted as maximizing the degrees of freedom
+in a dwimmey way, not as a nihilistic "don't care anymore--just shoot me".
+
 =back
 
 =head1 Names and Variables
@@ -982,9 +1017,9 @@
 =item *
 
 Truly global variables live in the C<*> package: C<$*UID>, C<%*ENV>.
-(The C<*> may generally be omitted if there is no inner declaration
-hiding the global name.)  C<$*foo> is short for C<$*::foo>, suggesting
-that the variable is "wild carded" into every package.
+(The C<*> may be omitted if you import the name from the C<GLOBAL>
+package.)  C<$*foo> is short for C<$*::foo>, suggesting that the
+variable is "wild carded" into every package.
 
 =item *
 
@@ -1483,7 +1518,7 @@
 not be followed by any dereferencers, since you can always put them
 inside the closure.  The expression inside is evaluated in scalar
 (string) context.  You can force list context on the expression using
-either the C<*> or C<list> operator if necessary.
+either the C<list> operator if necessary.
 
 The following means the same as the previous example.
 
@@ -1850,39 +1885,22 @@
 its arguments even if C<list> itself occurs in a scalar context.
 In list context, it flattens lazily.  In a scalar context, it returns
 the resulting list as a single C<List> object.  (So the C<list> operator
-really does exactly the same thing as putting a list in parentheses.
-But it's more readable in some situations.)
+really does exactly the same thing as putting a list in parentheses with
+at least one comma.  But it's more readable in some situations.)
 
 =item *
 
-The C<*> unary operator may be used to force list context on its
+The C<[,]> list operator may be used to force list context on its
 argument and I<also> defeat any scalar argument checking imposed by
 subroutine signature declarations.  This list flattens lazily.
-When applied to a scalar value containing an iterator, C<*> causes
-the iterator's return values be interpolated into the list lazily.
-Note that C<*> is destructive when applied to a scalar iterator,
-but non-destructive when applied to an array, even if that array
-represents an iterator.
-
-There is an argumentless form of C<*> which may be used within a
-multi-dimensional array or hash subscript to indicate all of the
-current set of subscripts available for this dimension.  It actually
-returns a type value of C<Any>, so it can be used in any selector
-where you would use C<Any>.
 
 =item *
 
-To force non-lazy list flattening, use the C<**> unary operator.
+To force non-lazy list flattening, use the C<eager> list operator.
 Don't use it on an infinite generator unless you have a machine with
 infinite memory, and are willing to wait a long time.  It may also
 be applied to a scalar iterator to force immediate iteration to completion.
 
-Argumentless C<**> in a multi-dimensional subscript indicates 0 or
-more dimensions of C<*> where the number of dimension isn't necessarily
-known: C<@foo[1;**;5]>.  It has a value of C<List of Any>, or something
-like that.  The argumentless C<*> and C<**> forms are probably only
-useful in "dimensional" list contexts.
-
 =item *
 
 Signatures on non-multi subs can be checked at compile time, whereas

Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod        (original)
+++ doc/trunk/design/syn/S03.pod        Fri May 12 14:55:00 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 8 Mar 2004
-  Last Modified: 11 May 2006
+  Last Modified: 12 May 2006
   Number: 3
-  Version: 29
+  Version: 30
 
 =head1 Changes to existing operators
 
@@ -32,13 +32,14 @@
 an alternate form that does.  (The converse does not hold--just because
 you can write C<x().foo> doesn't mean you can write C<x()foo>.)
 
-=item * Unary C<~> now imposes a string (C<Str>) context on its argument, and
-C<+> imposes a numeric (C<Num>) context (as opposed to being a no-op in Perl
-5).  Along the same lines, C<?> imposes a boolean (C<Bool>) context, and C<*>
-imposes an function-arguments (C<Capture>) context.   Unary sigils impose the
-container context implied by their sigil.  As with Perl 5, however,
-C<$$foo[bar]> parses as C<$($foo)[bar]>, so you need C<$($foo[bar])> to mean
-the other way.
+=item * Unary C<~> now imposes a string (C<Str>) context on its
+argument, and C<+> imposes a numeric (C<Num>) context (as opposed
+to being a no-op in Perl 5).  Along the same lines, C<?> imposes
+a boolean (C<Bool>) context, and the C<[,]> list operator imposes
+an function-arguments (C<Capture>) context on its argumetns.
+Unary sigils impose the container context implied by their sigil.
+As with Perl 5, however, C<$$foo[bar]> parses as C<$($foo)[bar]>,
+so you need C<$($foo[bar])> to mean the other way.
 
 =item * Bitwise operators get a data type prefix: C<+>, C<~>, or C<?>.
 For example, C<|> becomes either C<+|> or C<~|> or C<?|>, depending on
@@ -247,13 +248,13 @@
     1.5 ~~ 1^..^2  # true, equivalent to 1 < 1.5 < 2
     2.1 ~~ 1..2    # false, equivalent to 1 <= 2.1 <= 2
 
-If an argumentless C<*> (see the "Whatever" operator below) occurs on
+If a C<*> (see the "Whatever" type in S02) occurs on
 the right side of a range, it is taken to mean "positive infinity"
 in whatever space the range is operating.  A C<*> on the left means
 "negative infinity" for types that support negative values.  If the
 C<*> occurs on one side but not the other, the type is inferred from
 the other argument.  A star on both sides will match any value that
-supports the Ordered role.
+supports the C<Ordered> role.
 
     0..*       # 0 .. +Inf
     'a'..*     # 'a' .. 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
@@ -429,8 +430,16 @@
 return a boolean for either 1 or 0 arguments.  Negated operators
 return C<Bool::False>, and all the rest return C<Bool::True>.
 
-This metaoperator can also be used on the semicolon second-dimension
-separator:
+You can also make a reduce operator of the comma operator.  This has
+the effect of dereferencing its arguments into another argument list
+as if they'd been placed there directly.
+
+    @args = [EMAIL PROTECTED],1,2,3;
+    push [,] @args;    # same as push @foo,1,2,3
+
+See S06 for more.
+
+You may also reduce using the semicolon second-dimension separator:
 
     [[;] 1,2,3]   # equivalent to [1;2;3]
 
@@ -512,14 +521,30 @@
     @args = (\%a,'foo','bar');
     $x = [dehash] @args;
 
-In scalar context, a reduce operator returns only the final result, but
-in list context, the reduce operator also returns all intermediate results
-lazily:
-
-    say [+], 1..*  #  (1, 3, 6, 10, 15, ...)
-
-Unlike other reduction operators, the C<[;]> operator is not sensitive
-to list context.
+A reduce operator returns only a scalar result regardless of context.
+(Even C<[,]> returns a single Capture object which is then spliced
+into the outer argument list.)  To return all intermediate results,
+backslash the operator:
+
+    say [\+] 1..*  #  (1, 3, 6, 10, 15, ...)
+
+The visual picture of a triangle is not accidental.  To produce a triangular
+list of lists, you can use a "triangular comma":
+
+    [\,] 1..5
+    [1],
+    [1,2],
+    [1,2,3],
+    [1,2,3,4],
+    [1,2,3,4,5]
+
+If there is ambiguity between a triangular reduce and an infix operator
+beginning with backslash, the infix operator is chosen, and an extra backslash
+indicates the corresponding triangular reduce.  As a consequence, defining an
+infix operator beginning with backslash, C<< infix:<\x> >> say, will make it
+impossible to write certain triangular reduction operators, since C<[\x]> would
+mean the normal reduction of C<< infix:<\x> >> operator, not the triangular
+reduction of C<< infix:<x> >>.  This is deemed to be an insignificant problem.
 
 =head1 Junctive operators
 
@@ -672,19 +697,21 @@
 
 =head1 Argument List Interpolating
 
-Since typeglobs are being removed, unary C<*> may now serve as an
-interpolator, by casting its single operand to a C<Capture> object
-and inserting it into the current argument list.
+Perl 5 forced interpolation of a functions argument list by use of
+the C<&> prefix.  That option is no longer available in Perl 6, so
+instead the C<[,]> reduction operator serves as an
+interpolator, by casting its operands to C<Capture> objects
+and inserting them into the current argument list.
 
 It can be used to interpolate an C<Array> or C<Hash> into the current
 call, as positional and named arguments respectively.
 
 Note that those arguments still must comply with the subroutine's
-signature, but the presence of C<*> defers that test until run time for
+signature, but the presence of C<[,]> defers that test until run time for
 that argument (and for any subsequent arguments):
 
     my @args = (scalar @foo, @bar);
-    push [EMAIL PROTECTED];
+    push [,] @args;
 
 is equivalent to:
 
@@ -693,7 +720,7 @@
 as is this:
 
     my $args = \(@foo, @bar);    # construct a Capture object
-    push *$args;
+    push [,] @$args;
 
 In list context, a Scalar holding an Array object does not flatten.  Hence
 
@@ -701,18 +728,15 @@
     push @foo, $bar;
 
 merely pushes a single C<Array> object onto C<@foo>.  You can
-explicitly flatten it in any of these ways:
+explicitly flatten it in either of these ways:
 
-    push @foo, *$bar;
     push @foo, @$bar;
     push @foo, $bar[];
 
-The first form works by interpolating C<$bar>'s elements into positional
-arguments to C<push>.  The last two forms works because the slurpy
-array in C<push>'s signature flattens the C<Array> object in positional
-argument.
+Those two forms work because the slurpy array in C<push>'s signature
+flattens the C<Array> object into a list argument.
 
-Note that the last two forms also allow you to specify list context on
+Note that those two forms also allow you to specify list context on
 assignment:
 
     @$bar = (1,2,3);
@@ -721,7 +745,7 @@
 The last is particularly useful at the end of a long name naming an
 array attribute:
 
-    $foo.bar.baz.bletch.whatever.attr[] = (1,2,3)
+    $foo.bar.baz.bletch.whatever.attr[] = 1,2,3;
 
 The empty C<[]> and C<.[]> postfix operators are interpreted as
 zero-dimensional slices returning the entire array, not null slices
@@ -729,70 +753,16 @@
 not to mention the C<< <> >>, C<< .<> >>, C<«»>, and C<.«»>
 constant and interpolating slice subscripting forms.
 
-The C<*> operator interpolates lazily for C<Array> and C<Range> objects.
-To get an immediate interpolation like Perl 5 does, use unary C<**> instead:
+The C<[,]> operator interpolates lazily for C<Array> and C<Range> objects.
+To get an immediate interpolation like Perl 5 does, add the C<eager> list
+operator:
 
-    func(*(1..Inf));    # works fine
-    func(**(1..Inf));   # never terminates
+    func([,] 1..Inf);         # works fine
+    func([,] eager 1..Inf);   # never terminates
 
-You may use either of them on a scalar iterator to force it to iterate.
+To interpolate a function's return value, you must say:
 
-The C<*> operator is recognized only if the next character is a sigil
-or an opening bracket, In front of an alphabetic character C<*> will
-always be taken to mean C<GLOBAL::>.  Otherwise it will be assumed
-the C<*> has no argument.  See next section.
-
-To interpolate a function's return value, therefore, you must say one
-of these:
-
-    push *(func())
-    push *[func()]
-    push *&func()
-
-because
-
-    push *func()
-
-means
-
-    push GLOBAL::func()
-
-=item * The "Whatever" operator
-
-If the C<*> prefix operator has I<no> argument, it captures the notion
-of "Whatever", which is applied lazily by whatever operator it is
-an argument to.  Generally it can just be thought of as a "glob"
-that gives you everything it can in that argument position.  For instance:
-
-    if $x ~~ 1..* {...}                        # if 1 <= $x <= +Inf
-    my ($a,$b,$c) = "foo" xx *;                # an arbitrary long list of 
"foo"
-    if /foo/ ff * {...}                        # a latching flipflop
-    @slice = @x[*;0;*];                        # any Int
-    @slice = %x{*;'foo'};              # any keys in domain of 1st dimension
-    @array[*]                          # flattens, unlike @array[]
-    (*, *, $x) = (1, 2, 3);            # skip first two elements
-                                       # (same as lvalue "undef" in Perl 5)
-
-C<Whatever> is an undefined prototype object derived from C<Any>.  As a
-type it is abstract, and may not be instantiated as a defined object.
-If for a particular MMD dispatch, nothing in the MMD system claims it,
-it dispatches to as an C<Any> with an undefined value, and usually
-blows up constructively.  If you say
-
-    say 1 + *;
-
-you should probably not expect it to yield a reasonable answer, unless
-you think an exception is reasonable.  Since the C<Whatever> object
-is effectively immutable, the optimizer is free to recognize bare C<*>
-and optimize in the context of what operator it is being passed to.
-
-Other uses for C<*> will doubtless suggest themselves over time.  These
-can be given meaning via the MMD system, if not the compiler.  In general
-a C<Whatever> should be interpreted as maximizing the degrees of freedom
-in a dwimmey way, not as a nihilistic "don't care anymore--just shoot me".
-Care must also be taken not to introduce it on the left side of an infix
-that would be misconstrued as a term or prefix.  C<*..*> works only because
-no term starts with "C<..>".
+    push [,] func()
 
 =head1 Piping operators
 

Modified: doc/trunk/design/syn/S06.pod
==============================================================================
--- doc/trunk/design/syn/S06.pod        (original)
+++ doc/trunk/design/syn/S06.pod        Fri May 12 14:55:00 2006
@@ -13,9 +13,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 21 Mar 2003
-  Last Modified: 3 May 2006
+  Last Modified: 12 May 2006
   Number: 6
-  Version: 33
+  Version: 34
 
 
 This document summarizes Apocalypse 6, which covers subroutines and the
@@ -345,29 +345,41 @@
 
 =head2 Named arguments
 
-Named arguments are recognized syntactically at the
-"comma" level.  Pairs intended as positional arguments rather than
-named arguments must be isolated by extra parens:
+Named arguments are recognized syntactically at the "comma" level.
+Since parameters are identified using identifiers, the recognized
+syntaxes are those where the identifier in question is obvious.
+You may use either the adverbial form, C<:name($value)>, or the
+autoquoted arrow form, C<< name => $value >>.  These must occur at
+the top "comma" level, and no other forms are taken as named pairs
+by default.  Pairs intended as positional arguments rather than named
+arguments may be indicated by extra parens or by explicitly quoting
+the key to suppress autoquoting:
 
     doit :when<now>,1,2,3;     # always a named arg
     doit (:when<now>),1,2,3;   # always a positional arg
 
     doit when => 'now',1,2,3;  # always a named arg
     doit (when => 'now'),1,2,3;        # always a positional arg
+    doit 'when' => 'now',1,2,3;        # always a positional arg
 
 Going the other way, pairs intended as named arguments that don't look
-like pairs must be introduced with C<*>:
+like pairs must be introduced with the C<[,]> reduction operator:
 
     $pair = :when<now>;
-    doit $pair,1,2,3;  # always a positional arg
-    doit *$pair,1,2,3; # always a named arg
+    doit $pair,1,2,3;                   # always a positional arg
+    doit [,] $pair,1,2,3;               # always a named arg
+    doit [,]('when' => 'now'),1,2,3;    # always a named arg
+    doit [,] get_pair(),1,2,3;          # always a named arg
+
+Note that, to apply C<[,]> to a single arg you may need to use parentheses.
+In general it doesn't matter.
 
 Likewise, if you wish to pass a hash and have its entries treated as
-named arguments, you must introduce it with a C<*>:
+named arguments, you must dereference it with a C<[,]>:
 
     %pairs = {:when<now> :what<any>};
-    doit %pairs,1,2,3; # always a positional arg
-    doit *%pairs,1,2,3;        # always named args
+    doit %pairs,1,2,3;         # always a positional arg
+    doit [,](%pairs),1,2,3;    # always named args
 
 Variables with a C<:> prefix in rvalue context autogenerate pairs, so you
 can also say this:
@@ -414,13 +426,14 @@
 
 Because named and positional arguments can be freely mixed, the
 programmer always needs to disambiguate pairs literals from named
-arguments with parenthesis:
+arguments with parenthesis or quotes:
 
     # Named argument "a"
     push @array, 1, 2, :a<b>;
 
     # Pair object (a=>'b')
     push @array, 1, 2, (:a<b>);
+    push @array, 1, 2, 'a' => 'b';
 
 Perl 6 allows multiple same-named arguments, and records the relative
 order of arguments with the same name.  When there are more than one
@@ -441,7 +454,7 @@
 parameters, similar to how hash constructors work:
 
     # Allow "x" and "y" in %defaults be overrided
-    f( *%defaults, x => 1, y => 2 );
+    f( [,](%defaults), x => 1, y => 2 );
 
 =head2 Invocant parameters
 
@@ -695,25 +708,26 @@
 
 =head2 Flattening argument lists
 
-The unary prefix operator C<*> casts a value to a C<Capture>
-object, then splices it into the argument list it occurs in.
+The reduce operator C<[,]> casts each of its arguments to a C<Capture>
+object, then splices each of those captures into the argument list
+it occurs in.
 
 Casting C<Capture> to C<Capture> is a no-op:
 
-    *(\(1, x=>2));    # Capture, becomes \(1, x=>2)
+    [,](\(1, x=>2));    # Capture, becomes \(1, x=>2)
 
 C<Pair> and C<Hash> become named arguments:
 
-    *(x=>1);          # Pair, becomes \(x=>1)
-    *{x=>1, y=>2};    # Hash, becomes \(x=>1, y=>2)
+    [,](x=>1);          # Pair, becomes \(x=>1)
+    [,]{x=>1, y=>2};    # Hash, becomes \(x=>1, y=>2)
 
 C<List> (also C<Seq>, C<Range>, etc.) are simply turned into
 positional arguments:
 
-    *(1,2,3);         # Seq, becomes \(1,2,3)
-    *(1..3);          # Range, becomes \(1,2,3)
-    *(1..2, 3);       # List, becomes \(1,2,3)
-    *([x=>1, x=>2]);  # List (from an Array), becomes \((x=>1), (x=>2))
+    [,](1,2,3);         # Seq, becomes \(1,2,3)
+    [,](1..3);          # Range, becomes \(1,2,3)
+    [,](1..2, 3);       # List, becomes \(1,2,3)
+    [,]([x=>1, x=>2]);  # List (from an Array), becomes \((x=>1), (x=>2))
 
 For example:
 
@@ -722,14 +736,14 @@
 
     foo(1,2,3);                  # okay:  three args found
     foo(@onetothree);            # error: only one arg
-    foo([EMAIL PROTECTED]);           # okay:  @onetothree flattened to three 
args
+    foo([,[EMAIL PROTECTED]);         # okay:  @onetothree flattened to three 
args
 
-The C<*> operator flattens lazily -- the array is flattened only if
+The C<[,]> operator flattens lazily -- the array is flattened only if
 flattening is actually required within the subroutine. To flatten before
-the list is even passed into the subroutine, use the unary prefix C<**>
+the list is even passed into the subroutine, use the C<eager> list
 operator:
 
-    foo([EMAIL PROTECTED]);          # array flattened before &foo called
+    foo([,] eager @onetothree);          # array flattened before &foo called
 
 
 =head2 Multidimensional argument list binding
@@ -1779,7 +1793,7 @@
 On the caller's end, the C<Capture> is interpolated into any new argument list
 much like an array would be, that is, as a scalar in scalar context, and as a
 list in list context.  This is the default behavior, but as with an array, the
-caller may use C<< prefix:<*> >> to inline the returned values as part of the
+caller may use C<< prefix:<[,]> >> to inline the returned values as part of the
 new argument list.  The caller may also bind the returned C<Capture> directly.
 
 =head2 The C<caller> function

Reply via email to