On Wed, 2002-09-04 at 14:38, Jonathan Scott Duff wrote: > my $x; > / (\S*) { let $x = .pos } \s* foo / > > After this pattern, $x will be set to the ending position of > $1--but only if the pattern succeeds. If it fails, $x is > restored to undef when the closure is backtracked > > I don't see any binding there, just letting.
I think the confusion here is that "let" is creating a binding, but the binding is between the named variable (e.g. C<$x>) and the storage in the result object (e.g. C<$0.{x}>). What C<$0.{x}> is is kind of beside the point. It may be a binding as in: ... {let $x := $1} ... or a stand-alone value as in: ... {let $x = $1 + 100} ... Does this make sense? As I understand it, the let statement is translated to something like this: ... { $self.{x} = sub {$1 + 100}; $x := $self.{x} } ... Which will then be evaluated and the result substituted: $0.{x} = $0.{x}.(); once backtracking is complete to avoid evaluating C<$1 + 100> before a final understanding of what C<$1> contains is reached. Is that roughly correct?