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

2007-01-29 Thread larry
Author: larry
Date: Mon Jan 29 10:39:25 2007
New Revision: 13543

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

Log:
Note that take is intended to work en passant as suggested by gabriele renzi++
Also clarified that gather provides a void context to its victim.


Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podMon Jan 29 10:39:25 2007
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 19 Aug 2004
-  Last Modified: 25 Jan 2007
+  Last Modified: 29 Jan 2007
   Number: 4
-  Version: 48
+  Version: 49
 
 This document summarizes Apocalypse 4, which covers the block and
 statement syntax of Perl.
@@ -435,13 +435,33 @@
 explicit because it's not out front where it can be seen.  You can, of
 course, use a placeholder parameter if you also use Creturn.)
 
+=head2 The gather statement
+
 A variant of Cdo is Cgather.  Like Cdo, it is followed by a
-statement or block, and executes it once.  Unlike Cdo, its return
-value is specified by calling the Ctake function one or more times
-within the dynamic scope of the gather.  The returned values are in
-the form of a lazy multislice, with each dimension corresponding to
-one Ctake slice.  (A multislice is flattened in most list contexts.).
-A Cgather is not considered a loop.
+statement or block, and executes it once.  Unlike Cdo, it evaluates the
+statement or block in void context; its return
+value is instead specified by calling the Ctake function one or more times
+within the dynamic scope of the gather.  The returned values are in the
+form of a lazy multislice, with each slice corresponding to one
+Ctake capture.  (A multislice is lazily flattened in normal list context,
+but you may unflatten it again with a @@() contextualizer.)
+
+Because Cgather evaluates its block or statement in void context,
+this typically causes the Ctake statement to be evaluated in void
+context.  However, a Ctake statement that is not in void context
+gathers its arguments Ien passant and also returns them unchanged.
+This makes it easy to keep track of what you last took:
+
+my @uniq = gather for @list {
+state $previous = take $_;
+next if $_ === $previous;
+$previous = take $_;
+}
+
+A Cgather is not considered a loop, but it is easy to combine with a loop
+as in the example above.
+
+=head2 Other Cdo-like forms
 
 Other similar CCode-only forms may also take bare statements,
 including Ctry, Ccontend, Casync, and Clazy.  These constructs


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

2007-01-29 Thread larry
Author: larry
Date: Mon Jan 29 10:45:26 2007
New Revision: 13544

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

Log:
Minor cleanups


Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podMon Jan 29 10:45:26 2007
@@ -441,14 +441,14 @@
 statement or block, and executes it once.  Unlike Cdo, it evaluates the
 statement or block in void context; its return
 value is instead specified by calling the Ctake function one or more times
-within the dynamic scope of the gather.  The returned values are in the
+within the dynamic scope of the Cgather.  The returned values are in the
 form of a lazy multislice, with each slice corresponding to one
 Ctake capture.  (A multislice is lazily flattened in normal list context,
-but you may unflatten it again with a @@() contextualizer.)
+but you may unflatten it again with a C@@() contextualizer.)
 
 Because Cgather evaluates its block or statement in void context,
-this typically causes the Ctake statement to be evaluated in void
-context.  However, a Ctake statement that is not in void context
+this typically causes the Ctake function to be evaluated in void
+context.  However, a Ctake function that is not in void context
 gathers its arguments Ien passant and also returns them unchanged.
 This makes it easy to keep track of what you last took:
 


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

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 10:39:27AM -0800, [EMAIL PROTECTED] wrote:
 +Because Cgather evaluates its block or statement in void context,
 +this typically causes the Ctake statement to be evaluated in void
 +context.  However, a Ctake statement that is not in void context
 +gathers its arguments Ien passant and also returns them unchanged.
 +This makes it easy to keep track of what you last took:
 +
 +my @uniq = gather for @list {
 +state $previous = take $_;
 +next if $_ === $previous;
 +$previous = take $_;
 +}

What does it mean for take to be evaluated in void context?

What are the gathered values here?

   take 1, 2;  # easy. flattened 1 and then 2, right?
   @x = take 1, 2; # same thing?
   $x = take 1, 2; # same thing? [1, 2]?

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


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

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 10:01:08PM +0200, Gaal Yahas wrote:
  +Because Cgather evaluates its block or statement in void context,
  +this typically causes the Ctake statement to be evaluated in void
  +context.  However, a Ctake statement that is not in void context
  +gathers its arguments Ien passant and also returns them unchanged.
  +This makes it easy to keep track of what you last took:
  +
  +my @uniq = gather for @list {
  +state $previous = take $_;
  +next if $_ === $previous;
  +$previous = take $_;
  +}
 
 What does it mean for take to be evaluated in void context?
 
 What are the gathered values here?
 
take 1, 2;  # easy. flattened 1 and then 2, right?
@x = take 1, 2; # same thing?
$x = take 1, 2; # same thing? [1, 2]?

