>   MD> One of Uri's suggestions in RFC 158 was to compute $& only for
>   MD> regexes that have a /k modifier.  This would solve the $& problem
>   MD> because Perl would compute $& only when asked to, and not for
>   MD> every other regex in the rest of the program.
> 
> the rfc was about making $& private to the block with the regex and
> only make the copy if /k is used or you use grabbing.

Making $& local to a block is not going to get a performance
improvement.  The reason $1 is block localized is for safety, not
speed.  Consider:

        /(...)/;
        foo();
        print $1;

You might have had to worry that foo() would reset $1 somehow.  But
because $1 is block-localized, you can be sure that it will be
restored automatically when foo() returns.

The performance gain in your RFC comes from the /k option, regardless
of whether or not $& gets block scope.

> a side question i have is whether this extra copy is a runtime effect or
> compile time. i would imagine runtime with some global flag being
> checked to see if $& is being used. so you could run fast and later load
> a module uses $& which slows you down. 

That doesn't make any sense.  Your proposal says that $& is only set
for regexes that have /k.  Loading a module won't change your non-/k
regexes.

> in any case, i think we have a fair agreement on rfc 158 and i will
> freeze it if there is no further comments on it.

Please add a section that addresses Perl 5 -> Perl 6 translation
issues that will apply if your proposal is adopted.

Reply via email to