.match and .subst set outer $/?

2009-07-12 Thread Moritz Lenz
payload++ brought this up on #perl6:

in current Rakudo, $string ~~ /re/ sets $/ in the scope in which the
expression appears, ie

'a' ~~ /./;
say $/; # ouput: a

But $str.match(..) and $str.subst don't. The spec is rather silent, it
says There are also method forms of m// and s///: [...] There is no
syntactic sugar here.

I setting of OUTER::$/ considered syntactic sugar?

I don't care either way, I'd just like some clarification so that I can
write tests and submit tickets (if appropriate).

Cheers,
Moritz


Re: .match and .subst set outer $/?

2009-07-12 Thread Daniel Ruoso
Em Dom, 2009-07-12 às 22:51 +0200, Moritz Lenz escreveu:
 I setting of OUTER::$/ considered syntactic sugar?
 I don't care either way, I'd just like some clarification so that I can
 write tests and submit tickets (if appropriate).

As far as I remember, it's not really OUTER::$/, but each routine
implicitly declare

 my $/ is contextrw;
 my $! is contextrw;

so what happens inside m// or s/// is that inside that it should look
for $*/, as well as the process of failing should look for $*!. This
also has the advantage of:

 {
   'abc' ~~ /abc/;
   say $/; # prints abc
   {
 my $/ is contextrw;
 'bcd' ~~ /bcd';
 say $/; # prints bcd;
   }
   say $/; # still prints abc;
 }

I'm pretty sure that was just said by TimToady on IRC a lot of time ago
and no spec actually defines it.

That being said, I don't think there's a reason for .match and .subst
not to look and set $*/.

daniel