my ($self, $var, $stream, $then) = @_;
warn "Binding ".$var->id." to $stream";
my $bound = $var->with_stream($stream);
- $self->new(%$self,
+ $self->but(
by_id => { %{$self->by_id}, $var->id => $bound },
next_op => $then
)->mark_choice($bound);
sub mark_choice {
my ($self, $var) = @_;
- $self->new(%$self,
- last_choice => [ $self, $var ]
- );
+ $self->but(last_choice => [ $self, $var ]);
}
sub backtrack {
sub then {
my ($self, $then) = @_;
- $self->new(%$self, next_op => $then);
+ $self->but(next_op => $then);
}
sub run {
$_[0]->then(DX::Op::FromCode->new(code => sub { $_[1]->backtrack }));
}
+sub but {
+ my ($self, @but) = @_;
+ $self->new(%$self, @but);
+}
+
1;