Skip to content

Commit ec5fed2

Browse files
committed
print outputs much closer to H-E
1 parent 7751c26 commit ec5fed2

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

prolog/metta_lang/metta_interp.pl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,9 @@
12961296

12971297

12981298

1299-
1299+
assert_preds('&corelib',_Load, _Clause):- !.
13001300
assert_preds(Self,Load,List):- is_list(List),!,maplist(assert_preds(Self,Load),List).
1301+
assert_preds(_Self,_Load,Clause):- compiler_assertz(Clause),!.
13011302
%assert_preds(_Self,_Load,_Preds):- \+ show_transpiler,!.
13021303
assert_preds(Self,Load,Preds):-
13031304
expand_to_hb(Preds,H,_B),
@@ -1370,16 +1371,24 @@
13701371
assertion_neck_cl(':-').
13711372

13721373

1373-
load_hook0(_,_):- \+ show_transpiler, !. % \+ is_transpiling, !.
1374+
%load_hook0(_,_):- \+ show_transpiler, !. % \+ is_transpiling, !.
1375+
1376+
13741377
load_hook0(Load,Assertion):- assertion_hb(Assertion,Self,Eq,H,B),
1378+
load_hook1(Load,Self,Eq,H,B).
1379+
1380+
load_hook1(_Load,'&corelib',_Eq,_H,_B):-!.
1381+
load_hook1(Load,Self,Eq,H,B):-
13751382
once(functs_to_preds([Eq,H,B],Preds)),
13761383
assert_preds(Self,Load,Preds),!.
13771384
% old compiler hook
1385+
/*
13781386
load_hook0(Load,Assertion):-
13791387
assertion_hb(Assertion,Self, Eq, H,B),
13801388
rtrace_on_error(compile_for_assert_eq(Eq, H, B, Preds)),!,
13811389
rtrace_on_error(assert_preds(Self,Load,Preds)).
13821390
load_hook0(_,_):- \+ current_prolog_flag(metta_interp,ready),!.
1391+
*/
13831392
/*
13841393
load_hook0(Load,get_metta_atom(Eq,Self,H)):- B = 'True',
13851394
H\=[':'|_], functs_to_preds([=,H,B],Preds),
@@ -1611,8 +1620,8 @@
16111620
write_exec0(Exec):-
16121621
wots(S,write_src(exec(Exec))),
16131622
nb_setval(exec_src,Exec),
1614-
format('~N'),
1615-
output_language(metta,ignore((notrace((color_g_mesg('#0D6328',writeln(S))))))).
1623+
not_compatio((format('~N'),
1624+
output_language(metta,ignore((notrace((color_g_mesg('#0D6328',writeln(S))))))))).
16161625

16171626
%!(let* (( ($a $b) (collapse (get-atoms &self)))) ((bind! &stdlib $a) (bind! &corelib $b)))
16181627

@@ -2202,7 +2211,7 @@
22022211
test_alarm,
22032212
run_cmd_args,
22042213
write_answer_output,
2205-
maybe_halt(7)]))),!.
2214+
not_compat_io(maybe_halt(7))]))),!.
22062215

22072216
need_interaction:- \+ option_value('had_interaction',true),
22082217
\+ is_converting, \+ is_compiling, \+ is_pyswip,!,

prolog/metta_lang/metta_repl.pl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@
11421142
Prev = prev_result('Empty'),
11431143

11441144
% Print formatted answer output
1145-
in_answer_io(format('~n[')))),!,
1145+
in_answer_io(format('~N[')))),!,
11461146

11471147
% Interactive looping with possible timing and stepping control
11481148
(
@@ -1204,7 +1204,7 @@
12041204

12051205
),
12061206

1207-
in_answer_io((write(']'),if_t(\+is_mettalog,nl))),
1207+
in_answer_io((write(']\n'),if_t(\+is_mettalog, nop(nl)))),
12081208
flag(need_prompt,_,1),
12091209
ignore(Result = res(FOut)).
12101210

@@ -1227,11 +1227,11 @@
12271227

12281228
output_language(answers,(if_t(ResNum=<Max,
12291229
(
1230-
(((ResNum==1,Complete==true)->(old_not_compatio(format('~N~nDeterministic: ', [])), !); %or Nondet
1230+
(((ResNum==1,Complete==true)->(not_compatio(format('~N~nDeterministic: ', [])), !); %or Nondet
12311231
/* previously: handle deterministic result output */
1232-
(Complete==true -> (old_not_compatio(format('~N~nR(~w): ',[ResNum])),! );
1233-
old_not_compatio(format('~N~nN(~w): ',[ResNum]))))),
1234-
ignore(((
1232+
(Complete==true -> (not_compatio(format('~N~nR(~w): ',[ResNum])),! );
1233+
not_compatio(format('~N~nN(~w): ',[ResNum]))))),
1234+
not_compatio(ignore(((
12351235
if_t( \+ symbolic(Output), not_compatio(nop(nl))),
12361236
%if_t(ResNum==1,in_answer_io(format('~N['))),
12371237
% user_io
@@ -1240,7 +1240,7 @@
12401240
\+ \+
12411241
(maybe_name_vars(NamedVarsList),
12421242
old_not_compatio(write_bsrc(Output)),
1243-
true)))) )) ))))),
1243+
true)))) )) )))))),
12441244

12451245
in_answer_io(write_asrc((Output))),
12461246

@@ -1796,7 +1796,7 @@
17961796
% Print the compiled goal with formatting.
17971797
Call = do_metta_runtime(Res, Goal),
17981798
output_language(prolog, notrace((color_g_mesg('#114411', print_pl_source(:- Call))))),
1799-
call(Call).
1799+
nop(call(Call)).
18001800

18011801

18021802
%! verbose_unify(+Term) is det.

prolog/metta_lang/metta_subst.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
set_last_error(_).
257257
258258
*/
259-
subst_args1(Eq,RetType,Depth, Self, [OP|ARGS], Template):-
259+
subst_args1(Eq,RetType,Depth, Self, [OP|ARGS], Template):-
260260
is_space_op(OP), !,
261261
subst_args_as(Depth, Self, [OP|ARGS], Template).
262262

prolog/metta_lang/metta_testing.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@
743743
!.
744744
test_alarm :-
745745
% Set time limit and attempt goal within 0.5 seconds.
746-
time(catch(
746+
(catch(
747747
% Run goal with time limit; fail if it exceeds limit.
748748
(call_with_time_limit(0.5,
749749
(forall(between(1, 15, _), sleep(0.1)),

0 commit comments

Comments
 (0)