Re: a junction or not

2009-03-18 Thread Bruce Keeler

On 3/15/09 11:19 AM, Richard Hainsworth wrote:

The following (the n: is to mark the lines) are legal:

1: my @x = 1,2,3,4; ([+] @x).say; # output 10
2: my @x = 1|11,2,3,4; ([+] @a).perl.say; # output any(10,20)
3: my @x = 1|11,2,3,4; ([+] @a).eigenstates.min.say; # output 10

However, the next line isnt
4: my @x = 1,2,3,4; ([+] @a).eigenstates.min.say; # Method 
'eigenstates' not found for invocant of class 'Integer'


[...]

I've been pondering and experimenting with this.

Now that the Object.eigenstates patch is in, all of the above cases do 
it indeed work.  But what if you have more than one ace in your hand?


5: my @x = 1|11, 1|11, 10; ([+] @x).eigenstates.min.say
Junction0x7f89311bca30

Not so useful.

6: my @x = 1|11, 1|11, 10; ([+] @x).perl.say
any(any(12, 22), any(22, 32))

A junction of junctions.  And three aces?

7: my @x = 1|11, 1|11, 1|11, 10; ([+] @x).perl.say
any(any(any(13, 23), any(23, 33)), any(any(23, 33), any(33, 43)))

Yikes!  Is there a way of flattening such a beast into any(13, 23, 33, 
43) ?  Does a deeply nested Junction have any practical value that the 
flattened one does not?


At any rate, it behaves much the same as a flattened version would when 
matched against:


8: my @x = 1|11, 1|11, 1|11, 10; ([+] @x) == 23  say Match!
Match!

And so, the solution almost presents itself:

9: my @x = 1|11, 1|11, 1|11, 10; say ([+] @x) ~~ 1..21 ?? OK !! Bust!
OK
10: my @x = 1|11, 1|11, 1|11, 10, 9; say ([+] @x) ~~ 1..21 ?? OK !! 
Bust!

Bust!

And of course, that would have worked before the patch.

Oh, and ++ for coming up with such a cool use for junctions in the first 
place!


Bruce


Re: a junction or not

2009-03-18 Thread TSa (Thomas Sandlaß)
HaloO,

