Skip to content

Commit b8c66ec

Browse files
committed
clearer printing
1 parent 2707977 commit b8c66ec

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

prolog/metta_lang/metta_eval.pl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@
10711071
nonvar(F),atom(F),
10721072
ast_to_prolog_aux(no_caller,fn_impl(F,Args,Res),Head),
10731073
ast_to_prolog_aux(Head,Body,Body1),
1074-
print_tree_nl(Head:-Body1)))).
1074+
ppt(Head:-Body1)))).
10751075

10761076

10771077
is_like_eval_20(E20):- atom(E20),atom_concat(eval,_,E20),
@@ -1124,11 +1124,12 @@
11241124
maplist(println_impl,Out),
11251125
make_nop(RetType,[],Res),check_returnval(Eq,RetType,Res).
11261126

1127-
println_impl(X):- ttyflush,user_io((format("~N~@~N",[write_sln(X)]))),!,flush_output,ttyflush.
1127+
println_impl(X):- ttyflush,
1128+
user_io((format("~N"),write_sln(X),format("~N"))),flush_output,ttyflush.
11281129
%println_impl(X):- user_io((ansi_format(fg('#c7ea46'),"~N~@~N",[write_sln(X)]))),flush_output.
11291130
%println_impl(X):- ((ansi_format(fg('#c7ea46'),"~N~@~N",[write_sln(X)]))),flush_output.
11301131

1131-
princ_impl(X):- format("~@",[write_sln(X)]),!,flush_output.
1132+
princ_impl(X):- user_io((write_sln(X))),flush_output,ttyflush.
11321133

11331134
write_sln(X):- string(X), !, write(X),flush_output.
11341135
write_sln(X):- write_src_woi(X),flush_output.
@@ -1946,6 +1947,7 @@
19461947
eval_20(_Eq,_RetType,_Depth,_Self,['decons',OneArg],[H,T]):- !, must_unify(OneArg,[H|T]).
19471948
eval_20(_Eq,_RetType,_Depth,_Self,['cons'|TwoArgs],[H|T]):-!, must_unify(TwoArgs,[H,T]).
19481949

1950+
should_be(P1,Term):- call(P1,Term)-> true ; (debug_info(porting,hyperon_throws_error(should_be(P1,Term))),fail).
19491951

19501952
%eval_20(Eq,RetType,Depth,Self,['get-doc'|Args],Res):- !,with_all_spaces(eval_args(Eq,RetType,Depth,Self,['metta-get-doc'|Args],Res)),!.
19511953
%eval_20(Eq,RetType,Depth,Self,['help!'|Args],Res):-!,with_all_spaces(eval_args(Eq,RetType,Depth,Self,['metta-help!'|Args],Res)),!.
@@ -3112,10 +3114,13 @@
31123114

31133115

31143116
eval_20(_Eq,_RetType,_Depth,_Self,['call-string!',Str],NoResult):- !,'call-string!'(Str,NoResult).
3117+
eval_40(_Eq,_RetType,_Depth,_Self,['call-string',Str],NoResult):- !,'call-string!'(Str,NoResult).
31153118

31163119
'call-string!'(Str,NoResult):-
31173120
read_term_from_atom(Str,Term,[variables(Vars)]),!,
3118-
call(Term),NoResult=Vars.
3121+
stream_property(Err, file_no(2)),
3122+
user_io(with_output_to(Err,(format('~N'),call(Term),format('~N')))),
3123+
NoResult=Vars.
31193124

31203125

31213126
/*
@@ -3422,7 +3427,7 @@
34223427
% Constructs a compound term for the Python function call with adjusted arguments.
34233428
compound_name_arguments(Call, PyFun, Adjusted),
34243429
% Optionally prints a debug tree of the Python call if tracing is enabled.
3425-
if_trace(host;python, print_tree(py_call(PyModule:Call, RetVal))),
3430+
if_trace(host;python, ppt(py_call(PyModule:Call, RetVal))),
34263431
% Executes the Python function call and captures the result in MVal which propagates to RetVal.
34273432
py_call(PyModule:Call, MVal),
34283433
% Checks the return value against the expected type and criteria.
@@ -3444,7 +3449,7 @@
34443449
%fake_notrace( \+ is_user_defined_goal(Self,[AE|More])),!,
34453450
% adjust_args(Depth,Self,AE,More,Adjusted),
34463451
maplist(as_prolog_x(Depth,Self), More , Adjusted),
3447-
if_trace(host;prolog;e,print_tree(apply(Pred,Adjusted))),
3452+
if_trace(host;prolog;e,ppt(apply(Pred,Adjusted))),
34483453
with_metta_ctx(Eq,RetType,Depth,Self,[AE|More],catch_warn(efbug(show_call,eval_call(apply(Pred,Adjusted),TF)))),
34493454
check_returnval(Eq,RetType,TF).
34503455

@@ -3519,7 +3524,7 @@
35193524
%current_predicate(Pred/Len1),
35203525
maplist(as_prolog_x(Depth,Self),More,Adjusted),
35213526
append(Adjusted,[Res],Args),!,
3522-
if_trace(host;prolog,print_tree(apply(Pred,Args))),
3527+
if_trace(host;prolog,ppt(apply(Pred,Args))),
35233528
with_metta_ctx(Eq,RetType,Depth,Self,[AE|More],efbug(show_call,catch_warn(apply(Pred,Args)))),
35243529
check_returnval(Eq,RetType,Res).
35253530

0 commit comments

Comments
 (0)