Skip to content

Commit

Permalink
workarround for #219
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Dec 31, 2024
1 parent f7ff783 commit fcce533
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
82 changes: 41 additions & 41 deletions libraries/logicmoo_utils/prolog/logicmoo/util_varnames.pl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
dif_matrix/2,
term_singleslots/2,
term_singleslots/3,
term_singleslots/5,
term_singleslots/5,
set_varname/2,
set_varname/3,
write_functor/2,
Expand Down Expand Up @@ -67,7 +67,7 @@

no_varnaming/1,
no_vars_needed/1,

print_numbervars_maybe/1,
print_numbervars/1,
scan_for_varnames0/0,
Expand All @@ -93,7 +93,7 @@
try_get_inner_vars/1,
set_varname/2,
try_save_vars/1,

v_dif_rest/2,
vmust/1,
init_varname_stores/1,
Expand All @@ -103,7 +103,7 @@


/** <module> Utility LOGICMOO UTIL VARNAMES / Name Prolog variables (debugging)
This module holds utilities to access and change the names of prolog variables.
This module holds utilities to access and change the names of prolog variables.
- @author Douglas R. Miles
- @license LGPL
*/
Expand Down Expand Up @@ -156,15 +156,15 @@
get_clause_vars_copy/2,
get_clause_vars_hb_int/2,
imploded_copyvars/2,
locate_clause_ref/5,
locate_clause_ref/5,

listing_vars_file/0,
make_subterm_path/3,
maybe_record_scanned_file/0,
no_varnaming/1,
without_varname_scan/1,
no_vars_needed/1,

print_numbervars_maybe/1,
print_numbervars/1,
read_source_file_vars/1,
Expand All @@ -188,7 +188,7 @@
try_get_inner_vars/1,
set_varname/2,
try_save_vars/1,

v_dif_rest/2,
% name_variable/2, variable_name/2,
vmust/1,
Expand Down Expand Up @@ -237,7 +237,7 @@
%
member_open(C, [B|A]) :- (nonvar(B),B=C) ; (nonvar(A),member_open(C, A)).

%=
%=

%% source_variables_lwv( ?AllS) is det.
%
Expand Down Expand Up @@ -283,12 +283,12 @@
% Hook To [dom:attr_unify_hook/2] For Module Logicmoo_varnames.
% Attr Unify Hook.
%
vn:attr_unify_hook(X,Y):- ignore(quietly(must(vn_auh_0(X,Y)))).
vn:attr_unify_hook(X,Y):- ignore(quietly((vn_auh_0(X,Y)))).

vn_auh_0(_, Var):- cyclic_term(Var),!,fail.
vn_auh_0(Var,_):- cyclic_term(Var),!,fail.
vn_auh_0(Name1, Var):- when_var_locked(What),!,(unify_name_based(Name1, Var)->true;call(What,Var)).
vn_auh_0(Name1, Var):- var(Var),unify_name_based(Name1, Var),!.
vn_auh_0(_, Var):- cyclic_term(Var),!,fail.
%vn_auh_0(Var,_):- cyclic_term(Var),!,fail.
vn_auh_0(_Form, _OtherValue):-!.


Expand Down Expand Up @@ -339,11 +339,11 @@
% Portray Attribute Variable.
%
portray_attvar(Var) :-
write('{<'),
write('{<'),
((get_attr(Var,vn, VarName))->true;sformat(VarName,'~q',[Var])),
get_attrs(Var, Attr),
catch(writeq('??'(VarName,Attr)),_,'$attvar':portray_attrs(Attr, Var)),
write('>}').
get_attrs(Var, Attr),
catch(writeq('??'(VarName,Attr)),_,'$attvar':portray_attrs(Attr, Var)),
write('>}').
*/


Expand All @@ -353,14 +353,14 @@
% % % OFF :- system:use_module(library(when)).

:- prolog_clause:multifile((
unify_goal/5, % +Read, +Decomp, +M, +Pos, -Pos
unify_clause_hook/5,
make_varnames_hook/5,
open_source/2)). % +Input, -Stream
unify_goal/5, % +Read, +Decomp, +M, +Pos, -Pos
unify_clause_hook/5,
make_varnames_hook/5,
open_source/2)). % +Input, -Stream

:- predicate_options(prolog_clause:clause_info/5, 5,
[ variable_names(-list)
]).
[ variable_names(-list)
]).