On Tuesday, 17. March 2009 10:25:27 David Green wrote:
  That is, it would return a Junction of Str, not a Str.  So the
  question is how to get something that returns an expression to the
  effect of:
  'any(' ~ $choice.eigenstates.«perl.join(',') ~ ')'

 say $choice.perl

 ...which will ultimately call (junction-of-.perl's).Str, and
 Str(Junction:) is what produces the any(XXX) string.  [Unless it
 ends up being implemented some other way, of course!]

Note that this contradicts Larry's statement that .perl
autothreads. I think it can't autothread because we expect
it to put the junction constructor in front of the values
or the right operator as infix. So .perl is junction aware!
But it threads the .perl method through the eigenstates,
of course.


  The other question is: given $choice as defined above, how do I find
  out which type of junction it is?

 I guess really Junctions need two public methods: .eigenstates for the
 values, and, er, .eigenop(?!) to return how they're joined -- I'm
 thinking it would return a code ref, i.e. any, all, etc.

A simple solution is to have subtypes of Junction like AnyJunction,
AllJunction, OneJunction and NoneJunction or perhaps like Junction::Any,
Junction::All, Junction::One and Junction::None.


Regards, TSa.
-- 
The unavoidable price of reliability is simplicity -- C.A.R. Hoare
Simplicity does not precede complexity, but follows it. -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


r25889 - docs/Perl6/Spec

2009-03-18 Thread pugs-commits
Author: lwall
Date: 2009-03-18 19:24:25 +0100 (Wed, 18 Mar 2009)
New Revision: 25889

Modified:
   docs/Perl6/Spec/S05-regex.pod
Log:
Destroy the term result object in favor of abstract object and AST-Think.


Modified: docs/Perl6/Spec/S05-regex.pod
===
--- docs/Perl6/Spec/S05-regex.pod   2009-03-18 18:14:09 UTC (rev 25888)
+++ docs/Perl6/Spec/S05-regex.pod   2009-03-18 18:24:25 UTC (rev 25889)
@@ -14,9 +14,9 @@
Maintainer: Patrick Michaud pmich...@pobox.com and
Larry Wall la...@wall.org
Date: 24 Jun 2002
-   Last Modified: 11 Mar 2009
+   Last Modified: 18 Mar 2009
Number: 5
-   Version: 91
+   Version: 92
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them Iregex rather than regular
@@ -774,15 +774,21 @@
 \s+  { print but does contain whitespace\n }
  /
 
-An Bexplicit reduction using the Cmake function sets the Iresult object
+An Bexplicit reduction using the Cmake function generates the
+Iabstract syntax tree object (Iabstract object or Iast for short)
 for this match:
 
 / (\d) { make $0.sqrt } Remainder /;
 
-This has the effect of capturing the square root of the numified string,
-instead of the string.  The CRemainder part is matched but is not returned
-as part of the result object unless the first Cmake is later overridden by 
another Cmake.
+This has the effect of capturing the square root of the numified
+string, instead of the string.  The CRemainder part is matched and
+returned as part of the CMatch object but is not returned
+as part of the abstract object.  Since the abstract object usually
+represents the top node of an abstract syntax tree, the abstract object
+may be extracted from the CMatch object by use if the C.ast method.
 
+A second call to Cmake overrides any previous call to Cmake.
+
 These closures are invoked with a topic (C$_) of the current match
 state (a CCursor object).  Within a closure, the instantaneous
 position within the search is denoted by the C.pos method on
@@ -1331,7 +1337,7 @@
 time you use it unless the string changes.  (Any external lexical
 variable names must be rebound each time though.)  Subrules may not be
 interpolated with unbalanced bracketing.  An interpolated subrule
-keeps its own inner match result as a single item, so its parentheses never 
count toward the
+keeps its own inner match results as a single item, so its parentheses never 
count toward the
 outer regexes groupings.  (In other words, parenthesis numbering is always
 lexically scoped.)
 
@@ -1585,7 +1591,7 @@
 
 =item *
 
-A C (  token indicates the start of a result capture, while the
+A C (  token indicates the start of the match's overall capture, while the
 corresponding C )  token indicates its endpoint.  When matched,
 these behave as assertions that are always true, but have the side
 effect of setting the C.from and C.to attributes of the match
@@ -1600,8 +1606,9 @@
 except that the scan for Cfoo can be done in the forward direction,
 while a lookbehind assertion would presumably scan for C\d+ and then
 match Cfoo backwards.  The use of C (...)  affects only the
-meaning of the Iresult object and the positions of the beginning and
-ending of the match.  That is, after the match above, C$() contains
+meaning the positions of the beginning and
+ending of the match, and anything calculated based on those positions.
+For instance, after the match above, C$() contains
 only the digits matched, and C$/.to is pointing to after the digits.
 Other captures (named or numbered) are unaffected and may be accessed
 through C$/.
@@ -2389,8 +2396,9 @@
 =item *
 
 Notionally, a match object contains (among other things) a boolean
-success value, a scalar Iresult object, an array of ordered submatch
-objects, and a hash of named submatch objects.  To provide convenient
+success value, an array of ordered submatch objects, and a hash of named
+submatch objects.  (It also optionally carries an Iabstract object normally
+used to build up an abstract syntax tree,)  To provide convenient
 access to these various values, the match object evaluates differently
 in different contexts:
 
@@ -2433,10 +2441,12 @@
 
 When used as a scalar, a CMatch object evaluates to itself.
 
-However, sometimes you would like an alternate scalar value to ride
-along with the match.  This is called a Iresult object, and it rides
-along is an attribute of the CMatch object.
-C$() is a shorthand for C$($/.rob).
+However, sometimes you would like an alternate scalar value to
+ride along with the match.  The CMatch object itself describes
+a concrete parse tree, so this extra value is called an Iabstract
+object; it rides along as an attribute of the CMatch object.  C$()
+is a shorthand for C$($/.ast).  The C.ast method by default just
+returns the string between the C$/.from and C$/.to positions.
 
 Therefore C$() is usually just the entire match 

r25890 - docs/Perl6/Spec

2009-03-18 Thread pugs-commits
Author: lwall
Date: 2009-03-18 20:04:16 +0100 (Wed, 18 Mar 2009)
New Revision: 25890

Modified:
   docs/Perl6/Spec/S03-operators.pod
Log:
kill off int as a prefix operator to avoid confusion with the type name


Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod   2009-03-18 18:24:25 UTC (rev 25889)
+++ docs/Perl6/Spec/S03-operators.pod   2009-03-18 19:04:16 UTC (rev 25890)
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall la...@wall.org
   Date: 8 Mar 2004
-  Last Modified: 17 Mar 2009
+  Last Modified: 18 Mar 2009
   Number: 3
-  Version: 159
+  Version: 160
 
 =head1 Overview
 
@@ -991,7 +991,6 @@
 
 Functions of one argument
 
-int
 sleep
 abs
 sin
@@ -1000,9 +999,16 @@
 Note that, unlike in Perl 5, you must use the C.meth forms to default
 to C$_ in Perl 6.
 
-There is no unary Crand function in Perl 6, though there is a C.rand
-method call and an argumentless Crand term.
+There is no unary Crand prefix in Perl 6, though there is a C.rand
+method call and an argumentless Crand term.   There is no unary Cint
+prefix either; you must use a typecast to a type such as CInt or Cint.
+(Typecasts require parentheses and may not be used as prefix operators.)
+In other words:
 
+my $i = int $x;   # ILLEGAL
+
+is a syntax error (two terms in a row), because Cint is a type name now.
+
 =over
 
 =item *



r25891 - in docs/Perl6/Spec: . S32-setting-library

2009-03-18 Thread pugs-commits
Author: lwall
Date: 2009-03-18 20:46:15 +0100 (Wed, 18 Mar 2009)
New Revision: 25891

Modified:
   docs/Perl6/Spec/S02-bits.pod
   docs/Perl6/Spec/S06-routines.pod
   docs/Perl6/Spec/S09-data.pod
   docs/Perl6/Spec/S32-setting-library/Containers.pod
Log:
junctions are now considered a native type with private eigenstates


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2009-03-18 19:04:16 UTC (rev 25890)
+++ docs/Perl6/Spec/S02-bits.pod2009-03-18 19:46:15 UTC (rev 25891)
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall la...@wall.org
   Date: 10 Aug 2004
-  Last Modified: 15 Mar 2009
+  Lwst Modified: 18 Mar 2009
   Number: 2
-  Version: 159
+  Version: 160
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -576,7 +576,7 @@
 
 Built-in object types start with an uppercase letter. This includes
 immutable types (e.g. CInt, CNum, CComplex, CRat, CStr,
-CBit, CRegex, CSet, CJunction, CCode, CBlock, CList,
+CBit, CRegex, CSet, CCode, CBlock, CList,
 CSeq), as well as mutable (container) types, such as CScalar,
 CArray, CHash, CBuf, CRoutine, CModule, etc.
 
@@ -588,6 +588,11 @@
 repeated autoboxing can slow your program more than the native type
 can speed it up.)
 
+The Cjunction type is considered a native type because its internal
+representation is fixed, and you may not usefully derive from it
+because the intent of junctions is to autothread any method calls
+on them.
+
 Some object types can behave as value types.  Every object can produce
 a WHICH value that uniquely identifies the
 object for hashing and other value-based comparisons.  Normal objects
@@ -937,7 +942,7 @@
 CFailure role.  (The Cundef function merely returns the most
 generic CFailure object.  Use Cfail to return more specific failures.  Use
 CObject for the most generic non-failure undefined value.  The CAny
-type is also undefined, but excludes CJunctions so that autothreading
+type is also undefined, but excludes Cjunctions so that autothreading
 may be dispatched using normal multiple dispatch rules.)
 
 The CNil type is officially undefined as an item but interpolates
@@ -968,7 +973,6 @@
 Range   A pair of Ordered endpoints; gens immutables when iterated
 Set Unordered collection of values that allows no duplicates
 Bag Unordered collection of values that allows duplicates
-JunctionSet with additional behaviors
 Signature   Function parameters (left-hand side of a binding)
 Capture Function call arguments (right-hand side of a binding)
 BlobAn undifferentiated mass of bits
@@ -1028,8 +1032,8 @@
 Class   Perl 6 standard class namespace
 RolePerl 6 standard generic interface/implementation
 Grammar Perl 6 pattern matching namespace
-Any Perl 6 object (default routine parameter type, excludes 
Junction)
-Object  Perl 6 object (default block parameter type, either Any or 
Junction)
+Any Perl 6 object (default routine parameter type, excludes 
junction)
+Object  Perl 6 object (default block parameter type, either Any or 
junction)
 
 A CKeyHash differs from a normal CHash in how it handles default
 values.  If the value of a CKeyHash element is set to the default

Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2009-03-18 19:04:16 UTC (rev 25890)
+++ docs/Perl6/Spec/S06-routines.pod2009-03-18 19:46:15 UTC (rev 25891)
@@ -13,9 +13,9 @@
 
   Maintainer: Larry Wall la...@wall.org
   Date: 21 Mar 2003
-  Last Modified: 4 Mar 2009
+  Last Modified: 18 Mar 2009
   Number: 6
-  Version: 105
+  Version: 106
 
 
 This document summarizes Apocalypse 6, which covers subroutines and the
@@ -2876,7 +2876,7 @@
 
 The natural way to implement autothreading for multi subs is to
 simply have the junctional signatures (the ones that can accept
-Objects/Junctions as well as Any parameters) match more loosely than
+Objects or junctions as well as Any parameters) match more loosely than
 the non-autothreading versions, and let multiple dispatch find the
 appropriate sub based on the signature.  Those generic routines
 then end up redispatching to the more specific ones.

