Peter Haworth wrote:
> Also the different operators used (:= inside the rule, = inside the code)
> seems a bit confusing to me; I can't see that they're really doing anything
> different:
> 
>      / $x := (gr\w+) /    vs    / (gr\w+) { let $x = $1 } /
> 
> Shouldn't they both use C< := > ?

Depends on what you want. The "$x :=" in the rule binds the
first match to $x -- it does not copy the value. The "$x ="
in the code block copies the value of the first match. You
can use either binding or assignment in the code block.

Both of them will be "undone" during backtracking. It's more
efficient to bind, but the copy guarantees changes to $x and $1
are independent.

- Ken

Reply via email to