root/tags/lgt293/configs/lpamac.config

Revision 70, 7.9 KB (checked in by pmoura, 7 years ago)

Changed comments about Logtalk flags.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%
3%  Logtalk - Object oriented extension to Prolog
4%  Release 2.9.3
5%
6%  initialization file for LPA MacProlog32 1.25
7%
8%  last updated: December 30, 2001
9%
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12
13:- prolog_flag(syntax_errors, _, error).
14
15
16
17%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18%
19%  ISO Prolog Standard predicates that we must define because they are
20%  not built-in
21%
22%  add a clause for lgt_iso_predicate/1 declaring each ISO predicate that
23%  we must define; there must be at least one clause for this predicate
24%  whose call should fail if we don't define any ISO predicates
25%
26%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28
29:- dynamic(lgt_exception_/1).
30
31
32% lgt_iso_predicate(?callable).
33
34lgt_iso_predicate(atom_codes(_, _)).
35lgt_iso_predicate(atom_concat(_, _, _)).
36lgt_iso_predicate(catch(_, _, _)).
37lgt_iso_predicate(nl(_)).
38lgt_iso_predicate(number_codes(_, _)).
39lgt_iso_predicate(once(_)).
40lgt_iso_predicate(open(_, _, _)).
41lgt_iso_predicate(read_term(_, _, _)).
42lgt_iso_predicate(throw(_)).
43lgt_iso_predicate(write_term(_, _, _)).
44
45
46atom_codes(Atom, Codes) :-
47    name(Atom, Codes).
48
49
50atom_concat(Atom1, Atom2, Atom3) :-
51    nonvar(Atom1), nonvar(Atom2),
52    !,
53    name(Atom1, Codes1),
54    name(Atom2, Codes2),
55    lgt_append(Codes1, Codes2, Codes3),
56    name(Atom3, Codes3).
57
58atom_concat(Atom1, Atom2, Atom3) :-
59    nonvar(Atom3),
60    !,
61    name(Atom3, Codes3),
62    lgt_append(Codes1, Codes2, Codes3),
63    name(Atom1, Codes1),
64    name(Atom2, Codes2).
65
66
67lpa_catch(Error, Goal) :-
68    catch(Error, Goal).
69
70
71:- hide(catch).
72
73
74catch(Error, Goal) :-
75    lpa_catch(Error, Goal).
76
77
78catch(Goal, Catcher, Recovery) :-
79    lpa_catch(Error, Goal),
80    (Error = 0 ->
81        true
82        ;
83        (Error = -1 ->
84            fail
85            ;
86            (Error = 999 ->
87                retract(lgt_exception_(Ball)),
88                !,
89                (Catcher = Ball ->
90                    call(Recovery)
91                    ;
92                    throw(Ball))
93                ;
94                error_message(Error, Message),
95                (Catcher = Message ->
96                    call(Recovery)
97                    ;
98                    write(Message), nl, abort)))).
99
100
101nl(Stream) :-
102    nl ~> Stream.
103
104
105number_codes(Number, Codes) :-
106    name(Number, Codes).
107
108
109once(Goal) :-
110    one(Goal).
111
112
113open(File, Mode, File) :-
114    open(File, Mode).
115
116
117read_term(Stream, Term, [singletons([])]) :-
118    !,
119    read(Term) <~ Stream.
120
121read_term(Stream, Term, _) :-
122    read(Term) <~ Stream.
123
124
125throw(Error) :-
126    asserta(lgt_exception_(Error)),
127    throw(999, Error).
128
129
130write_term(Stream, Term, [quoted(true)]) :-
131    !,
132    writeq(Term) ~> Stream.
133
134write_term(Stream, Term, _) :-
135    write(Term) ~> Stream.
136
137
138
139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140%
141%  predicate properties
142%
143%  this predicate must return at least static, dynamic and built_in
144%  properties for an existing predicate
145%
146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148
149% lgt_predicate_property(+callable, ?predicate_property)
150
151lgt_predicate_property(Pred, Prop) :-
152    predicate_property(Pred, Prop).
153
154
155
156%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157%
158%  metapredicates
159%
160%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162
163% lgt_call/2-8
164%
165% use these definitions only if your compiler does
166% not provide call/1-8 as built-in predicates
167
168lgt_call(F, A) :-
169    F(A).
170
171
172lgt_call(F, A1, A2) :-
173    F(A1, A2).
174
175
176lgt_call(F, A1, A2, A3) :-
177    F(A1, A2, A3).
178
179
180lgt_call(F, A1, A2, A3, A4) :-
181    F(A1, A2, A3, A4).
182
183
184lgt_call(F, A1, A2, A3, A4, A5) :-
185    F(A1, A2, A3, A4, A5).
186
187
188lgt_call(F, A1, A2, A3, A4, A5, A6) :-
189    F(A1, A2, A3, A4, A5, A6).
190
191
192lgt_call(F, A1, A2, A3, A4, A5, A6, A7) :-
193    F(A1, A2, A3, A4, A5, A6, A7).
194
195
196% lgt_once/2-8
197%
198% if your compiler provides call/1-8 as built-in
199% predicates rewrite these definitions using call(...), !.
200
201lgt_once(F, A) :-
202    one(F(A)).
203
204
205lgt_once(F, A1, A2) :-
206    one(F(A1, A2)).
207
208
209lgt_once(F, A1, A2, A3) :-
210    one(F(A1, A2, A3)).
211
212
213lgt_once(F, A1, A2, A3, A4) :-
214    one(F(A1, A2, A3, A4)).
215
216
217lgt_once(F, A1, A2, A3, A4, A5) :-
218    one(F(A1, A2, A3, A4, A5)).
219
220
221lgt_once(F, A1, A2, A3, A4, A5, A6) :-
222    one(F(A1, A2, A3, A4, A5, A6)).
223
224
225lgt_once(F, A1, A2, A3, A4, A5, A6, A7) :-
226    one(F(A1, A2, A3, A4, A5, A6, A7)).
227
228
229
230%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231%
232%  file extension predicates
233%
234%  these extensions are used by Logtalk load/compile predicates
235%
236%  you may want to change the extension for Prolog files to match
237%  the one expected by your Prolog compiler
238%
239%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240
241
242% lgt_file_extension(?atom, ?atom)
243
244lgt_file_extension(logtalk, '.lgt').
245lgt_file_extension(prolog, '.pl').
246lgt_file_extension(xml, '.xml').
247
248
249
250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251%
252%  default flag values
253%
254%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255
256
257% lgt_default_flag(?atom, ?atom)
258%
259% default values for all flags
260
261lgt_default_flag(iso_initialization_dir, true).
262
263lgt_default_flag(xml, on).
264lgt_default_flag(xsl, 'lgtxml.xsl').
265
266lgt_default_flag(unknown, warning).
267lgt_default_flag(misspelt, warning).
268lgt_default_flag(singletons, warning).
269lgt_default_flag(lgtredef, warning).
270lgt_default_flag(plredef, silent).
271lgt_default_flag(portability, silent).
272
273lgt_default_flag(report, on).
274
275
276
277%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278%
279%  list predicates
280%
281%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282
283
284lgt_append([], List, List).
285lgt_append([Head| Tail], List, [Head| Tail2]) :-
286    lgt_append(Tail, List, Tail2).
287
288
289lgt_member(Head, [Head| _]).
290lgt_member(Head, [_| Tail]) :-
291    lgt_member(Head, Tail).
292
293
294lgt_member_var(V, [H| _]) :-
295    V == H.
296lgt_member_var(V, [_| T]) :-
297    lgt_member_var(V, T).
298
299
300lgt_proper_list([]).
301lgt_proper_list([_| List]) :-
302    lgt_proper_list(List).
303
304
305
306%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307%
308%  file predicates
309%
310%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311
312
313% lgt_file_exists(+atom)
314%
315% see if a file exist in the current directory
316
317lgt_file_exists(File) :-
318    catch(absolute_file_name(File, [access(exist)], _), _, fail).
319
320
321% lgt_load_prolog_code(+atom)
322%
323% compile and load a Prolog file
324
325lgt_load_prolog_code(File) :-
326    reconsult(File).
327
328
329
330%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331%
332%  sorting predicates
333%
334%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335
336
337% lgt_keysort(+list, -list)
338
339lgt_keysort(List, Sorted) :-
340    keysort(List, Sorted).
341
342
343% lgt_sort(+list, -list)
344
345lgt_sort(List, Sorted) :-
346    sort(List, Sorted).
347
348
349
350%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351%
352%  time and date predicates
353%
354%  if your Prolog compiler does not provide access to the operating system
355%  time and date just write dummy definitions
356%
357%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358
359
360% lgt_current_date(?Year, ?Month, ?Day)
361
362lgt_current_date(Year, Month, Day) :-
363    date(Day, Month, Year).
364
365
366% lgt_current_time(?Hours, ?Mins, ?Secs)
367
368lgt_current_time(Hours, Mins, Secs) :-
369    time(Hours, Mins, Secs, _).
370
371
372
373%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374%
375%  timing predicate
376%
377%  if your Prolog compiler does not provide access to a timing predicate
378%  just write dummy definition
379%
380%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381
382
383% lgt_cpu_time(-Seconds)
384
385lgt_cpu_time(Seconds) :-
386    ticks(Ticks),
387    Seconds is Ticks / 60.
388
389
390
391%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392%
393%  comparison predicate
394%
395%  the usual compare/3 definition
396%
397%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398
399
400% compare(?atom, @term, @term) -- built-in
401
402
403
404%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405%
406%  end!
407%
408%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the browser.