On Sat, Aug 23, 2008 at 12:55:44PM +0200, Moritz Lenz wrote:
> Carl Mäsak wrote:
> >  # should $/ really keep ties to $s like this?
> > <masak> rakudo: my $s = "hello"; $s ~~ /hello/; $s = "goodbye"; say $/
> > <p6eval> rakudo 29834: OUTPUT[goodb␤]
> 
> I'm pretty sure it's a bug in rakudo.

It's a bug somewhere, yes.  I suspect that PGE is tying to
the scalar variable itself where it needs to be tying to the
value.

> > The currently defined methods are
> > 
> >     $/.from # the initial match position
> >     $/.to   # the final match position
> >     $/.chars        # $/.to - $/.from
> >     $/.orig # the original match string
> >     $/.text # substr($/.orig, $/.from, $/.chars)
> 
> $/.text seems to be a bit superfluous, because it's already available as
> ~$/ and $/.Str

$/.text and ~$/ are different: $/.text always returns the
matched text, while ~$/ returns the stringification of the
result object (which could be different from the matched text
if C<make> was used inside of the regex).

    "81" ~~ / (\d+) { make $0.sqrt } /;

    say ~$/;             # "9\n"
    say $/.text;         # "81\n"

(C<make> and closures in regexes are not implemented in Rakudo yet.)

Pm

Reply via email to