diff --git a/src/canary/metta_corelib.pl b/src/canary/metta_corelib.pl index ce3c7f0aabf..70dfac56750 100755 --- a/src/canary/metta_corelib.pl +++ b/src/canary/metta_corelib.pl @@ -22,6 +22,9 @@ :- discontiguous metta_atom_corelib_types/1. +:- dynamic(using_corelib_file/0). + + metta_atom_corelib_defn( [=, ['car-atom', A], [eval, ['if-decons', A, B, _, B, ['Error', ['car-atom', A], "car-atom expects a non-empty expression as an argument"]]]]). metta_atom_corelib_defn( [=, ['cdr-atom', A], [eval, ['if-decons', A, _, B, B, ['Error', ['cdr-atom', A], "cdr-atom expects a non-empty expression as an argument"]]]]). metta_atom_corelib_defn( [=, ['filter-atom', A, B, C], [function, [eval, ['if-decons', A, D, E, [chain, [eval, ['filter-atom', E, B, C]], F, [chain, [eval, [apply, D, B, C]], G, [chain, G, H, [eval, [if, H, [chain, [cons, D, F], I, [return, I]], [return, F]]]]]], [return, []]]]]]). @@ -280,4 +283,15 @@ :- multifile(metta_atom_asserted_deduced/2). metta_atom_asserted_deduced('&corelib', Term):- metta_atom_corelib_types(Term). +use_corelib_file:- using_corelib_file,!. +use_corelib_file:- asserta(using_corelib_file), fail. +use_corelib_file:- !. +use_corelib_file:- is_metta_dir(Dir), really_use_corelib_file(Dir,'corelib.metta'),!. +use_corelib_file:- is_metta_dir(Dir), really_use_corelib_file(Dir,'stdlib_mettalog.metta'),!. +% !(import! &corelib "src/canary/stdlib_mettalog.metta") +really_use_corelib_file(Dir,File):- absolute_file_name(File,Filename,[relative_to(Dir)]), + include_metta_directory_file('&corelib',Dir,Filename). + +%:- initialization(use_corelib_file). + diff --git a/src/canary/metta_eval.pl b/src/canary/metta_eval.pl index 9fa48b72f7e..ef3a059bcd4 100755 --- a/src/canary/metta_eval.pl +++ b/src/canary/metta_eval.pl @@ -2135,6 +2135,7 @@ :-if(true). +:- nodebug(metta('defn')). eval_maybe_defn(Eq,RetType,Depth,Self,X,Res):- \+ \+ (curried_arity(X,F,A), @@ -2145,7 +2146,7 @@ \+ fail_on_constructor, eval_constructor(Eq,RetType,Depth,Self,X,Res). eval_maybe_defn(Eq,RetType,Depth,Self,X,Y):- can_be_ok(eval_maybe_defn,X),!, - trace_eval(eval_defn_choose_candidates(Eq,RetType),' find_defn ',Depth,Self,X,Y). + trace_eval(eval_defn_choose_candidates(Eq,RetType),'defn',Depth,Self,X,Y). eval_constructor(Eq,RetType,Depth,Self,X,Res):- eval_maybe_subst(Eq,RetType,Depth,Self,X,Res). @@ -2185,7 +2186,7 @@ :-else. eval_maybe_defn(Eq,RetType,Depth,Self,X,Y):- can_be_ok(eval_maybe_defn,X),!, - trace_eval(eval_defn_choose_candidates(Eq,RetType),' find_defn ',Depth,Self,X,Y). + trace_eval(eval_defn_choose_candidates(Eq,RetType),'defn',Depth,Self,X,Y). eval_defn_choose_candidates(Eq,RetType,Depth,Self,X,Y):- findall((XX->B0),get_defn_expansions(Eq,RetType,Depth,Self,X,XX,B0),XXB0L), diff --git a/src/canary/metta_interp.pl b/src/canary/metta_interp.pl index 9d515fc539e..07414600036 100755 --- a/src/canary/metta_interp.pl +++ b/src/canary/metta_interp.pl @@ -1809,7 +1809,10 @@ %:- ensure_loaded(metta_python). +:- initialization(use_corelib_file). + :- ignore((( + use_corelib_file, (is_testing -> UNIT_TEST=true; UNIT_TEST=false), set_is_unit_test(UNIT_TEST), \+ prolog_load_context(reloading,true),