In fact, $x = take 5;# if this were Perl 5, I might expect
 # either 1 or [1] here!

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


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

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 10:08:34PM +0200, Gaal Yahas wrote:
 On Mon, Jan 29, 2007 at 10:01:08PM +0200, Gaal Yahas wrote:
   +Because Cgather evaluates its block or statement in void context,
   +this typically causes the Ctake statement to be evaluated in void
   +context.  However, a Ctake statement that is not in void context
   +gathers its arguments Ien passant and also returns them unchanged.
   +This makes it easy to keep track of what you last took:
   +
   +my @uniq = gather for @list {
   +state $previous = take $_;
   +next if $_ === $previous;
   +$previous = take $_;
   +}
  
  What does it mean for take to be evaluated in void context?
  
  What are the gathered values here?
  
 take 1, 2;  # easy. flattened 1 and then 2, right?
 @x = take 1, 2; # same thing?
 $x = take 1, 2; # same thing? [1, 2]?
 
 In fact, $x = take 5;# if this were Perl 5, I might expect
  # either 1 or [1] here!

Ugh, sorry, I meant either 1 or [5].

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


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

2007-01-29 Thread larry
Author: larry
Date: Mon Jan 29 14:06:49 2007
New Revision: 13545

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

Log:
Clarifications requested by gaal++.


Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podMon Jan 29 14:06:49 2007
@@ -438,12 +438,19 @@
 =head2 The gather statement
 
 A variant of Cdo is Cgather.  Like Cdo, it is followed by a
-statement or block, and executes it once.  Unlike Cdo, it evaluates the
-statement or block in void context; its return
-value is instead specified by calling the Ctake function one or more times
-within the dynamic scope of the Cgather.  The returned values are in the
-form of a lazy multislice, with each slice corresponding to one
-Ctake capture.  (A multislice is lazily flattened in normal list context,
+statement or block, and executes it once.  Unlike Cdo, it evaluates
+the statement or block in void context; its return value is instead
+specified by calling the Ctake list prefix operator one or more times
+within the dynamic scope of the Cgather.  The Ctake function's
+signature is like that of Creturn; it merely captures the CCapture
+of its argments without imposing any additional constraints (in the
+absense of context propagation by the optimizer).  The value returned
+by the Ctake to its own context is that same CCapture object (which
+is ignored when the Ctake is in void context).  Regardless of the
+Ctake's context, the CCapture object is also added to the list of
+values being gathered, which is returned by the Cgather in the form
+of a lazy multislice, with each slice corresponding to one Ctake
+capture.  (A multislice is lazily flattened in normal list context,
 but you may unflatten it again with a C@@() contextualizer.)
 
 Because Cgather evaluates its block or statement in void context,
@@ -458,8 +465,34 @@
 $previous = take $_;
 }
 
+The Ctake function essentially has two contexts simultaneously, the
+context in which the gather is operating, and the context in which the
+Ctake is operating.  These need not be identical contexts, since they
+may bind or coerce the resulting captures differently:
+
+my @y;
+@x = gather for 1..2 {  # @() context for list of captures
+my $x = take $_, $_ * 10;   # $() context for individual capture
+push @y, $x;
+}
+# @x returns 1,10,2,20
+# @y returns [1,10],[2,20]
+
+Likewise, we can just remember the gather's result by binding and
+later coerce it:
+
+$c := gather for 1..2 {
+take $_, $_ * 10;
+}
+# @$c returns 1,10,2,20
+# @@$c returns [1,10],[2,20]
+# $$c returns [[1,10],[2,20]]
+
+Note that the Ctake itself is in void context in this example because
+the Cfor loop is in void context.
+
 A Cgather is not considered a loop, but it is easy to combine with a loop
-as in the example above.
+statement as in the examples above.
 
 =head2 Other Cdo-like forms
 


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

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 02:06:51PM -0800, [EMAIL PROTECTED] wrote:
 +The Ctake function essentially has two contexts simultaneously, the
 +context in which the gather is operating, and the context in which the
 +Ctake is operating.  These need not be identical contexts, since they
 +may bind or coerce the resulting captures differently:
 +
 +my @y;
 +@x = gather for 1..2 {  # @() context for list of captures
 +my $x = take $_, $_ * 10;   # $() context for individual capture
 +push @y, $x;
 +}
 +# @x returns 1,10,2,20
 +# @y returns [1,10],[2,20]

XXX = gather {
YYY
take f();
ZZZ
}

sub f () {
return want.Scalar ?? 42 !! 54;
}

Which of XXX, YYY, and ZZZ influence whether the taken value is 42 or
54? Please confirm there's *no way* that f is entered twice here :-)