% % % OFF :- system:use_module(library(prolog_source)).
% % % OFF :- system:use_module(library(prolog_clause)). % read_term_at_line/6
Expand Down Expand Up @@ -916,7 +916,7 @@
save_clause_vars(M,H,MB,B,Vs,Why:_):-atom(Why),!,save_clause_vars(M,H,MB,B,Vs,Why).
save_clause_vars(M,H,MB,B,Vs,Why):- fail, locate_clause_ref(M,H,MB,B,ClauseRef),clause_ref_vars(ClauseRef,Was),
((Was=Vs) -> fail ; save_to_clause_ref(ClauseRef,Vs,Why)),!.
save_clause_vars(_M,H,_MB,B,Vs,Why):-
save_clause_vars(_M,H,_MB,B,Vs,Why):-
ain00(varname_cache:varname_info(H,B,Vs,Why)).


Expand Down Expand Up @@ -1138,13 +1138,13 @@
%
% Source Variables.
%
source_variables(Vs):-
source_variables(Vs):-
(prolog_load_context(variable_names,Vs2);Vs2=[]),
execute_goal_vs(Vs1),
append(Vs1,Vs2,Vs3),list_to_set(Vs3,Vs),
(Vs\==Vs2 -> b_setval('$variable_names',Vs) ; true).

source_variables0(Vs):-
source_variables0(Vs):-
(prolog_load_context(variable_names,Vs2);Vs2=[]),
execute_goal_vs(Vs1),
append(Vs1,Vs2,Vs3),list_to_set(Vs3,Vs).
Expand Down Expand Up @@ -1219,7 +1219,7 @@
% Scan For Varnames.
%
scan_for_varnames:- thglobal:scanning_for_varnames_already,!.
scan_for_varnames:- %swc,
scan_for_varnames:- %swc,
setup_call_cleanup(
asserta(thglobal:scanning_for_varnames_already),
scan_for_varnames0,
Expand Down Expand Up @@ -1286,22 +1286,22 @@

read_source_vars(File,In):-
Module = module(_),
repeat,
catch(prolog_read_source_term(In, Term, Expanded, [ variable_names(Vs), syntax_errors(error) , term_position(TermPos) ]),
E,(nop((dmsg(E))),fail)),
repeat,
catch(prolog_read_source_term(In, Term, Expanded, [ variable_names(Vs), syntax_errors(error) , term_position(TermPos) ]),
E,(nop((dmsg(E))),fail)),
arg(1,Module,M),
(Term = module(MM,_) -> (nb_setarg(1,Module,MM),fail);
((stream_position_data(line_count, TermPos, LineNo),

ignore(save_file_source_vars(mfl4(Vs,M,File,LineNo),Term,Vs)),
( is_list(Expanded)
-> member(T, Expanded)
; T = Expanded
),
( T == end_of_file
-> ! ;
ignore(save_file_source_vars(mfl4(Vs,M,File,LineNo),Term,Vs)),
( is_list(Expanded)
-> member(T, Expanded)
; T = Expanded
),
( T == end_of_file
-> ! ;
( T\==Term, save_file_source_vars(mfl4(Vs,M,File,LineNo),T,Vs),
fail))))).
fail))))).


