diff --git a/hyperon-wam.vpj b/hyperon-wam.vpj index e88e8d1628d..03c0cd5b917 100755 --- a/hyperon-wam.vpj +++ b/hyperon-wam.vpj @@ -67,6 +67,8 @@ Name="Other Files" Filters=""> + + @@ -116,6 +118,13 @@ Excludes=".git/;*.metta.html;*.bak;build/;.*/;*~*/" L="1"/> + + + - - diff --git a/hyperon-wam.vpw b/hyperon-wam.vpw index 87195c74bc5..5a831624753 100755 --- a/hyperon-wam.vpw +++ b/hyperon-wam.vpw @@ -5,5 +5,6 @@ + diff --git a/src/canary/metta_corelib.pl b/src/canary/metta_corelib.pl index 682c7d4f78d..ed84feb9108 100755 --- a/src/canary/metta_corelib.pl +++ b/src/canary/metta_corelib.pl @@ -108,12 +108,12 @@ metta_atom_corelib_types( [:, 'Error', [->, 'Atom', 'Atom', 'ErrorType']]). -metta_atom_corelib_types( [:, 'add-atom', [->, 'Space', 'Atom', [->]]]). +metta_atom_corelib_types( [:, 'add-atom', [->, 'hyperon::space::DynSpace', 'Atom', [->]]]). metta_atom_corelib_types( [:, 'car-atom', [->, 'Expression', 'Atom']]). metta_atom_corelib_types( [:, 'cdr-atom', [->, 'Expression', 'Expression']]). metta_atom_corelib_types( [:, 'filter-atom', [->, 'Expression', 'Variable', 'Atom', 'Expression']]). metta_atom_corelib_types( [:, 'foldl-atom', [->, 'Expression', 'Atom', 'Variable', 'Variable', 'Atom', 'Atom']]). -metta_atom_corelib_types( [:, 'get-atoms', [->, 'Space', 'Atom']]). +metta_atom_corelib_types( [:, 'get-atoms', [->, 'hyperon::space::DynSpace', 'Atom']]). metta_atom_corelib_types( [:, 'if-decons', [->, 'Atom', 'Variable', 'Variable', 'Atom', 'Atom', 'Atom']]). metta_atom_corelib_types( [:, 'if-empty', [->, 'Atom', 'Atom', 'Atom', 'Atom']]). metta_atom_corelib_types( [:, 'if-error', [->, 'Atom', 'Atom', 'Atom', 'Atom']]). @@ -121,7 +121,7 @@ metta_atom_corelib_types( [:, 'if-not-reducible', [->, 'Atom', 'Atom', 'Atom', 'Atom']]). metta_atom_corelib_types( [:, 'let*', [->, 'Expression', 'Atom', 'Atom']]). metta_atom_corelib_types( [:, 'map-atom', [->, 'Expression', 'Variable', 'Atom', 'Expression']]). -metta_atom_corelib_types( [:, 'remove-atom', [->, 'Space', 'Atom', [->]]]). +metta_atom_corelib_types( [:, 'remove-atom', [->, 'hyperon::space::DynSpace', 'Atom', [->]]]). metta_atom_corelib_types( [:, 'return-on-error', [->, 'Atom', 'Atom', 'Atom']]). metta_atom_corelib_types( [:, and, [->, 'Bool', 'Bool', 'Bool']]). metta_atom_corelib_types( [:, apply, [->, 'Atom', 'Variable', 'Atom', 'Atom']]). @@ -285,12 +285,14 @@ use_corelib_file:- using_corelib_file,!. use_corelib_file:- asserta(using_corelib_file), fail. -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'),!. +use_corelib_file:- load_corelib_file. +load_corelib_file:- is_metta_src_dir(Dir), really_use_corelib_file(Dir,'corelib.metta'),!. +load_corelib_file:- is_metta_src_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)]), - locally(nb_setval(may_use_fast_buffer,t), - include_metta_directory_file('&corelib',Dir,Filename)). + locally(nb_setval(may_use_fast_buffer,t), + locally(nb_setval(suspend_answers,true), + with_output_to(string(_),include_metta_directory_file('&corelib',Dir,Filename)))). %:- initialization(use_corelib_file). diff --git a/src/canary/metta_interp.pl b/src/canary/metta_interp.pl index 020704c4c26..ffcb395be28 100755 --- a/src/canary/metta_interp.pl +++ b/src/canary/metta_interp.pl @@ -425,6 +425,7 @@ :- dynamic(is_answer_output_stream/2). answer_output(Stream):- is_testing,original_user_output(Stream),!. +answer_output(Stream):- !,original_user_output(Stream),!. answer_output(Stream):- is_answer_output_stream(_,Stream),!. answer_output(Stream):- tmp_file('answers',File), open(File,write,Stream,[encoding(utf8)]), @@ -1067,9 +1068,13 @@ %metta_atom([Superpose,ListOf], Atom):- Superpose == 'superpose',is_list(ListOf),!,member(KB,ListOf),get_metta_atom_from(KB,Atom). metta_atom(Space, Atom):- typed_list(Space,_,L),!, member(Atom,L). metta_atom(KB, [F, A| List]):- KB=='&flybase',fb_pred_nr(F, Len),current_predicate(F/Len), length([A|List],Len),apply(F,[A|List]). -metta_atom(KB,Atom):- KB=='&corelib',!, metta_atom_corelib(Atom). +%metta_atom(KB,Atom):- KB=='&corelib',!, metta_atom_corelib(Atom). metta_atom(KB,Atom):- metta_atom_in_file( KB,Atom). metta_atom(KB,Atom):- metta_atom_asserted( KB,Atom). +metta_atom(KB,Atom):- KB \== '&corelib', !, should_inherit_from_corelib(Atom), metta_atom('&corelib',Atom). +should_inherit_from_corelib([H|_]):- nonvar(H),should_inherit_op_from_corelib(H). +should_inherit_op_from_corelib('='). +should_inherit_op_from_corelib(':'). metta_atom_asserted('&self','&corelib'). metta_atom_asserted('&self','&stdlib'). @@ -1093,13 +1098,15 @@ %metta_atom(KB,[F,A|List]):- metta_atom(KB,F,A,List), F \== '=',!. is_metta_space(Space):- \+ \+ is_space_type(Space,_Test). -metta_eq_def(Eq,KB,Head,Body):- ignore(Eq = '='), metta_atom(KB,[Eq,Head,Body]). +metta_eq_def(Eq,KB,H,B):- ignore(Eq = '='),if_or_else(metta_atom(KB,[Eq,H,B]),metta_atom_corelib(KB,[Eq,H,B])). -metta_defn(KB,Head,Body):- metta_eq_def(_Eq,KB,Head,Body). -metta_type(KB,H,B):- if_or_else(metta_atom(KB,[':',H,B]),metta_atom_corelib([':',H,B])). +%metta_defn(KB,Head,Body):- metta_eq_def(_Eq,KB,Head,Body). +metta_defn(KB,H,B):- metta_eq_def('=',KB,H,B). +metta_type(KB,H,B):- metta_eq_def(':',KB,H,B). %metta_type(S,H,B):- S == '&corelib', metta_atom_stdlib_types([':',H,B]). %typed_list(Cmpd,Type,List):- compound(Cmpd), Cmpd\=[_|_], compound_name_arguments(Cmpd,Type,[List|_]),is_list(List). +metta_atom_corelib(KB,Atom):- KB\='&corelib',!,metta_atom('&corelib',Atom). %maybe_xform(metta_atom(KB,[F,A|List]),metta_atom(KB,F,A,List)):- is_list(List),!. maybe_xform(metta_eq_def(Eq,KB,Head,Body),metta_atom(KB,[Eq,Head,Body])). diff --git a/src/canary/metta_loader.pl b/src/canary/metta_loader.pl index 43b82a32725..483a6ff4a7b 100755 --- a/src/canary/metta_loader.pl +++ b/src/canary/metta_loader.pl @@ -564,9 +564,13 @@ set_exec_num(Filename,0))), load_metta_file_stream_fast(Size,P2,Filename,Self,In)))). -% use_fast_buffer makes tmp .buffer.pl files that get around long load times +% use_fast_buffer makes tmp .buffer files that get around long load times use_fast_buffer:- nb_current(may_use_fast_buffer,t). +:- dynamic(metta_file_buffer/5). +:- multifile(metta_file_buffer/5). + + load_metta_file_stream_fast(_Size,_P2,Filename,Self,S):- fail, symbolic_list_concat([_,_,_|_],'.',Filename), \+ option_value(html,true), @@ -576,12 +580,9 @@ accept_line(Self,I), I==end_of_file,!. -:- dynamic(metta_file_buffer/5). -:- multifile(metta_file_buffer/5). - load_metta_file_stream_fast(_Size, _P2, Filename, Self, _In) :- use_fast_buffer, - symbol_concat(Filename, '.buffer.pl', BufferFile), + symbol_concat(Filename, '.buffer~', BufferFile), exists_file(BufferFile), time_file(Filename, FileTime), time_file(BufferFile, BufferFileTime), @@ -592,7 +593,7 @@ load_metta_file_stream_fast(_Size,P2,Filename,Self,In):- if_t(use_fast_buffer, - ((symbol_concat(Filename, '.buffer.pl', BufferFile), + ((symbol_concat(Filename, '.buffer~', BufferFile), fbugio(creating(BufferFile)), write_bf(BufferFile, ( :- dynamic(metta_file_buffer/5))), write_bf(BufferFile, ( :- multifile(metta_file_buffer/5)))))), diff --git a/src/canary/stdlib_mettalog.metta b/src/canary/stdlib_mettalog.metta index 9858cbf64a0..838135aad46 100755 --- a/src/canary/stdlib_mettalog.metta +++ b/src/canary/stdlib_mettalog.metta @@ -8,6 +8,8 @@ (: = (-> $t $t Atom)) ;; Implemented from Interpreters +(: ALT= (-> Atom Atom Atom)) + ; Public MeTTa (@doc ErrorType (@desc "Type of the atom which contains error")) (: ErrorType Type) @@ -660,7 +662,7 @@ ;; Public MeTTa? -(:> Space Grounded) +(:> hyperon::space::DynSpace Grounded) ;; Public MeTTa (@doc add-reduct @@ -676,7 +678,7 @@ (@param "Atom to add"))) (@return "Unit atom")) -(: add-reduct-rust1 (-> Space %Undefined% (->))) +(: add-reduct-rust1 (-> hyperon::space::DynSpace %Undefined% (->))) (= (add-reduct-minimal $dst $atom) (add-atom $dst $atom)) ;; Public MeTTa (: add-reduct (-> Grounded %Undefined% (->)))