(If I'm following correctly, then take's args are basically evaluated
in list context. If YYY is something like $scalar =  that list gets
Captured, but there's still a list there.)

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


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

2007-01-29 Thread larry
Author: larry
Date: Mon Jan 29 16:05:40 2007
New Revision: 13546

Modified:
   doc/trunk/design/syn/S04.pod
   doc/trunk/design/syn/S06.pod

Log:
More infonuggets for gaal++.


Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podMon Jan 29 16:05:40 2007
@@ -14,7 +14,7 @@
   Date: 19 Aug 2004
   Last Modified: 29 Jan 2007
   Number: 4
-  Version: 49
+  Version: 50
 
 This document summarizes Apocalypse 4, which covers the block and
 statement syntax of Perl.
@@ -494,6 +494,14 @@
 A Cgather is not considered a loop, but it is easy to combine with a loop
 statement as in the examples above.
 
+If any function called as part of a Ctake list asks what its context
+is, it will be told it was called in list context regardless of the
+eventual binding of the returned CCapture.  If that is not the
+desired behavior you must coerce the call to an appropriate context.
+In any event, such a function is called only once at the time the
+CCapture object is generated, not when it is bound (which could
+happen more than once).
+
 =head2 Other Cdo-like forms
 
 Other similar CCode-only forms may also take bare statements,

Modified: doc/trunk/design/syn/S06.pod
==
--- doc/trunk/design/syn/S06.pod(original)
+++ doc/trunk/design/syn/S06.podMon Jan 29 16:05:40 2007
@@ -13,9 +13,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 21 Mar 2003
-  Last Modified: 28 Jan 2007
+  Last Modified: 29 Jan 2007
   Number: 6
-  Version: 67
+  Version: 68
 
 
 This document summarizes Apocalypse 6, which covers subroutines and the
@@ -1621,6 +1621,15 @@
 caller may use C prefix:|  to inline the returned values as part of the
 new argument list.  The caller may also bind the returned CCapture directly.
 
+If any function called as part of a return list asks what its context
+is, it will be told it was called in list context regardless of the
+eventual binding of the returned CCapture.  If that is not the
+desired behavior you must coerce the call to an appropriate context,
+(or declare the return type of the function to perform such a coercion).
+In any event, such a function is called only once at the time the
+CCapture object is generated, not when it is later bound (which
+could happen more than once).
+
 =head2 The Ccaller function
 
 The Ccaller function returns an object that describes a particular 


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

2007-01-29 Thread Brandon S. Allbery KF8NH


On Jan 29, 2007, at 17:06 , [EMAIL PROTECTED] wrote:


+absense of context propagation by the optimizer).  The value returned


Minor spelling nit:  absence

--
brandon s. allbery[linux,solaris,freebsd,perl] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH





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

2007-01-29 Thread larry
Author: larry
Date: Mon Jan 29 17:41:22 2007
New Revision: 13547

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

Log:
typo from KF8NH++


Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podMon Jan 29 17:41:22 2007
@@ -444,7 +444,7 @@
 within the dynamic scope of the Cgather.  The Ctake function's
 signature is like that of Creturn; it merely captures the CCapture
 of its argments without imposing any additional constraints (in the
-absense of context propagation by the optimizer).  The value returned
+absence of context propagation by the optimizer).  The value returned
 by the Ctake to its own context is that same CCapture object (which
 is ignored when the Ctake is in void context).  Regardless of the
 Ctake's context, the CCapture object is also added to the list of


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

2007-01-29 Thread larry
Author: larry
Date: Mon Jan 29 21:05:36 2007
New Revision: 13548

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

Log:
More clarifications requested by thom++.


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podMon Jan 29 21:05:36 2007
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 10 Aug 2004
-  Last Modified: 23 Dec 2006
+  Last Modified: 29 Jan 2007
   Number: 2
-  Version: 82
+  Version: 83
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -646,9 +646,6 @@
 A variant of C* is the C** term.  It is generally understood to
 be a multidimension form of C* when that makes sense.
 
-The C*** variant serves as the insertion point of a list of feeds.
-That insertion point may be targeted by feeding into C*.  See S06.
-
 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 CWhatever should be interpreted as maximizing the degrees of freedom
@@ -673,12 +670,15 @@
 
 These can behave as values or objects of any class, except that
 Cdefined always returns false.  One can create them with the
-built-in Cundef and Cfail functions.  (See S02 for how failures
+built-in Cundef and Cfail functions.  (See S04 for how failures
 are handled.)
 
-Undef   Undefined (can serve as a prototype object of any class)
+Undef   Undefined (variants serve as prototype objects of classes)
 WhateverWildcard (like undef, but subject to do-what-I-mean via MMD)
-Failure Failure (throws an exception if not handled properly)
+Failure Failure (lazy exceptions, thrown if not handled properly)
+
+Whenever you declare any kind of type, class, module, or package, you're
+automatically declaring a undefined prototype value with the same name.
 
 =head2 Immutable types