split seems to be a suprisingly tricky beast ;-)

To quote S29:

: As with Perl 5's split, if there is a capture in the pattern it
: is returned in alternation with the split values. Unlike with
: Perl 5, multiple such captures are returned in a single Match object.

Unlike in Perl 5, it is not determined at (pattern) compile time if a
regex has captures.

In Perl 5 the regex m/(foo)?/ always has one capture ($1), in Perl 6 it
has either zero or one ($0 doesn't exist if 'foo' never matched).

So does split return the match objects
  * if the regex has the potential to create at least one capture
or
  * at least one match actually produces a capture
or
  * (weird) only those matches that produce a capture put a match object
into the result list.

I'd go for the first option.
In that case it might be useful to have some sort of introspection, ie a
method like $regex.has_capture (which might return either True
(unconditional captures) or False (no captures at all) or True|False
(for my example above) ;-)

Cheers,
Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/

Reply via email to