Modified: docs/Perl6/Spec/S09-data.pod
===
--- docs/Perl6/Spec/S09-data.pod2009-03-18 19:04:16 UTC (rev 25890)
+++ docs/Perl6/Spec/S09-data.pod2009-03-18 19:46:15 UTC (rev 25891)
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall la...@wall.org
   Date: 13 Sep 2004
-  Last Modified: 4 Mar 2009
+  Last Modified: 18 Mar 2009
   Number: 9
-  Version: 30
+  Version: 31
 
 =head1 Overview
 
@@ -984,7 +984,7 @@
 In particular, if a junction is used as an argument to any routine
 (operator, closure, 

r25895 - docs/Perl6/Spec

2009-03-18 Thread pugs-commits
Author: coke
Date: 2009-03-18 21:10:41 +0100 (Wed, 18 Mar 2009)
New Revision: 25895

Modified:
   docs/Perl6/Spec/S02-bits.pod
Log:
Correct minor typo in metadata.
(... unless that's Welsh, in which case my bad.)



Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2009-03-18 20:10:33 UTC (rev 25894)
+++ docs/Perl6/Spec/S02-bits.pod2009-03-18 20:10:41 UTC (rev 25895)
@@ -12,7 +12,7 @@
 
   Maintainer: Larry Wall la...@wall.org
   Date: 10 Aug 2004
-  Lwst Modified: 18 Mar 2009
+  Last Modified: 18 Mar 2009
   Number: 2
   Version: 160
 



Re: r25821 - docs/Perl6/Spec

2009-03-18 Thread Moritz Lenz
pugs-comm...@feather.perl6.nl wrote:
 Author: masak
 Date: 2009-03-14 13:34:42 +0100 (Sat, 14 Mar 2009)
 New Revision: 25821
 
 Modified:
docs/Perl6/Spec/S12-objects.pod
 Log:
 specced syntactic 'where' sugar in param lists
 
 Modified: docs/Perl6/Spec/S12-objects.pod
 ===
 --- docs/Perl6/Spec/S12-objects.pod   2009-03-13 15:44:50 UTC (rev 25820)
 +++ docs/Perl6/Spec/S12-objects.pod   2009-03-14 12:34:42 UTC (rev 25821)
 @@ -12,9 +12,9 @@
  
Maintainer: Larry Wall la...@wall.org
Date: 27 Oct 2004
 -  Last Modified: 12 Mar 2009
 +  Last Modified: 14 Mar 2009
Number: 12
 -  Version: 76
 +  Version: 77
  
  =head1 Overview
  
 @@ -1305,6 +1305,18 @@
  since all the type constraints in a signature parameter are just
  anded together anyway.
  
 +You can leave out the block when matching against a literal value of some
 +kind:
 +
 +multi sub fib ($n where 0|1) { return $n }
 +multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }
 +
 +In fact, you can leave out the 'where' declaration altogether:
 +
 +multi sub fib (0) { return 0 }
 +multi sub fib (1) { return 1 }
 +multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

As much as I like this new syntax, it's not as useful as it looks.
multi sub fib (0) desugars to (Any $ where 0), which is just a type
constraint in terms of multi dispatch. Which (Int $n) is also, so you
actually get an ambiguous dispatch error in your example.

Any thoughts on how that could be improved in a dwimmy way?

Cheers,
Moritz


Re: r25821 - docs/Perl6/Spec

2009-03-18 Thread Jonathan Worthington

Moritz Lenz wrote:

pugs-comm...@feather.perl6.nl wrote:
  

 +You can leave out the block when matching against a literal value of some
+kind:
+
+multi sub fib ($n where 0|1) { return $n }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }
+
+In fact, you can leave out the 'where' declaration altogether:
+
+multi sub fib (0) { return 0 }
+multi sub fib (1) { return 1 }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }



