Currently, the split opcode is declared as 'split(out PMC, in STR, in STR)' where $2 is a regex.

PGE, however, currently supports three types of regular expressions, and more are likely going to be added. So, which type of regular expression should split use?

The Perl6's split function will likely use slightly different regular expressions than TCL's split function or Python's. Picking any one regular expression (e.g Perl6's) will force the other languages to reimplement split's functionality.

A solution:

Declare split as 'split(out PMC, in PMC, in STR)' where $2 would be a compiled PGE::Match object. This lets you pick what kind of regular expression you want to use.

An example using Perl6's regular expressions:
.local string pattern
.local string input
.local pmc rulesub
.local pmc array
pattern = "[\n ]" # pattern to compile
rulesub = p6rule_compile(pattern) # compile it to rulesub
input = "I held out my arm\nbut she laughed"
split array, rulesub, input # array will be a list of words in input



Comments? Is there a simpler solution? Am I making a problem out of nothing?

- James



Reply via email to