From: Matt S Trout Date: Sat, 25 Jun 2016 01:40:05 +0000 (+0000) Subject: create explicit on_exhaustion_step attribute X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6a0483ff6915c819a942613ecfd118a970d4f2ee;p=scpubgit%2FDX.git create explicit on_exhaustion_step attribute --- diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index 1548f11..a19a416 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -15,6 +15,8 @@ has alternatives => (is => 'ro', isa => AlternativeList, required => 1); has is_solution_state => (is => 'ro', required => 1); +has on_exhaustion_step => (is => 'ro', required => 1); + sub next_proposition { my ($self, $hyp) = @_; $hyp ||= $self->current_hypothesis; @@ -38,6 +40,7 @@ sub new_for { ) : ( is_solution_state => 1 ) ), + on_exhaustion_step => undef, ); } diff --git a/lib/DX/Step/Backtrack.pm b/lib/DX/Step/Backtrack.pm index 8e3b5d8..3306fc3 100644 --- a/lib/DX/Step/Backtrack.pm +++ b/lib/DX/Step/Backtrack.pm @@ -7,7 +7,7 @@ with 'DX::Role::Step'; sub apply_to { my ($self, $ss) = @_; my ($first_alt, @rest_alt) = @{$ss->alternatives}; - return $ss->but(next_step => undef) unless $first_alt; + return $ss->but(next_step => $ss->on_exhaustion_step) unless $first_alt; trace 'search.backtrack.rewind_to' => $first_alt->[1]; return $ss->but( current_hypothesis => $first_alt->[0],