diff --git a/docs/yap.tex b/docs/yap.tex index 81c2a8b29..34e0902c0 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -7766,6 +7766,11 @@ procedures. If @code{on} compile predicates so that they will output profiling information. Profiling data can be read through the @code{profile_data/3} built-in. +@item prompt_alternatives_on(atom, changeable) +@findex prompt_alternatives_on (yap_flag/2 option) +SWI-Compatible opttion, determines prompting for alternatives in the Prolog toplevel. Default is @t{groundness}, YAP prompts for alternatives if and only if the query contains variables. The alternative, default in SWI-Prolog is @t{determinism} which implies the system prompts for alternatives if the goal succeeded while leaving choicepoints. + + @item redefine_warnings @findex discontiguous_warnings (yap_flag/2 option) @* diff --git a/pl/boot.yap b/pl/boot.yap index 9bd74a606..d805300d1 100755 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -475,7 +475,9 @@ true :- true. X == '$', !, ( recorded('$reconsulting',_,R) -> erase(R) ). - /* Executing a query */ +'$prompt_alternatives_on'(groundness). + +/* Executing a query */ '$query'(end_of_file,_). @@ -493,21 +495,31 @@ true :- true. % end of YAPOR - '$query'(G,[]) :- !, + '$query'(G,[]) :- + '$prompt_alternatives_on'(groundness), !, '$yes_no'(G,(?-)). '$query'(G,V) :- ( '$exit_system_mode', + yap_hacks:current_choice_point(CP), '$execute'(G), - ( '$enter_system_mode' ; '$exit_system_mode', fail), - '$output_frozen'(G, V, LGs), - '$write_answer'(V, LGs, Written), - '$write_query_answer_true'(Written), + yap_hacks:current_choice_point(NCP), + ( '$enter_system_mode' ; '$exit_system_mode', fail), + '$output_frozen'(G, V, LGs), + '$write_answer'(V, LGs, Written), + '$write_query_answer_true'(Written), + ( + '$prompt_alternatives_on'(determinism), CP = NCP -> + nl(user_error), + ! + ; '$another', - !, fail + ! + ), + fail ; - '$enter_system_mode', - '$out_neg_answer' + '$enter_system_mode', + '$out_neg_answer' ). '$yes_no'(G,C) :- diff --git a/pl/directives.yap b/pl/directives.yap index 3eac18043..88f6348e3 100644 --- a/pl/directives.yap +++ b/pl/directives.yap @@ -761,6 +761,18 @@ yap_flag(write_strings,off) :- !, yap_flag(write_strings,X) :- '$do_error'(domain_error(flag_value,write_strings+X),yap_flag(write_strings,X)). +yap_flag(prompt_alternatives_on,OUT) :- + var(OUT), !, + '$prompt_alternatives_on'(OUT). +yap_flag(prompt_alternatives_on,determinism) :- !, + '$purge_clauses'('$prompt_alternatives_on'(_),prolog), + '$compile'('$prompt_alternatives_on'(determinism),0,'$prompt_alternatives_on'(determinism),prolog). +yap_flag(prompt_alternatives_on,groundness) :- !, + '$purge_clauses'('$prompt_alternatives_on'(_),prolog), + '$compile'('$prompt_alternatives_on'(groundness),0,'$prompt_alternatives_on'(groundness),prolog). +yap_flag(prompt_alternatives_on,X) :- + '$do_error'(domain_error(flag_value,prompt_alternatives_on+X),yap_flag(prompt_alternatives_on,X)). + yap_flag(stack_dump_on_error,OUT) :- var(OUT), !, '$access_yap_flags'(17,X), @@ -933,6 +945,7 @@ yap_flag(dialect,yap). V = n_of_integer_keys_in_db ; V = open_expands_filename ; V = profiling ; + V = prompt_alternatives_on ; V = redefine_warnings ; V = shared_object_search_path ; V = single_var_warnings ;