make module user available by default to all other modules
This commit is contained in:
parent
63416fdc48
commit
29ffb152e5
@ -35,10 +35,10 @@ The main predicates in the module system are:
|
|||||||
* use_module/1 and use_module/2 can be used to load a module. They take as first argument the source file for the module. Whereas use_module/1 loads all exported predicates, use_module/2 only takes the ones given by the second argument.
|
* use_module/1 and use_module/2 can be used to load a module. They take as first argument the source file for the module. Whereas use_module/1 loads all exported predicates, use_module/2 only takes the ones given by the second argument.
|
||||||
|
|
||||||
YAP pre-defines a number of modules. Most system predicates belong to
|
YAP pre-defines a number of modules. Most system predicates belong to
|
||||||
the module `prolog`. Predicates from the module `prolog` are
|
the module `prolog`. Predicates from the module `prolog` are
|
||||||
automatically visible to every module. The `system` module was
|
automatically visible to every module. The `system` module was
|
||||||
introduced for SWI-Prolog compatibility, and in YAP mostly acts as an
|
introduced for SWI-Prolog compatibility, and in YAP mostly acts as an
|
||||||
alias to `prolog`.
|
alias to `prolog`. The `user` module is also visible to all other modules.
|
||||||
|
|
||||||
The YAP engine is always associated to a module, the current <em>source
|
The YAP engine is always associated to a module, the current <em>source
|
||||||
module</em> or <em>type-in module</em>. By default, all predicates
|
module</em> or <em>type-in module</em>. By default, all predicates
|
||||||
@ -837,12 +837,14 @@ expand_goal(G, G).
|
|||||||
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
|
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
|
||||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
|
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
|
||||||
% SWI builtin
|
% SWI builtin
|
||||||
|
'$get_undefined_pred'(G, _ImportingMod, G, user) :-
|
||||||
|
'$pred_exists'(G, user), !.
|
||||||
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
|
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
|
||||||
recorded('$dialect',Dialect,_),
|
recorded('$dialect',Dialect,_),
|
||||||
Dialect \= yap,
|
Dialect \= yap,
|
||||||
functor(G, Name, Arity),
|
functor(G, Name, Arity),
|
||||||
call(Dialect:index(Name,Arity,ExportingModI,_)), !,
|
call(Dialect:index(Name,Arity,ExportingModI,_)), !,
|
||||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||||
% autoload
|
% autoload
|
||||||
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
|
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
|
||||||
yap_flag(autoload, V),
|
yap_flag(autoload, V),
|
||||||
@ -931,7 +933,7 @@ meta_predicate declaration
|
|||||||
|
|
||||||
'$install_meta_predicate'(P, M1) :-
|
'$install_meta_predicate'(P, M1) :-
|
||||||
functor(P,F,N),
|
functor(P,F,N),
|
||||||
( M1 = prolog -> M = _ ; M1 = M),
|
( M1 = prolog -> M = _ ; M1 = M),
|
||||||
( retractall(prolog:'$meta_predicate'(F,M,N,_)), fail ; true),
|
( retractall(prolog:'$meta_predicate'(F,M,N,_)), fail ; true),
|
||||||
asserta(prolog:'$meta_predicate'(F,M,N,P)),
|
asserta(prolog:'$meta_predicate'(F,M,N,P)),
|
||||||
'$flags'(P, M1, Fl, Fl),
|
'$flags'(P, M1, Fl, Fl),
|
||||||
@ -1248,7 +1250,9 @@ export_resource(P0) :-
|
|||||||
; recorda('$module','$module'(user_input,Mod,user_input,[P],1),_)
|
; recorda('$module','$module'(user_input,Mod,user_input,[P],1),_)
|
||||||
).
|
).
|
||||||
export_resource(op(Prio,Assoc,Name)) :- !,
|
export_resource(op(Prio,Assoc,Name)) :- !,
|
||||||
op(Prio,Assoc,prolog:Name).
|
op(Prio,Assoc,prolog:Name).
|
||||||
|
export_resource(op(Prio,Assoc,Name)) :- !,
|
||||||
|
op(Prio,Assoc,user:Name).
|
||||||
export_resource(Resource) :-
|
export_resource(Resource) :-
|
||||||
'$do_error'(type_error(predicate_indicator,Resource),export(Resource)).
|
'$do_error'(type_error(predicate_indicator,Resource),export(Resource)).
|
||||||
|
|
||||||
@ -1498,8 +1502,8 @@ All exported predicates from _ExportingModule_ are automatically available to th
|
|||||||
source module _ImportModule_.
|
source module _ImportModule_.
|
||||||
|
|
||||||
This innovation was introduced by SWI-Prolog. By default, modules only
|
This innovation was introduced by SWI-Prolog. By default, modules only
|
||||||
inherit from `prolog`. This extension allows predicates in any module
|
inherit from `prolog` and `user`. This extension allows predicates in
|
||||||
to inherit from `user`oe other modules.
|
any module to inherit from `user` and other modules.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
import_module(Mod, ImportModule) :-
|
import_module(Mod, ImportModule) :-
|
||||||
|
Reference in New Issue
Block a user