%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Logtalk - Object oriented extension to Prolog
%  Release 2.16.0
%
%  configuration file for YAP Prolog 4.3.23 or later
%
%  last updated: February 27, 2004
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% the following initialization is not needed to run Logtalk altough is 
% recommended; you can comment out the set_prolog_flag/2 calls if needed

:- initialization(
	(set_prolog_flag(update_semantics, logical),
	 set_prolog_flag(unknown, error),
	 use_module(library(system)),
	 '$lgt_hide_predicates')).


'$lgt_hide_predicates' :-
	predicate_property(hide_predicate(_), built_in) ->
		dynamic('$lgt_before_'/5), hide_predicate('$lgt_before_'/5),
		dynamic('$lgt_after_'/5), hide_predicate('$lgt_after_'/5),
		dynamic('$lgt_current_protocol_'/2), hide_predicate('$lgt_current_protocol_'/2),
		dynamic('$lgt_current_category_'/2), hide_predicate('$lgt_current_category_'/2),
		dynamic('$lgt_current_object_'/5), hide_predicate('$lgt_current_object_'/5),
		dynamic('$lgt_implements_protocol_'/3), hide_predicate('$lgt_implements_protocol_'/3),
		dynamic('$lgt_imports_category_'/3), hide_predicate('$lgt_imports_category_'/3),
		dynamic('$lgt_instantiates_class_'/3), hide_predicate('$lgt_instantiates_class_'/3),
		dynamic('$lgt_specializes_class_'/3), hide_predicate('$lgt_specializes_class_'/3),
		dynamic('$lgt_extends_protocol_'/3), hide_predicate('$lgt_extends_protocol_'/3),
		dynamic('$lgt_extends_object_'/3), hide_predicate('$lgt_extends_object_'/3)
		;
		true.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  ISO Prolog Standard predicates that we must define because they are
%  not built-in
%
%  add a clause for lgt_iso_predicate/1 declaring each ISO predicate that
%  we must define; there must be at least one clause for this predicate
%  whose call should fail if we don't define any ISO predicates
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_iso_predicate'(?callable).

'$lgt_iso_predicate'(_) :-
	fail.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  predicate properties
%
%  this predicate must return at least static, dynamic, and built_in 
%  properties for an existing predicate
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_predicate_property'(+callable, ?predicate_property)

'$lgt_predicate_property'(Pred, Prop) :-
	predicate_property(Pred, Prop).



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  metapredicates
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% forall(+callable, +callble)

forall(Generate, Test) :-
	\+ call((Generate, \+ call(Test))).


% lgt_call/2-8
%
% use these definitions only if your compiler does
% not provide call/1-8 as built-in predicates

'$lgt_call'(F, A) :-
	call_with_args(F, A).


'$lgt_call'(F, A1, A2) :-
	call_with_args(F, A1, A2).


'$lgt_call'(F, A1, A2, A3) :-
	call_with_args(F, A1, A2, A3).


'$lgt_call'(F, A1, A2, A3, A4) :-
	call_with_args(F, A1, A2, A3, A4).


'$lgt_call'(F, A1, A2, A3, A4, A5) :-
	call_with_args(F, A1, A2, A3, A4, A5).


'$lgt_call'(F, A1, A2, A3, A4, A5, A6) :-
	call_with_args(F, A1, A2, A3, A4, A5, A6).


'$lgt_call'(F, A1, A2, A3, A4, A5, A6, A7) :-
	call_with_args(F, A1, A2, A3, A4, A5, A6, A7).


% lgt_once/2-8
%
% if your compiler provides call/1-8 as built-in 
% predicates rewrite these definitions using call(...), !.

'$lgt_once'(F, A) :-
	call_with_args(F, A),
	!.


'$lgt_once'(F, A1, A2) :-
	call_with_args(F, A1, A2),
	!.


'$lgt_once'(F, A1, A2, A3) :-
	call_with_args(F, A1, A2, A3),
	!.


'$lgt_once'(F, A1, A2, A3, A4) :-
	call_with_args(F, A1, A2, A3, A4),
	!.


'$lgt_once'(F, A1, A2, A3, A4, A5) :-
	call_with_args(F, A1, A2, A3, A4, A5),
	!.


'$lgt_once'(F, A1, A2, A3, A4, A5, A6) :-
	call_with_args(F, A1, A2, A3, A4, A5, A6),
	!.


'$lgt_once'(F, A1, A2, A3, A4, A5, A6, A7) :-
	call_with_args(F, A1, A2, A3, A4, A5, A6, A7),
	!.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Prolog built-in metapredicates