% new method
Expand All @@ -1316,10 +1316,10 @@
read_source_file_vars_1(File):-
once(current_prolog_flag(xref, Was);Was=false),
locally(set_prolog_flag(xref, true),
setup_call_cleanup(
prolog_open_source(File, In),
read_source_vars(File,In),
(prolog_close_source(In),
setup_call_cleanup(
prolog_open_source(File, In),
read_source_vars(File,In),
(prolog_close_source(In),
current_prolog_flag(xref, Was)))),!.


Expand Down
8 changes: 4 additions & 4 deletions prolog/metta_lang/metta_eval.pl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
% eval_20(Eq,RetType,Depth,Self,['quote',Eval],RetVal):- !, Eval = RetVal, check_returnval(Eq,RetType,RetVal).
is_self_eval_l_fa('quote',_).
%is_self_eval_l_fa('=',_):- nb_current(evaling_args,t).
is_self_eval_l_fa(':',_):- nb_current(evaling_args,t).
%is_self_eval_l_fa(':',_):- nb_current(evaling_args,t).
is_self_eval_l_fa('Error',_).
is_self_eval_l_fa('{...}',_).
is_self_eval_l_fa('[...]',_).
Expand Down Expand Up @@ -2325,8 +2325,6 @@

suggest_type(_RetType,_Bool).

naive_eval_args:-
false.

eval_41(Eq,RetType,Depth,Self,[AE|More],Res):- naive_eval_args,!,
maplist(must_eval_args(Eq,_,Depth,Self),More,Adjusted),
Expand Down Expand Up @@ -2363,6 +2361,8 @@
if_or_else(eval_maybe_host_predicate(Eq,RetType,Depth,Self,PredDecl,Res),
if_or_else(eval_maybe_host_function(Eq,RetType,Depth,Self,PredDecl,Res), fail))).


naive_eval_args:- false_flag.
eval_all_args:- naive_eval_args.
fail_missed_defn:- true_flag.
fail_on_constructor:- true_flag.
Expand Down Expand Up @@ -2752,7 +2752,7 @@
light_eval(Eq,RetType,Depth,Self,B0,Y),!.
eval_defn_failure(Eq,RetType,Depth,Self,X,Res):-
if_trace(e,color_g_mesg('#773701',indentq2(Depth,defs_failed(X)))),
eval_constructor(Eq,RetType,Depth,Self,X,Res).
eval_constructor(Eq,RetType,Depth,Self,X,Res),
\+ fail_missed_defn.


Expand Down
44 changes: 22 additions & 22 deletions prolog/metta_lang/metta_interp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/

%*********************************************************************************************
% PROGRAM FUNCTION: Interpret MeTTa code within the SWI-Prolog environment, enabling logical
% PROGRAM FUNCTION: Interpret MeTTa code within the SWI-Prolog environment, enabling logical
% inference, runtime evaluation, and cross-language integration with Python and Rust.
%*********************************************************************************************

Expand Down Expand Up @@ -152,12 +152,12 @@
% - Facilitates maintainability and portability of the codebase.
% - Supports dynamic pack management during runtime without requiring manual adjustments.
%
:- (prolog_load_context(directory, Value); Value='.'),
:- (prolog_load_context(directory, Value); Value='.'),
% Resolve the absolute path to the '../../libraries/' directory.
absolute_file_name('../../libraries/', Dir, [relative_to(Value)]),
% Build paths for specific libraries/packs.
atom_concat(Dir, 'predicate_streams', PS),
atom_concat(Dir, 'logicmoo_utils', LU),
atom_concat(Dir, 'logicmoo_utils', LU),
% Attach the base library directory with specified options.
attach_packs(Dir, [duplicate(replace), search(first)]),
% Attach the `predicate_streams` and `logicmoo_utils` packs.
Expand Down Expand Up @@ -206,7 +206,7 @@

% This predicate is used as a guard condition in stream-related operations
% to prevent unintended changes to Prolog's standard input, output, or error streams.
% It ensures that existing stream configurations remain intact, avoiding conflicts
% It ensures that existing stream configurations remain intact, avoiding conflicts
% during operations that might otherwise alter stream properties.
dont_change_streams:- true.

Expand Down Expand Up @@ -236,8 +236,8 @@
%
% Determines the root directory of the Mettalog project.
%
% This predicate attempts to determine the root directory by first using the
% `user:is_metta_src_dir/1` dynamic predicate. If that is unavailable or fails,
% This predicate attempts to determine the root directory by first using the
% `user:is_metta_src_dir/1` dynamic predicate. If that is unavailable or fails,
% it falls back to the `METTA_DIR` environment variable.
%
% @arg Dir The absolute path to the Mettalog root directory.
Expand All @@ -261,7 +261,7 @@
%
% Determines the library directory of the Mettalog project.
%
% This predicate resolves the library directory relative to the Mettalog root
% This predicate resolves the library directory relative to the Mettalog root
% directory using `metta_root_dir/1`.
%
% @arg Dir The absolute path to the Mettalog library directory.
Expand All @@ -281,12 +281,12 @@
%
% Determines the directory path for the Mettalog system.
%
% This predicate tries multiple approaches to resolve the directory associated
% with Mettalog in a specific order. It prioritizes specific subdirectories, then
% This predicate tries multiple approaches to resolve the directory associated
% with Mettalog in a specific order. It prioritizes specific subdirectories, then
% falls back to source, library, and root directories.
%
% The resolution strategy is as follows:
% 1. It attempts to resolve the directory as a subdirectory of the Mettalog library
% 1. It attempts to resolve the directory as a subdirectory of the Mettalog library
% path, specifically './loaders/genome/'.
% 2. Falls back to the directory specified by `is_metta_src_dir/1`.
% 3. Further falls back to the Mettalog library directory.
Expand Down Expand Up @@ -319,21 +319,21 @@
% The Prolog 'dynamic' enables runtime modification of predicate.
:- dynamic user:file_search_path/2.
%
% The `user:file_search_path/2` predicate allows associating logical aliases
% with specific directories, making it easier to reference files without
% The `user:file_search_path/2` predicate allows associating logical aliases
% with specific directories, making it easier to reference files without
% hardcoding their paths. In this case:
%
% - `library` is mapped to the Mettalog directory, enabling searches for
% - `library` is mapped to the Mettalog directory, enabling searches for
% library files relative to the Mettalog root.
% - `mettalog` is also mapped to the Mettalog directory, likely to handle
% - `mettalog` is also mapped to the Mettalog directory, likely to handle
% specific files related to the MettalogLog transpiler/interpreter.
:- multifile user:file_search_path/2.
user:file_search_path(library,Dir):- metta_dir(Dir).
user:file_search_path(mettalog,Dir):- metta_dir(Dir).

%
% This directive conditionally loads the `logicmoo_utils` library if the system
% is detected as Windows 64-bit. If the platform is not Windows 64-bit, the
% This directive conditionally loads the `logicmoo_utils` library if the system
% is detected as Windows 64-bit. If the platform is not Windows 64-bit, the
% directive does nothing.
%
:- is_win64 -> ensure_loaded(library(logicmoo_utils)) ; true.
Expand All @@ -342,9 +342,9 @@

% 'nodebug' disables specific debugging flags for various Mettalog-related modules.
%
% These directives ensure that certain debugging categories (`metta(eval)`,
% `metta(exec)`, `metta(load)`, and `metta(prolog)`) are disabled by default.
% This reduces console output noise and improves runtime performance in
% These directives ensure that certain debugging categories (`metta(eval)`,
% `metta(exec)`, `metta(load)`, and `metta(prolog)`) are disabled by default.
% This reduces console output noise and improves runtime performance in
% non-debugging environments.
%
:- nodebug(metta(eval)).
Expand All @@ -353,11 +353,11 @@
:- nodebug(metta(prolog)).

%
% This section declares several dynamic and multifile predicates used in the
% Mettalog system. These predicates support runtime updates, extensibility, and
% This section declares several dynamic and multifile predicates used in the
% Mettalog system. These predicates support runtime updates, extensibility, and
% modular design. They cover various aspects of Mettalog functionality.
%
% These predicates are marked as `dynamic` to allow runtime modifications
% These predicates are marked as `dynamic` to allow runtime modifications
% and as `multifile` to enable contributions from multiple modules.
%
:- dynamic(function_arity/2).
Expand Down
2 changes: 1 addition & 1 deletion prolog/metta_lang/metta_testing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
get_last_call_duration(Duration),
DurationX1000 is Duration * 1000,
% Write the detailed formatted log entry.
format(Stream,'| ~w | ~w |[~w](https://trueagi-io.github.io/metta-wam/~w#~w) | ~@ | ~@ | ~@ | ~w | ~w |~n',
format(Stream,'| ~w | ~w |[~w](https://logicmoo.github.io/metta-wam/~w#~w) | ~@ | ~@ | ~@ | ~w | ~w |~n',
[TestName,PASS_FAIL,TestName,HTML_OUT,TestName,
trim_gstring_bar_I(write_src_woi([P,C]),600),
trim_gstring_bar_I(write_src_woi(G1),600),
Expand Down
2 changes: 1 addition & 1 deletion prolog/metta_lang/stdlib_mettalog.metta
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ For example:

(predicate-arity predicate-arity 2)
(predicate-arity : 2)
(= (: $F P1) (predicate-arity $F 1))
;; (= (: $F P1) (predicate-arity $F 1))

;; Source Predicate and Function Types

Expand Down

0 comments on commit fcce533

Please sign in to comment.