Piers Cawley wrote:
>  Unless I'm very much mistaken, the order of execution will
> look like:
> 
>       $2:=$1; $1:=$2;

You're not binding $2:=$1. You're binding $2 to the first
capture. By default $1 is also bound to the first capture.

Assuming that numbered variables aren't special, the order
of execution is:

   $2:=$1:=first; $1:=$2:=second;

That doesn't make any sense though, so numbered variables
must be treated specially -- an explicit numbered binding
replaces the default numbered binding. So, the order of
execution is really:

   $2:=first; $1:=second;

I think this solves both of your puzzles.

One last thing though. Binding might be done at compile-time
because it changes variables, not the values of variables.
Thinking about binding as a compile-time declaration might
be easier than thinking about run-time execution order.

Thinking about binding as a compile-time thing, the rule

   / $2:=(\S+) <lt>= $1:=(\S+) /

becomes

   / <begin $2>[\S+]<end $2> <lt>= <begin $1>[\S+]<end $1> /

- Ken

Reply via email to