%
%  (excluding ISO Prolog Standard metapredicates)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_pl_metapredicate'(?callable).

'$lgt_pl_metapredicate'(all(*, ::, *)).
'$lgt_pl_metapredicate'(call_cleanup(::)).
'$lgt_pl_metapredicate'(call_cleanup(::, ::)).
'$lgt_pl_metapredicate'(call_residue(::,*)).
'$lgt_pl_metapredicate'(on_cleanup(::)).
'$lgt_pl_metapredicate'(freeze(*,::)).
'$lgt_pl_metapredicate'(time_out(::, *, *)).
'$lgt_pl_metapredicate'(when(*,::)).



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  file extension predicates
%
%  these extensions are used by Logtalk load/compile predicates
%
%  you may want to change the extension for Prolog files to match 
%  the one expected by your Prolog compiler
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_file_extension'(?atom, ?atom)

'$lgt_file_extension'(logtalk, '.lgt').
'$lgt_file_extension'(prolog, '.pl').
'$lgt_file_extension'(xml, '.xml').



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  default flag values
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_default_flag'(?atom, ?atom)
%
% default values for all flags

'$lgt_default_flag'(iso_initialization_dir, true).

'$lgt_default_flag'(xml, on).
'$lgt_default_flag'(xsl, 'lgtxml.xsl').
'$lgt_default_flag'(xmlspec, dtd).
'$lgt_default_flag'(doctype, local).

'$lgt_default_flag'(unknown, warning).
'$lgt_default_flag'(misspelt, warning).
'$lgt_default_flag'(singletons, warning).
'$lgt_default_flag'(lgtredef, warning).
'$lgt_default_flag'(plredef, silent).
'$lgt_default_flag'(portability, silent).

'$lgt_default_flag'(report, on).

'$lgt_default_flag'(smart_compilation, off).

'$lgt_default_flag'(startup_message, on).

'$lgt_default_flag'(underscore_vars, singletons).

'$lgt_default_flag'(code_prefix, '').



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  list predicates
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


'$lgt_append'([], List, List).
'$lgt_append'([Head| Tail], List, [Head| Tail2]) :-
	'$lgt_append'(Tail, List, Tail2).


'$lgt_member'(Head, [Head| _]).
'$lgt_member'(Head, [_| Tail]) :-
	'$lgt_member'(Head, Tail).


'$lgt_member_var'(V, [H| _]) :-
	V == H.
'$lgt_member_var'(V, [_| T]) :-
	'$lgt_member_var'(V, T).


'$lgt_proper_list'([]).
'$lgt_proper_list'([_| List]) :-
	'$lgt_proper_list'(List).



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  file predicates
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_file_exists'(+atom)
%
% see if a file exist in the current directory

'$lgt_file_exists'(File) :-
	file_exists(File).


% '$lgt_load_prolog_code'(+atom)
%
% compile and load a Prolog file

'$lgt_load_prolog_code'(File) :-
	reconsult(File).


% '$lgt_compare_file_mtimes'(?atom, +atom, +atom)
%
% compare file modification times

'$lgt_compare_file_mtimes'(Result, File1, File2) :-
	file_property(File1, mod_time(Time1)),
	file_property(File2, mod_time(Time2)),
	compare(Result, Time1, Time2).



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  sorting predicates
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_keysort'(+list, -list)

'$lgt_keysort'(List, Sorted) :-
	keysort(List, Sorted).


% '$lgt_sort'(+list, -list)

'$lgt_sort'(List, Sorted) :-
	sort(List, Sorted).



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  time and date predicates
%
%  if your Prolog compiler does not provide access to the operating system 
%  time and date just write dummy definitions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_current_date'(?Year, ?Month, ?Day)

'$lgt_current_date'(Year, Month, Day) :-
	datime(datime(Year, Month, Day, _, _, _)).


% '$lgt_current_time'(?Hours, ?Mins, ?Secs)

'$lgt_current_time'(Hours, Mins, Secs) :-
	datime(datime(_, _, _, Hours, Mins, Secs)).



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  timing predicate
%
%  if your Prolog compiler does not provide access to a timing predicate 
%  just write dummy definition
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% '$lgt_cpu_time'(-Seconds)

'$lgt_cpu_time'(Seconds) :-
	Seconds is cputime.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  comparison predicate
%
%  the usual compare/3 definition
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% compare(?atom, @term, @term) -- built-in



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  end!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