As much as I like this new syntax, it's not as useful as it looks.
multi sub fib (0) desugars to (Any $ where 0), which is just a type
constraint in terms of multi dispatch. Which (Int $n) is also, so you
actually get an ambiguous dispatch error in your example.

  
Actually, you'd not get an ambiguous dispatch. Int is narrower than Any, 
so the Any cases with the constraints are never considered. So in:


+multi sub fib ($n where 0|1) { return $n }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

You'd always dispatch to the second of those, because Int is narrower than Any. 
And:

+multi sub fib (0) { return 0 }
+multi sub fib (1) { return 1 }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

Here you'd always call the last one too, for the same reason. (And thus both 
would recourse infinitely. Fail.)

Of course, leaving Int off of both examples should make it work.



Any thoughts on how that could be improved in a dwimmy way?
  
Well, in this case of simple literal integers we can probably statically 
know their type and be able to generate Int $ where 0 instead. But I'm 
not sure how well that will scale up...


Jonathan


Re: r25821 - docs/Perl6/Spec

2009-03-18 Thread Jonathan Worthington

Jonathan Worthington wrote:

Moritz Lenz wrote:

pugs-comm...@feather.perl6.nl wrote:
 
 +You can leave out the block when matching against a literal value 
of some

+kind:
+
+multi sub fib ($n where 0|1) { return $n }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }
+
+In fact, you can leave out the 'where' declaration altogether:
+
+multi sub fib (0) { return 0 }
+multi sub fib (1) { return 1 }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }



