Chris Fields wrote: > On Jul 16, 2008, at 1:28 PM, Patrick R. Michaud wrote: > >> On Wed, Jul 16, 2008 at 11:20:28AM -0500, Chris Fields wrote: >>> I have submitted a simple 'match' implementation for rakudo (method >>> version of m//, RT#56970) and ran into an odd issue. The current >>> version of match which works uses a tail call: >>> >>> .sub 'match' :method >>> .param pmc x >>> .return x.ACCEPTS(self) >>> .end >> >> .ACCEPTS should be calling .match, not vice-versa. > > Okay, though ACCEPTS is currently defined in Code.pir (REJECTS as > well). Would calling .match pertain to all executable blocks, or > should we have a Regex-specific ACCEPTS that calls .match? > > BTW (and a bit OT, but probably related to the above), Rakudo > currently indicates a regex is a Block, not a Regex; haven't looked at > it in detail and don't know if it's worth worrying about for now. > > > say /foo/.WHAT > Block > >> Essentially the difference is that smart-match sets $/, while >> a simple call to .match probably should not. >> >> Pm > > I can have .match not set $/ for now and simply return matches based > on context
IMHO that's the wrong approach. Perl 6 tries not to return stuff based on context, but to return stuff that will behave right in every context. So if you just return a match object (that one that would usually ends up in $/ ) you should be just fine all contexts. Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/