I'd like to get clarification on the scoping of variables
bound in a regex.  It's described in S05 as follows:

  External aliasing

    * Instead of using internal aliases like:

     m/ mv  @<files>:=<ident>+  $<dir>:=<ident> /

      the name of an ordinary variable can be used as an "external
      alias", like so:

     m/ mv  @files:=<ident>+  $dir:=<ident> /

    * In this case, the behaviour of each alias is exactly as describe
      in the previous sections, except that the resulting capture(s) are
      bound directly (but still hypothetically) to the variables of the
      specified name that exist in the scope in which the rule declared.

S05 and A05 both seems to say that @files and $dir must be already declared
in the scope containing the declaration.  Is that correct?

Is there any way to introduce a new variable to the containing scope
with a regex?  Either the declaration scope or execution scope?

A05 says no, unless MY:: fiddling is allowed.  I can see that variables
popping into existence goes against lexical scoping hygiene, but
it may be acceptable with a "my" in the regex or limiting the
additions to declaring scope.

(I think I've used the word "scope" too much there)

My motivation for this is to use rules as an alternative parameter
list sublanguage.  That idea is still in the oven though.


  To ask when you already know is politeness. To ask when you don't know
  is the rule.                  -- Hagakure http://bereft.net/hagakure/

Reply via email to