From ec5fed2c3d6cb556750a366b2b5f3eacd62545c1 Mon Sep 17 00:00:00 2001 From: logicmoo Date: Tue, 24 Dec 2024 03:15:23 -0800 Subject: [PATCH] print outputs much closer to H-E --- prolog/metta_lang/metta_interp.pl | 19 ++++++++++++++----- prolog/metta_lang/metta_repl.pl | 16 ++++++++-------- prolog/metta_lang/metta_subst.pl | 2 +- prolog/metta_lang/metta_testing.pl | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/prolog/metta_lang/metta_interp.pl b/prolog/metta_lang/metta_interp.pl index 05c91fbf70..455cf286ec 100755 --- a/prolog/metta_lang/metta_interp.pl +++ b/prolog/metta_lang/metta_interp.pl @@ -1296,8 +1296,9 @@ - +assert_preds('&corelib',_Load, _Clause):- !. assert_preds(Self,Load,List):- is_list(List),!,maplist(assert_preds(Self,Load),List). +assert_preds(_Self,_Load,Clause):- compiler_assertz(Clause),!. %assert_preds(_Self,_Load,_Preds):- \+ show_transpiler,!. assert_preds(Self,Load,Preds):- expand_to_hb(Preds,H,_B), @@ -1370,16 +1371,24 @@ assertion_neck_cl(':-'). -load_hook0(_,_):- \+ show_transpiler, !. % \+ is_transpiling, !. +%load_hook0(_,_):- \+ show_transpiler, !. % \+ is_transpiling, !. + + load_hook0(Load,Assertion):- assertion_hb(Assertion,Self,Eq,H,B), + load_hook1(Load,Self,Eq,H,B). + +load_hook1(_Load,'&corelib',_Eq,_H,_B):-!. +load_hook1(Load,Self,Eq,H,B):- once(functs_to_preds([Eq,H,B],Preds)), assert_preds(Self,Load,Preds),!. % old compiler hook +/* load_hook0(Load,Assertion):- assertion_hb(Assertion,Self, Eq, H,B), rtrace_on_error(compile_for_assert_eq(Eq, H, B, Preds)),!, rtrace_on_error(assert_preds(Self,Load,Preds)). load_hook0(_,_):- \+ current_prolog_flag(metta_interp,ready),!. +*/ /* load_hook0(Load,get_metta_atom(Eq,Self,H)):- B = 'True', H\=[':'|_], functs_to_preds([=,H,B],Preds), @@ -1611,8 +1620,8 @@ write_exec0(Exec):- wots(S,write_src(exec(Exec))), nb_setval(exec_src,Exec), - format('~N'), - output_language(metta,ignore((notrace((color_g_mesg('#0D6328',writeln(S))))))). + not_compatio((format('~N'), + output_language(metta,ignore((notrace((color_g_mesg('#0D6328',writeln(S))))))))). %!(let* (( ($a $b) (collapse (get-atoms &self)))) ((bind! &stdlib $a) (bind! &corelib $b))) @@ -2202,7 +2211,7 @@ test_alarm, run_cmd_args, write_answer_output, - maybe_halt(7)]))),!. + not_compat_io(maybe_halt(7))]))),!. need_interaction:- \+ option_value('had_interaction',true), \+ is_converting, \+ is_compiling, \+ is_pyswip,!, diff --git a/prolog/metta_lang/metta_repl.pl b/prolog/metta_lang/metta_repl.pl index d91ebe034d..8749ec1a71 100755 --- a/prolog/metta_lang/metta_repl.pl +++ b/prolog/metta_lang/metta_repl.pl @@ -1142,7 +1142,7 @@ Prev = prev_result('Empty'), % Print formatted answer output - in_answer_io(format('~n[')))),!, + in_answer_io(format('~N[')))),!, % Interactive looping with possible timing and stepping control ( @@ -1204,7 +1204,7 @@ ), - in_answer_io((write(']'),if_t(\+is_mettalog,nl))), + in_answer_io((write(']\n'),if_t(\+is_mettalog, nop(nl)))), flag(need_prompt,_,1), ignore(Result = res(FOut)). @@ -1227,11 +1227,11 @@ output_language(answers,(if_t(ResNum=(old_not_compatio(format('~N~nDeterministic: ', [])), !); %or Nondet + (((ResNum==1,Complete==true)->(not_compatio(format('~N~nDeterministic: ', [])), !); %or Nondet /* previously: handle deterministic result output */ - (Complete==true -> (old_not_compatio(format('~N~nR(~w): ',[ResNum])),! ); - old_not_compatio(format('~N~nN(~w): ',[ResNum]))))), - ignore((( + (Complete==true -> (not_compatio(format('~N~nR(~w): ',[ResNum])),! ); + not_compatio(format('~N~nN(~w): ',[ResNum]))))), + not_compatio(ignore((( if_t( \+ symbolic(Output), not_compatio(nop(nl))), %if_t(ResNum==1,in_answer_io(format('~N['))), % user_io @@ -1240,7 +1240,7 @@ \+ \+ (maybe_name_vars(NamedVarsList), old_not_compatio(write_bsrc(Output)), - true)))) )) ))))), + true)))) )) )))))), in_answer_io(write_asrc((Output))), @@ -1796,7 +1796,7 @@ % Print the compiled goal with formatting. Call = do_metta_runtime(Res, Goal), output_language(prolog, notrace((color_g_mesg('#114411', print_pl_source(:- Call))))), - call(Call). + nop(call(Call)). %! verbose_unify(+Term) is det. diff --git a/prolog/metta_lang/metta_subst.pl b/prolog/metta_lang/metta_subst.pl index dca4c5c256..32cda78180 100755 --- a/prolog/metta_lang/metta_subst.pl +++ b/prolog/metta_lang/metta_subst.pl @@ -256,7 +256,7 @@ set_last_error(_). */ -subst_args1(Eq,RetType,Depth, Self, [OP|ARGS], Template):- +subst_args1(Eq,RetType,Depth, Self, [OP|ARGS], Template):- is_space_op(OP), !, subst_args_as(Depth, Self, [OP|ARGS], Template). diff --git a/prolog/metta_lang/metta_testing.pl b/prolog/metta_lang/metta_testing.pl index 18e75b384a..d6e295bf71 100755 --- a/prolog/metta_lang/metta_testing.pl +++ b/prolog/metta_lang/metta_testing.pl @@ -743,7 +743,7 @@ !. test_alarm :- % Set time limit and attempt goal within 0.5 seconds. - time(catch( + (catch( % Run goal with time limit; fail if it exceeds limit. (call_with_time_limit(0.5, (forall(between(1, 15, _), sleep(0.1)),