In <[EMAIL PROTECTED]>, Perl6 RFC Librarian writes:
:=head1 TITLE
:
:Asignment within a regex

This document could do with running through a spellchecker.

:Potentially the $foo could be any scalar LHS, as in (?$foo{$bar}= ... )!,
:likewise the '=' could be any asignment operator.

It isn't clear what the significance of the '!' is in that example.
It also isn't clear what parts of the expression are interpolated at
compile time; what should the following leave in %foo?

  %foo = ();
  $bar = "one";
  "twothree" =~ / (?$bar=two) (?$foo{$bar}=three) /x;

:=head2 Scoping
:
:The question of scoping for these assignments has been raised, but I don't
:currently have a feel for the "best" way to handle this.  Input welcome.

I think it should be defined to act the same as in (??{...}), whenever
we get around to defining that.

:=head1 IMPLENTATION
:
:Currently all $scalars in regexes are expanded before the main regex compiler
:gets to analyse the syntax.  This problem also affects several other RFCs
:(166 for example).  The expansion of variables in regexes needs for these
:(and other RFCs) to be driven from within the regex compiler so that the
:regex can expand as and where appropriate.  Changing this should not affect
:any existing behaviour.

That may not be necessary for this case; it may be enough just to tweak
the parser slightly, to detect '(?$' (and maybe '(?\$'). Don't forget
that the parser already successfully skips past '$' when we need it to.

Hugo

Reply via email to