S05 and S29 may conflict on behavior of $string.match(/pat/)
I'm trying to pin down what $string.match(/pat/) should be returning. From S05: Under Return values from match objects A match always returns a Match object... From S29: Under the definition of Str.comb Saying $string.comb(/pat/, $n) is equivalent to $string.match(rx:global:x(0..$n):c/pat/) [ ...and later... ] If there are captures in the pattern, a list of Match objects (one per match) is returned instead of strings. Which implies that $string.match(/pat/) should indeed return a List of Str and $string.match(/pat_with_groups/) should return a List of Match. I expected the S29 definition when first approaching $string.match I feel it is more intuitive than what happens with S05. Could someone clarify what the behavior should be? Best Regards, -Chris Davaz
Re: S05 and S29 may conflict on behavior of $string.match(/pat/)
On Thu, Sep 18, 2008 at 06:11:45PM +0800, Chris Davaz wrote: : I'm trying to pin down what $string.match(/pat/) should be returning. : : From S05: : : Under Return values from match objects : A match always returns a Match object... : : From S29: : : Under the definition of Str.comb : : Saying : : $string.comb(/pat/, $n) : : is equivalent to : : $string.match(rx:global:x(0..$n):c/pat/) : : [ ...and later... ] : : If there are captures in the pattern, a list of Match objects (one : per match) is returned instead of strings. : : Which implies that $string.match(/pat/) should indeed return a List of : Str and $string.match(/pat_with_groups/) should return a List of : Match. : : I expected the S29 definition when first approaching $string.match I : feel it is more intuitive than what happens with S05. Could someone : clarify what the behavior should be? S05 is using a different definition of match. In S05 it means more like one low-level run of the regex engine rather than one high-level call to the .match method. In other words, the .match method can do multiple matches. Larry
Re: S05 and S29 may conflict on behavior of $string.match(/pat/)
Thanks for clarifying however I'm still unsure what a Perl 6 user should expect to get back from running $string.match(/pat/). This is the one high-level call to the .match method yes? So it should be returning a List of Str (or List of Match in case of capture groups), is this correct? I ask because in the current Rakudo implementation it returns the Match object (what I would expect from the one low-level run of the regex engine). Best Regards, -Chris On Thu, Sep 18, 2008 at 11:52 PM, Larry Wall [EMAIL PROTECTED] wrote: On Thu, Sep 18, 2008 at 06:11:45PM +0800, Chris Davaz wrote: : I'm trying to pin down what $string.match(/pat/) should be returning. : : From S05: : : Under Return values from match objects : A match always returns a Match object... : : From S29: : : Under the definition of Str.comb : : Saying : : $string.comb(/pat/, $n) : : is equivalent to : : $string.match(rx:global:x(0..$n):c/pat/) : : [ ...and later... ] : : If there are captures in the pattern, a list of Match objects (one : per match) is returned instead of strings. : : Which implies that $string.match(/pat/) should indeed return a List of : Str and $string.match(/pat_with_groups/) should return a List of : Match. : : I expected the S29 definition when first approaching $string.match I : feel it is more intuitive than what happens with S05. Could someone : clarify what the behavior should be? S05 is using a different definition of match. In S05 it means more like one low-level run of the regex engine rather than one high-level call to the .match method. In other words, the .match method can do multiple matches. Larry