|
4151 | 4151 | % ?- load_hook1(my_load, '&corelib', '=', head, body). |
4152 | 4152 |
|
4153 | 4153 | % load_hook1(_Load, '&corelib', _Eq, _H, _B) :- !. |
4154 | | -load_hook1(Load, Self, Fact) :- |
4155 | | - % Skip processing if the `metta_interp` flag is not set to `ready`. |
4156 | | - % \+ is_metta_interp_ready, |
4157 | | - % debug_info(assert_hooks,load_hook_not_ready(Load, Self, Fact)), |
4158 | | - %fail, |
4159 | | - !, |
4160 | | - woc(load_hook_compiler(Load, Self, Fact)). |
| 4154 | + |
| 4155 | +load_hook1(_Load, Self, [Eq,H,B]) :- |
| 4156 | + Eq == '=', assertz_if_new(metta_function_asserted(Self,H,B)),fail. |
| 4157 | + |
4161 | 4158 |
|
4162 | 4159 | load_hook1(Load, Self, Fact) :- |
4163 | 4160 | % Ensure the Metta compiler is ready for use. |
|
4166 | 4163 | woc(load_hook_compiler(Load, Self, Fact)). |
4167 | 4164 | load_hook1(Load, Self, Fact):- |
4168 | 4165 | %debug_info(assert_hooks,not_use_metta_compiler(Load, Self, Fact)), |
| 4166 | + woc(load_hook_compiler(Load, Self, Fact)),!. |
| 4167 | +load_hook1(Load, Self, Fact) :- |
| 4168 | + % Skip processing if the `metta_interp` flag is not set to `ready`. |
| 4169 | + % \+ is_metta_interp_ready, |
| 4170 | + % debug_info(assert_hooks,load_hook_not_ready(Load, Self, Fact)), |
| 4171 | + %fail, |
| 4172 | + !, |
4169 | 4173 | woc(load_hook_compiler(Load, Self, Fact)). |
4170 | 4174 |
|
4171 | 4175 | metta_atom_asserted_hook(Self,Assertion):- |
|
4450 | 4454 | % @arg X The context or space. |
4451 | 4455 | % @arg Y The atom to check. |
4452 | 4456 | % |
| 4457 | +dont_bother(Atom):- Atom=@=[_, :, _]. |
| 4458 | +dont_bother(Atom):- Atom=@=[=, [_, _], _]. % maybe |
| 4459 | +dont_bother(Atom):- Atom=@=[=, [_, _, _], _]. |
| 4460 | +dont_bother(Atom):- Atom = [V1, [Colon, Thing, V2], V3], Colon==':', nonvar(Thing),maplist(var,[V1,V2,V3]). |
| 4461 | + |
| 4462 | +metta_atom_added(_KB, Atom) :- dont_bother(Atom),!,fail. |
| 4463 | +metta_atom_added(X, [Eq,A,B]) :- Eq =='=', !, |
| 4464 | + woct(metta_function_asserted(X,A,B)). |
| 4465 | + |
4453 | 4466 | metta_atom_added(X, Y) :- nocut, |
4454 | 4467 | % Check if the atom was explicitly asserted. |
4455 | 4468 | metta_atom_asserted_ocw(X, Y). |
|
4491 | 4504 | transform_about(Fact, Rule, Cond), Cond=='True',!, |
4492 | 4505 | fact_store(KB, Rule, Fact, Cond). |
4493 | 4506 | */ |
4494 | | -dont_bother(Atom):- Atom=@=[_, :, _]. |
4495 | | -dont_bother(Atom):- Atom=@=[=, [_, _, _], _]. |
4496 | | -dont_bother(Atom):- Atom=@=[=, [_, _], _]. % maybe |
4497 | | -dont_bother(Atom):- Atom = [V1, [Colon, Thing, V2], V3], Colon==':', nonvar(Thing),maplist(var,[V1,V2,V3]). |
4498 | 4507 |
|
4499 | 4508 | metta_atom0(_Inherit,_KB, Atom) :- dont_bother(Atom),!,fail. |
4500 | 4509 |
|
|
4801 | 4810 | % metta_eq_def(Eq,KB,H,B):- ignore(Eq = '='),metta_atom(KB,[Eq,H,B]). |
4802 | 4811 | metta_eq_def(Eq, KB, H, B) :- |
4803 | 4812 | ignore(Eq = '='), |
4804 | | - metta_atom0(inherit([KB]),KB,[EQ, H, B]), |
4805 | | - EQ == Eq. |
| 4813 | + metta_atom0(inherit([KB]),KB,[Eq, H, B]). |
4806 | 4814 |
|
4807 | 4815 | % Original commented-out code, retained as-is for potential future use: |
4808 | 4816 | % metta_defn(KB,Head,Body):- metta_eq_def(_Eq,KB,Head,Body). |
|
0 commit comments