As much as I like this new syntax, it's not as useful as it looks.
multi sub fib (0) desugars to (Any $ where 0), which is just a type
constraint in terms of multi dispatch. Which (Int $n) is also, so you
actually get an ambiguous dispatch error in your example.

  
Actually, you'd not get an ambiguous dispatch. Int is narrower than 
Any, so the Any cases with the constraints are never considered. So in:


+multi sub fib ($n where 0|1) { return $n }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

You'd always dispatch to the second of those, because Int is narrower 
than Any. And:


+multi sub fib (0) { return 0 }
+multi sub fib (1) { return 1 }
+multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

Here you'd always call the last one too, for the same reason. (And 
thus both would recourse infinitely. Fail.)


Of course, leaving Int off of both examples should make it work.



Any thoughts on how that could be improved in a dwimmy way?
  
Well, in this case of simple literal integers we can probably 
statically know their type and be able to generate Int $ where 0 
instead. But I'm not sure how well that will scale up...


O AKSHUALY...that's quite easy to do, since we just calls .WHAT on the 
value to get its proto-object and stick it in the sig. So perhaps best 
is just to re-define:


multi sub fib (LITERAL) { ... }

As meaning

multi sub fib (LITERAL.WHAT $ where LITERAL) { ... }

Jonathan



Dallas.p6m

2009-03-18 Thread fREW Schmidt
Hello friends!
s1n and I decided that we would start Dallas.p6m as we are close to each
other geographically speaking.  We are meeting tomorrow (Thursday, March 19,
7:00PM) at a coffee shop with free wifi.  The address is 985 W Bethany Dr
Allen, TX 75013.

So far it looks like it will be s1n, me, and two or three of my co-workers.
 We don't really have an agenda, but I figure I will ask s1n about some PIR
stuff and if he wants I can chat about some perl 6 stuff (although he may
know more about that as well.)

Anyway, you are invited to come and have a good time!  We will probably be
more organized in the future, but for now this will work :-)



-- 
fREW Schmidt
http://blog.afoolishmanifesto.com


Re: r25821 - docs/Perl6/Spec

2009-03-18 Thread Mark J. Reed
2009/3/18 Moritz Lenz mor...@faui2k3.org:
 +You can leave out the block when matching against a literal value of some
 +kind:
 +
 +    multi sub fib ($n where 0|1) { return $n }
 +    multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }
 +
 +In fact, you can leave out the 'where' declaration altogether:
 +
 +    multi sub fib (0) { return 0 }
 +    multi sub fib (1) { return 1 }
 +    multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

 As much as I like this new syntax, it's not as useful as it looks.
 multi sub fib (0) desugars to (Any $ where 0),

Shouldn't that desugar to (Int $ where 0)?  After all, 0.WHAT is Int...

Of course, then someone will expect multi sub fib (0|1) { return @_[0]
} to DTRT here...


 Cheers,
 Moritz




-- 
Mark J. Reed markjr...@gmail.com


Re: r25821 - docs/Perl6/Spec

2009-03-18 Thread Jonathan Worthington

Mark J. Reed wrote:

Shouldn't that desugar to (Int $ where 0)?  After all, 0.WHAT is Int...

  
Yes, I proposed that in my second reply too, after realizing .WHAT gave 
us that too. :-)



Of course, then someone will expect multi sub fib (0|1) { return @_[0]
} to DTRT here...
  
That's fine, because we shatter their expectations with a parse fail, 
not a debugging session. :-)


Jonathan



r25902 - docs/Perl6/Spec

2009-03-18 Thread pugs-commits
Author: lwall
Date: 2009-03-19 01:43:53 +0100 (Thu, 19 Mar 2009)
New Revision: 25902

Modified:
   docs/Perl6/Spec/S05-regex.pod
Log:
[S05] define .caps and .chunks methods on match objects


Modified: docs/Perl6/Spec/S05-regex.pod
===
--- docs/Perl6/Spec/S05-regex.pod   2009-03-18 23:02:41 UTC (rev 25901)
+++ docs/Perl6/Spec/S05-regex.pod   2009-03-19 00:43:53 UTC (rev 25902)
@@ -16,7 +16,7 @@
Date: 24 Jun 2002
Last Modified: 18 Mar 2009
Number: 5
-   Version: 92
+   Version: 93
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them Iregex rather than regular
@@ -1705,14 +1705,14 @@
 =item * before Cpattern
 
 Perform lookahead -- i.e., check if we're at a position where
-Cpattern matches.  Returns a zero-width Match object on
+Cpattern matches.  Returns a zero-width CMatch object on
 success.
 
 =item * after Cpattern
 
 Perform lookbehind -- i.e., check if the string before the
 current position matches pattern (anchored at the end).
-Returns a zero-width Match object on success.
+Returns a zero-width CMatch object on success.
 
 =item * ?
 
@@ -2385,7 +2385,7 @@
 
 =item *
 
-A match always returns a Match object, which is also available
+A match always returns a CMatch object, which is also available
 as C$/, which is a contextual lexical declared in the outer
 subroutine that is calling the regex.  (A regex declares its own
 lexical C$/ variable, which always refers to the most recent
@@ -2547,6 +2547,9 @@
 $/.chars   # $/.to - $/.from
 $/.orig# the original match string
 $/.Str # substr($/.orig, $/.from, $/.chars)
+$/.ast  # the abstract result associated with this node
+$/.caps # sequential captures
+$/.chunks   # sequential tokenization
 
 Within the regex the current match state C$¢ also provides
 
@@ -2558,6 +2561,18 @@
 
 =item *
 
+As described above, a CMatch in list context returns its positional
+captures.  However, sometimes you'd rather get a flat list of tokens in
+the order they occur in the text.  The C.caps method returns a list
+of every captured item, regardless of how it was otherwise bound into
+named or numbered captures.  The C.chunks method returns the captures
+as well as all the interleaved noise between the captures. [Conjecture:
+we could also have C.deepcaps and C.deepchunks that recursively expand
+any capture containing submatches.  Presumably each returned chunk would
+come equipped with some method to discover its pedigree in the parse tree.]
+
+=item *
+
 All match attempts--successful or not--against any regex, subrule, or
 subpattern (see below) return an object of class CMatch. That is:
 
@@ -2566,8 +2581,8 @@
 
 =item *
 
-This returned object is also automatically assigned to the lexical
-C$/ variable of the current surroundings. That is:
+This returned object is also automatically bound to the lexical
+C$/ variable of the current surroundings regardless of success. That is:
 
  $str ~~ /pattern/;
  say Matched if $/;
@@ -3122,7 +3137,7 @@
 #||
   mm/ $key=[ ([A..E]) (\d**3..6) (X?) ] /;
 
-then the corresponding C $/key  Match object contains only the string
+then the corresponding C $/key  CMatch object contains only the string
 matched by the non-capturing brackets.
 
 =item *



Re: r25891 - in docs/Perl6/Spec: . S32-setting-library

2009-03-18 Thread Jon Lang
 +    method !eigenstates (Junction $j: -- List)

Shouldn't that be lowercase-j junction?

-- 
Jonathan Dataweaver Lang


Re: r25891 - in docs/Perl6/Spec: . S32-setting-library

2009-03-18 Thread Larry Wall
On Wed, Mar 18, 2009 at 06:32:18PM -0700, Jon Lang wrote:
:  +    method !eigenstates (Junction $j: -- List)
: 
: Shouldn't that be lowercase-j junction?

Maybe, though there might be a Junction role involved for subtype
matches like that one.

Larry