From 22ec8bdf010380fba2f1f1c6d4437390483553bf@a4.complang.tuwien.ac.at Sat May 02 03:18:22 2009 Return-path: <22ec8bdf010380fba2f1f1c6d4437390483553bf@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sat, 02 May 2009 03:18:22 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <22ec8bdf010380fba2f1f1c6d4437390483553bf@a4.complang.tuwien.ac.at>) id 1M03ry-0001ni-Pf; Sat, 02 May 2009 03:18:22 +0200 From: Ulrich Neumerkel Date: Wed, 29 Apr 2009 01:54:35 +0200 Subject: [PATCH] Old gcc adaptations for yap-6 Message-Id: --- C/absmi.c | 7 +++++-- C/arith2.c | 3 ++- C/cmppreds.c | 6 ++++-- C/heapgc.c | 3 ++- C/iopreds.c | 9 ++++++--- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index b597d8d..3f6ad61 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -611,6 +611,9 @@ Int Yap_absmi(int inp) { + CPredicate f; + yamop *oldPREG; + #if BP_FREE /* some function might be using bp for an internal variable, it is the callee's responsability to save it */ @@ -7470,8 +7473,8 @@ Yap_absmi(int inp) DEPTH -= MkIntConstant(2); #endif /* DEPTH_LIMIT */ /* now call C-Code */ - CPredicate f = PREG->u.pp.p->cs.f_code; - yamop *oldPREG = PREG; + f = PREG->u.pp.p->cs.f_code; + oldPREG = PREG; saveregs(); d0 = (f)(); setregs(); diff --git a/C/arith2.c b/C/arith2.c index da26daf..270d9bc 100644 --- a/C/arith2.c +++ b/C/arith2.c @@ -594,12 +594,13 @@ p_power(Term t1, Term t2) static inline Int ipow(Int x, Int p) { + Int r; if (p == 0) return 1L; if (x == 0 && p > 0) return 0L; if(p < 0) return (-p % 2) ? x : 1L; - Int r = 1L; + r = 1L; for(;;) { if(p & 1) { if (mul_overflow((r*x), r, x)) { diff --git a/C/cmppreds.c b/C/cmppreds.c index 49ded66..1d414a4 100644 --- a/C/cmppreds.c +++ b/C/cmppreds.c @@ -547,8 +547,9 @@ a_cmp(Term t1, Term t2) } t1 = Yap_Eval(t1); if (IsIntegerTerm(t1)) { + Int i1; t2 = Yap_Eval(t2); - Int i1 = IntegerOfTerm(t1); + i1 = IntegerOfTerm(t1); if (IsIntegerTerm(t2)) { Int i2 = IntegerOfTerm(t2); @@ -565,8 +566,9 @@ a_cmp(Term t1, Term t2) return FALSE; } } else if (IsFloatTerm(t1)) { + Float f1; t2 = Yap_Eval(t2); - Float f1 = FloatOfTerm(t1); + f1 = FloatOfTerm(t1); if (IsIntegerTerm(t2)) { Int i2 = IntegerOfTerm(t2); diff --git a/C/heapgc.c b/C/heapgc.c index a937a51..b731a11 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -2354,6 +2354,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR) /* next, clean trail */ source = dest = (tr_fr_ptr)Yap_TrailBase; while (source < old_TR) { + CELL trail_cell; while (next && source == next->cp_tr) { choiceptr b = next; b->cp_tr = dest; @@ -2361,7 +2362,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR) b->cp_b = current; current = b; } - CELL trail_cell = TrailTerm(source); + trail_cell = TrailTerm(source); if (trail_cell != (CELL)source) { dest++; } diff --git a/C/iopreds.c b/C/iopreds.c index 2f8f311..ea923e2 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -183,11 +183,12 @@ STATIC_PROTO (Term StreamPosition, (int)); static encoding_t DefaultEncoding(void) { + int sz; char *s = getenv("LANG"); /* if we don't have a LNAG then just use ISO_LATIN1 */ if (s == NULL) return ENC_ISO_LATIN1; - int sz = strlen(s); + sz = strlen(s); if (sz > 5) { if (s[sz-5] == 'U' && s[sz-4] == 'T' && @@ -3492,9 +3493,10 @@ static Int p_representation_error (void) { /* '$representation_error'(+Stream,-ErrorMessage) */ Int sno = CheckStream (ARG1, Input_Stream_f|Output_Stream_f, "representation_errors/1"); + Term t; if (sno < 0) return (FALSE); - Term t = Deref(ARG2); + t = Deref(ARG2); if (IsVarTerm(t)) { UNLOCK(Stream[sno].streamlock); @@ -5887,6 +5889,7 @@ p_same_file(void) { return TRUE; #if HAVE_LSTAT { + int out; struct stat *b1, *b2; while ((char *)H+sizeof(struct stat)*2 > (char *)(ASP-1024)) { if (!Yap_gcl(2*sizeof(struct stat), 2, ENV, gc_P(P,CP))) { @@ -5934,7 +5937,7 @@ p_same_file(void) { /* file does not exist, but was opened? Return -1 */ return FALSE; } - int out = (b1->st_ino == b2->st_ino + out = (b1->st_ino == b2->st_ino #ifdef __LCC__ && memcmp((const void *)&(b1->st_dev),(const void *)&(b2->st_dev),sizeof(buf1.st_dev)) == 0 #else -- 1.5.3.6 From f7df2871aabaf581686b3f08bf515bad49c8dd8c@a4.complang.tuwien.ac.at Sat May 02 03:18:28 2009 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sat, 02 May 2009 03:18:28 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from ) id 1M03s4-0001nt-Bg; Sat, 02 May 2009 03:18:28 +0200 From: Ulrich Neumerkel Date: Sat, 2 May 2009 03:13:01 +0200 Subject: [PATCH] DOC: info dir added Message-Id: --- docs/dir | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) create mode 100644 docs/dir diff --git a/docs/dir b/docs/dir new file mode 100644 index 0000000..d96e25f --- /dev/null +++ b/docs/dir @@ -0,0 +1,18 @@ +-*- Text -*- +This is the file .../info/dir, which contains the topmost node of the +Info hierarchy. The first time you invoke Info you start off +looking at that node, which is (dir)Top. + +File: dir Node: Top This is the top of the INFO tree + This (the Directory node) gives a menu of major topics. + Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" + gives a primer for first-timers, "mEmacs" visits the Emacs topic, + etc. + In Emacs, you can click mouse button 2 on a menu item or cross reference + to select it. + --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- + +* Menu: The list of major topics begins on the next line. + +YAP Prolog +* YAP Prolog Manual: (yap). YAP User's Manual. -- 1.5.3.6 From b6b425e0761af16aa23f25d945258d98d1ea8f7a@a4.complang.tuwien.ac.at Sat May 02 03:18:33 2009 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sat, 02 May 2009 03:18:33 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from ) id 1M03s9-0001o4-3J; Sat, 02 May 2009 03:18:33 +0200 From: Ulrich Neumerkel Date: Sat, 2 May 2009 03:14:12 +0200 Subject: [PATCH] New .gitignore Message-Id: --- .gitignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5294db8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +docs/yap.info* \ No newline at end of file -- 1.5.3.6 From 2e89822ebd288de808cf7754b584fa24d586688e@a4.complang.tuwien.ac.at Sat May 02 18:42:40 2009 Return-path: <2e89822ebd288de808cf7754b584fa24d586688e@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sat, 02 May 2009 18:42:40 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <2e89822ebd288de808cf7754b584fa24d586688e@a4.complang.tuwien.ac.at>) id 1M0IIS-0004Dh-5J; Sat, 02 May 2009 18:42:40 +0200 From: Ulrich Neumerkel Date: Sat, 2 May 2009 18:41:33 +0200 Subject: [PATCH] Correct dir-formatting for Info including special character and tabs. Message-Id: --- docs/dir | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/dir b/docs/dir index 99df821..f4d8a0f 100644 --- a/docs/dir +++ b/docs/dir @@ -2,8 +2,8 @@ This is the file .../info/dir, which contains the topmost node of the Info hierarchy. The first time you invoke Info you start off looking at that node, which is (dir)Top. - -File: dir Node: Top This is the top of the INFO tree + +File: dir Node: Top This is the top of the INFO tree This (the Directory node) gives a menu of major topics. Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" gives a primer for first-timers, "mEmacs" visits the Emacs topic, @@ -15,4 +15,4 @@ File: dir Node: Top This is the top of the INFO tree * Menu: The list of major topics begins on the next line. YAP Prolog -* YAP Prolog Manual: (yap). YAP User's Manual. +* YAP Prolog Manual: (yap). YAP User's Manual. -- 1.5.3.6 From 270ad96919422bf26beeea9053d3bcc642ae42b0@a4.complang.tuwien.ac.at Mon May 04 17:55:50 2009 Return-path: <270ad96919422bf26beeea9053d3bcc642ae42b0@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 04 May 2009 17:55:50 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <270ad96919422bf26beeea9053d3bcc642ae42b0@a4.complang.tuwien.ac.at>) id 1M10WE-0005RZ-6a; Mon, 04 May 2009 17:55:50 +0200 From: Ulrich Neumerkel Date: Mon, 4 May 2009 17:51:29 +0200 Subject: [PATCH-YAP] '$skip_list'/3 corrected. Infinite lists still missing Message-Id: --- GPL/error.pl | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/GPL/error.pl b/GPL/error.pl index db55e43..cdecc2d 100644 --- a/GPL/error.pl +++ b/GPL/error.pl @@ -249,13 +249,21 @@ is_list_or_partial_list(L0) :- :- if(current_prolog_flag(dialect, yap)). % vsc: I hope it works like this -'$skip_list'(_, Rest, Rest) :- var(Rest), !. -'$skip_list'(_, [], _) :- !, fail. -'$skip_list'(Anything, [_|More], Rest) :- - '$skip_list'(Anything, [_|More], Rest). -'$skip_list'(Anything, [_|More], Rest) :- - '$skip_list'(Anything, More, Rest). -'$skip_list'(_Anything, Rest, Rest). +% UWN: only an approximation +'$skip_list'(N, Xs0,Xs) :- + '$skip_list_i'(0,N, Xs0,Xs). + +'$skip_list_i'(N0,N, Xs0,Xs) :- + var(Xs0), !, + N0 = N, + Xs0 = Xs. +'$skip_list_i'(N0,N, [],Xs) :- !, + N0 = N, + Xs = []. +'$skip_list_i'(N0,N, [_|Xs0],Xs) :- !, + N1 is N0 + 1, + '$skip_list_i'(N1,N, Xs0,Xs). +'$skip_list_i'(N,N, Xs,Xs). :- endif. -- 1.5.3.6 From 9bed3f869a7f866883595c113913ba589c112f66@a4.complang.tuwien.ac.at Tue May 12 23:39:56 2009 Return-path: <9bed3f869a7f866883595c113913ba589c112f66@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 12 May 2009 23:39:56 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <9bed3f869a7f866883595c113913ba589c112f66@a4.complang.tuwien.ac.at>) id 1M3zhb-0001Es-R8; Tue, 12 May 2009 23:39:55 +0200 From: Ulrich Neumerkel Date: Sun, 3 May 2009 17:52:40 +0200 Subject: [PATCH-YAP] Minor typos Message-Id: --- docs/yap.tex | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index 599b5e4..2720761 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -11126,11 +11126,11 @@ terminates, unify @var{Result} with @t{timeout}. This command is implemented by activating an alarm at procedure entry. If the timer expires before the goal completes, the alarm will -through an exception @var{timeout}. +throw an exception @var{timeout}. One should note that @code{time_out/3} is not reentrant, that is, a goal called from @code{time_out} should never itself call -@t{time_out}. Moreover, @code{time_out/3} will deactivate any previous +@code{time_out/3}. Moreover, @code{time_out/3} will deactivate any previous alarms set by @code{alarm/3} and vice-versa, hence only one of these calls should be used in a program. -- 1.5.3.6 From 18c36460fbf7e7d53f9819ad3859948fbbdda5d3@a4.complang.tuwien.ac.at Fri May 15 19:54:36 2009 Return-path: <18c36460fbf7e7d53f9819ad3859948fbbdda5d3@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Fri, 15 May 2009 19:54:36 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <18c36460fbf7e7d53f9819ad3859948fbbdda5d3@a4.complang.tuwien.ac.at>) id 1M51cC-0005A6-OA; Fri, 15 May 2009 19:54:36 +0200 From: Ulrich Neumerkel Date: Fri, 15 May 2009 19:48:36 +0200 Subject: [PATCH-YAP] Made length steadfast for Message-Id: ?- freeze(L,(L=[_|_],throw(unexpected))), length(L,-1). --- pl/sort.yap | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pl/sort.yap b/pl/sort.yap index d4e9607..91eee68 100644 --- a/pl/sort.yap +++ b/pl/sort.yap @@ -37,9 +37,9 @@ length(L,M) :- '$$_length2'(M,L). -> L = [] ; - L = [_|L1], N > 0, N1 is N - 1, + L = [_|L1], '$$_length2'(N1, L1) ). -- 1.5.3.6 From 8bc1793701b53f58ad93604f22dbbf9da30cde5b@a4.complang.tuwien.ac.at Sat May 16 16:32:51 2009 Return-path: <8bc1793701b53f58ad93604f22dbbf9da30cde5b@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sat, 16 May 2009 16:32:51 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <8bc1793701b53f58ad93604f22dbbf9da30cde5b@a4.complang.tuwien.ac.at>) id 1M5KwV-0002lq-2x; Sat, 16 May 2009 16:32:51 +0200 From: Ulrich Neumerkel Date: Sat, 16 May 2009 16:31:25 +0200 Subject: [PATCH-YAP] DOC: copy_term/3 Message-Id: --- docs/yap.tex | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index 6179614..0911684 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -3264,7 +3264,15 @@ Also refer to @code{copy_term/2}. @cnindex copy_term/3 Term @var{TF} is a variant of the original term @var{TI}, such that for each variable @var{V} in the term @var{TI} there is a new variable @var{V'} -in term @var{TF}. Attributed variables are converted to standard variables and the list @var{Goals} is unified with a set of goals that can be used to restore the constraints, by calling @code{attribute_goals/3} before copying is performed. +in term @var{TF} without any attributes attached. Attributed +variables are thus converted to standard variables. @var{Goals} is +unified with a list that represents the attributes. The goal +@code{maplist(call,@var{Goals})} can be called to recreate the +attributes. + +Before the actual copying, \@code{copy_term/3} calls +@code{attribute_goals//1} in the module where the attribute is +defined. @end table @@ -7706,7 +7714,7 @@ from a modern Prolog system. Moreover, because most Prolog implementations do not fully implement the standard and because the standard itself gives the implementor latitude in a few important questions, such as the unification algorithm and maximum size for -numbers there is not guarantee that programs compliant with this mode +numbers there is no guarantee that programs compliant with this mode will work the same way in every Prolog and in every platform. We thus believe this mode is mostly useful when investigating how a program depends on a Prolog's platform specific features. @@ -11988,7 +11996,7 @@ unifying terms. As an example, @code{X = a(X)} will not fail but instead will create an infinite term of the form @code{a(a(a(a(a(...)))))}, or @emph{rational tree}. -Rational trees are no supported by default in YAP. In previous +Rational trees are now supported by default in YAP. In previous versions, this was not the default and these terms could easily lead to infinite computation. For example, @code{X = a(X), X = X} would enter an infinite loop. @@ -15340,7 +15348,7 @@ compatible built-in. @item The following SICStus Prolog v3 built-ins are not (currently) implemented in YAP (note that this is only a partial list): -@code{call_cleanup/1}, @code{file_search_path/2}, +@code{file_search_path/2}, @code{stream_interrupt/3}, @code{reinitialize/0}, @code{help/0}, @code{help/1}, @code{trimcore/0}, @code{load_files/1}, @code{load_files/2}, and @code{require/1}. @@ -15355,12 +15363,6 @@ releases of SICStus Prolog. execution through the @code{assert_static/1} and @code{abolish/1} built-ins. This is not allowed in Quintus Prolog or SICStus Prolog. -@item YAP implements rational trees and co-routining but they -are not included by default in the system. You must enable these -extensions when compiling the system. - -@item YAP does not currently implement constraints. - @item The socket predicates, although designed to be compatible with SICStus Prolog, are built-ins, not library predicates, in YAP. -- 1.5.3.6 From 5735abbb457409d67e26d16b3c3e7ac38d24109a@a4.complang.tuwien.ac.at Mon May 18 15:45:18 2009 Return-path: <5735abbb457409d67e26d16b3c3e7ac38d24109a@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 18 May 2009 15:45:18 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <5735abbb457409d67e26d16b3c3e7ac38d24109a@a4.complang.tuwien.ac.at>) id 1M639a-0004Ng-CU; Mon, 18 May 2009 15:45:18 +0200 From: Ulrich Neumerkel Date: Mon, 18 May 2009 15:41:04 +0200 Subject: [PATCH-YAP] Permit | in DCGs. Message-Id: --- pl/grammar.yap | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/pl/grammar.yap b/pl/grammar.yap index bf4bed7..90df133 100644 --- a/pl/grammar.yap +++ b/pl/grammar.yap @@ -85,6 +85,9 @@ '$t_body'((T;R), _ToFill, _, S, SR, (Tt;Rt)) :- !, '$t_body'(T, _, last, S, SR, Tt), '$t_body'(R, _, last, S, SR, Rt). +'$t_body'((T|R), _ToFill, _, S, SR, (Tt;Rt)) :- !, + '$t_body'(T, _, last, S, SR, Tt), + '$t_body'(R, _, last, S, SR, Rt). '$t_body'(M:G, ToFill, Last, S, SR, M:NG) :- !, '$t_body'(G, ToFill, Last, S, SR, NG). '$t_body'(T, filled_in, _, S, SR, Tt) :- -- 1.5.3.6 From bf248b71fe84389c2fc496597f36ad9158c89f31@a4.complang.tuwien.ac.at Tue May 19 18:13:57 2009 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 19 May 2009 18:13:57 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from ) id 1M6Rwy-0006lY-Qi; Tue, 19 May 2009 18:13:56 +0200 From: Ulrich Neumerkel Date: Tue, 19 May 2009 18:10:51 +0200 Subject: [PATCH-YAP] FIXED: time_out output argument, exceptions (unhappy about once) Message-Id: ?- time_out(true,3600,time_out). yes ?- catch(time_out(throw(x),3600,R),x,length(L,L)). ERROR!! UNHANDLED EXCEPTION - message time_out unknown --- library/timeout.yap | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/library/timeout.yap b/library/timeout.yap index 1ed0bf0..607e73f 100644 --- a/library/timeout.yap +++ b/library/timeout.yap @@ -30,14 +30,9 @@ time_out(Goal, Time, Result) :- % enable alarm alarm(T.UT,throw(time_out),_), % launch goal and wait for signal - ( catch(Goal, time_out, Result = time_out) - % make sure to disable alarm - -> - alarm(0,_,_) - ; - alarm(0,_,_), - fail - ), - % just couldn't resist... - (Result = success -> true ; true). - + call_cleanup( + catch( ( Result0 = success, once(Goal) ), + time_out, + Result0 = time_out ), + alarm(0,_,_) ), + Result = Result0. -- 1.5.3.6 From 492139cce029b06461cb5b5b5866affbe9190628@a4.complang.tuwien.ac.at Tue May 19 19:04:11 2009 Return-path: <492139cce029b06461cb5b5b5866affbe9190628@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 19 May 2009 19:04:11 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <492139cce029b06461cb5b5b5866affbe9190628@a4.complang.tuwien.ac.at>) id 1M6Sjb-0007e9-3n; Tue, 19 May 2009 19:04:11 +0200 From: Ulrich Neumerkel Date: Tue, 19 May 2009 19:02:51 +0200 Subject: [PATCH-YAP] Simplified Message-Id: --- library/cleanup.yap | 14 +------------- 1 files changed, 1 insertions(+), 13 deletions(-) diff --git a/library/cleanup.yap b/library/cleanup.yap index 5023056..0726de0 100644 --- a/library/cleanup.yap +++ b/library/cleanup.yap @@ -142,7 +142,7 @@ cleanup_expansion([H,T]) :- !, cleanup_expansion(H), ( T = [] -> true ; cleanup_expansion(T) ). cleanup_expansion(M:G/A) :- atom(G),integer(A),!, - compose_var_goal(G/A,GG), + functor(GG,G,A), \+ user:goal_expansion(GG,M,call_cleanup(M:GG)), assert(( user:goal_expansion(GG,M,NG) :- bb_get(expansion_toggle,1) @@ -154,15 +154,3 @@ cleanup_expansion(G/A) :- !,prolog_flag(typein_module,M),cleanup_expansion(M:G/A). cleanup_expansion(X) :- !,throw(error(instantiation_error,fragile(X))). - -compose_var_goal(G/A,NG) :- - arity_to_vars(A,L), NG =.. [G|L]. - -arity_to_vars(N,L) :- - arity_to_vars(N,[],L). -arity_to_vars(N,L1,L2) :- - N > 0, - NN is N-1, - LT = [L|L1], - arity_to_vars(NN,LT,L2). -arity_to_vars(0,L,L). -- 1.5.3.6 From 1b65988a0b6f31e025b018dbc75f3c1bb76d0c2e@a4.complang.tuwien.ac.at Tue May 26 15:13:26 2009 Return-path: <1b65988a0b6f31e025b018dbc75f3c1bb76d0c2e@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 26 May 2009 15:13:26 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <1b65988a0b6f31e025b018dbc75f3c1bb76d0c2e@a4.complang.tuwien.ac.at>) id 1M8wT8-0002Cu-25; Tue, 26 May 2009 15:13:26 +0200 From: Ulrich Neumerkel Date: Sun, 24 May 2009 00:38:27 +0200 Subject: [PATCH-YAP] DOC: minor Message-Id: --- docs/yap.tex | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index d58c159..349bcf7 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -6520,7 +6520,8 @@ execute_once_with_alarm(Time, Goal) :- ( call(Goal) -> alarm(0, alarm, _) ; alarm(0, alarm, _), fail). @end example -The procedure has three arguments: the @var{Time} before the alarm is +The procedure @code{once_with_alarm/3} has three arguments: +the @var{Time} to wait before the alarm is sent; the @var{Goal} to execute; and the goal @var{DoOnAlarm} to execute if the alarm is sent. It uses @code{catch/3} to handle the case the @code{alarm} is sent. Then it starts the alarm, calls the goal -- 1.5.3.6 From 88d8e983b75049fe981d67f8f25bbe1164b5445d@a4.complang.tuwien.ac.at Wed May 27 00:59:29 2009 Return-path: <88d8e983b75049fe981d67f8f25bbe1164b5445d@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Wed, 27 May 2009 00:59:29 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <88d8e983b75049fe981d67f8f25bbe1164b5445d@a4.complang.tuwien.ac.at>) id 1M95cG-0004KY-Tv; Wed, 27 May 2009 00:59:28 +0200 From: Ulrich Neumerkel Date: Wed, 27 May 2009 00:57:59 +0200 Subject: [PATCH-YAP] DOC: formatting Message-Id: --- docs/yap.tex | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index 349bcf7..62b411a 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -11112,7 +11112,7 @@ deterministic success, commit, or an exception. @var{Setup} will contain the goals that need to be protected from asynchronous interrupts such as the ones received from @code{call_with_time_limit/2} or @code{thread_signal/2}. In most uses, @var{Setup} will perform temporary side-effects required by -@var{Goal} that are finally undone by \arg{Cleanup}. +@var{Goal} that are finally undone by @var{Cleanup}. Success or failure of @var{Cleanup} is ignored and choice-points it created are destroyed (as @code{once/1}). If @var{Cleanup} throws an exception, @@ -11141,7 +11141,7 @@ term_in_stream(Term, In) :- Note that it is impossible to implement this predicate in Prolog other than by reading all terms into a list, close the file and call @code{member/2}. Without @code{setup_call_cleanup/3} there is no way to gain control if the -choice-point left by code{repeat} is removed by a cut or an exception. +choice-point left by @code{repeat} is removed by a cut or an exception. @code{setup_call_cleanup/2} can also be used to test determinism of a goal: @@ -11161,7 +11161,7 @@ For compatibility with other Prolog implementations see @code{call_cleanup/2}. @findex setup_call_catcher_cleanup/4 @snindex setup_call_catcher_cleanup/4 @cnindex setup_call_catcher_cleanup/4 -Similar to @code{setup_call_cleanup}{@var{Setup},@var{ Goal}, @var{Cleanup}} with +Similar to @code{setup_call_cleanup(@var{Setup}, @var{Goal}, @var{Cleanup})} with additional information on the reason of calling @var{Cleanup}. Prior to calling @var{Cleanup}, @var{Catcher} unifies with the termination code. If this unification fails, @var{Cleanup} is -- 1.5.3.6 From 6005d652ff6ecfcecdf25488aacbb41b591d4f75@a4.complang.tuwien.ac.at Wed May 27 22:56:19 2009 Return-path: <6005d652ff6ecfcecdf25488aacbb41b591d4f75@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Wed, 27 May 2009 22:56:19 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <6005d652ff6ecfcecdf25488aacbb41b591d4f75@a4.complang.tuwien.ac.at>) id 1M9QAd-0000XS-Hg; Wed, 27 May 2009 22:56:19 +0200 From: Ulrich Neumerkel Date: Wed, 27 May 2009 22:54:05 +0200 Subject: [PATCH-YAP] What's wrong with this one? Of course, the granularity of the alarms is a problem. And the inability to nest. Message-Id: --- library/timeout.yap | 74 +++++++++----------------------------------------- 1 files changed, 14 insertions(+), 60 deletions(-) diff --git a/library/timeout.yap b/library/timeout.yap index 427f131..44d0c82 100644 --- a/library/timeout.yap +++ b/library/timeout.yap @@ -24,67 +24,21 @@ % % not the nicest program I've ever seen. % -% -% I cannot use setup_call_cleanup because I can only take interrupts *after* I set up -% the catcher, so I have to do the dirty deed myself. -% + time_out(Goal, Time, Result) :- T is Time//1000, UT is (Time mod 1000)*1000, - yap_hacks:disable_interrupts, - % enable alarm - alarm(T.UT,throw(time_out),_), - % launch goal and wait for signal - catch( run_goal(Goal, Result0), - Exception, - handle_exception(Exception) ), + catch( ( Result0 = success, + setup_call_cleanup( + alarm(T.UT,throw(time_out),_), + Goal, + alarm(0,_,RT)), + ( var(RT) + -> alarm(0,_,RT), + ( true ; alarm(RT,throw(time_out),_) ) + ; true + ) + ), + time_out, + Result0 = time_out ), Result = Result0. - -run_goal(Goal, Result0) :- - % we can only enable interrupts after alarm was been enabled. - yap_hacks:enable_interrupts, - Result0 = success, - yap_hacks:current_choice_point(CP0), - call(Goal), - yap_hacks:current_choice_point(CP1), - % make sure we're not getting an extraneous interrupt if we terminate early.... - alarm(0,_,RT), - ( - CP0 == CP1 - -> - true - ; - ( - true - ; - alarm(RT,throw(time_out),_), - fail - ) - ). - -run_goal(_, _) :- - yap_hacks:disable_interrupts, - % make sure we're not getting an extraneous interrupt if we terminate early.... - alarm(0,_,_), - yap_hacks:enable_interrupts, - fail. - -complete_time_out :- - yap_hacks:disable_interrupts, - alarm(0,_,_), - yap_hacks:enable_interrupts. - - -handle_exception(Exception) :- - yap_hacks:disable_interrupts, - ( - Exception = time_out - -> - yap_hacks:enable_interrupts, - Result0 = time_out - ; - alarm(0,_,_), - yap_hacks:enable_interrupts, - throw(Exception) - ). - -- 1.5.3.6 From 2b6b1f034c207b67b69be287ed13204fff23bfb9@a4.complang.tuwien.ac.at Thu May 28 01:18:43 2009 Return-path: <2b6b1f034c207b67b69be287ed13204fff23bfb9@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Thu, 28 May 2009 01:18:43 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <2b6b1f034c207b67b69be287ed13204fff23bfb9@a4.complang.tuwien.ac.at>) id 1M9SOR-0004NQ-0u; Thu, 28 May 2009 01:18:43 +0200 From: Ulrich Neumerkel Date: Thu, 28 May 2009 01:15:02 +0200 Subject: [PATCH-YAP] time_out/3: Give every alternative the full timeout time #86 Message-Id: --- library/timeout.yap | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/timeout.yap b/library/timeout.yap index 44d0c82..f59c5bf 100644 --- a/library/timeout.yap +++ b/library/timeout.yap @@ -29,13 +29,13 @@ time_out(Goal, Time, Result) :- T is Time//1000, UT is (Time mod 1000)*1000, catch( ( Result0 = success, - setup_call_cleanup( + setup_call_cleanup( alarm(T.UT,throw(time_out),_), Goal, alarm(0,_,RT)), ( var(RT) - -> alarm(0,_,RT), - ( true ; alarm(RT,throw(time_out),_) ) + -> alarm(0,_,_), + ( true ; alarm(T.UT,throw(time_out),_) ) ; true ) ), -- 1.5.3.6 From 62e6c3abc09273f9a203790f0e4b9c1620ca809b@a4.complang.tuwien.ac.at Thu May 28 19:26:11 2009 Return-path: <62e6c3abc09273f9a203790f0e4b9c1620ca809b@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Thu, 28 May 2009 19:26:11 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <62e6c3abc09273f9a203790f0e4b9c1620ca809b@a4.complang.tuwien.ac.at>) id 1M9jMp-0000ZX-Gr; Thu, 28 May 2009 19:26:11 +0200 From: Ulrich Neumerkel Date: Thu, 28 May 2009 19:08:29 +0200 Subject: [PATCH-YAP] Introduction of errors for signal. In a case of conflict, 13211-1:7.12.2a is given precedence over 13211-2:6.7.1.4 Message-Id: --- pl/signals.yap | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pl/signals.yap b/pl/signals.yap index 5edc58e..e349389 100644 --- a/pl/signals.yap +++ b/pl/signals.yap @@ -215,8 +215,14 @@ on_signal(Signal,OldAction,Action) :- Action = OldAction. on_signal(Signal,OldAction,Action) :- '$reset_signal'(Signal, OldAction), - '$current_module'(M), - recordz('$signal_handler', action(Signal,M:Action), _). + % 13211-2 speaks only about callable + ( Action = M:Goal -> true ; throw(error(type_error(callable,Action),on_signal/3)) ), + % the following disagrees with 13211-2:6.7.1.4 which disagrees with 13211-1:7.12.2a + % but the following agrees with 13211-1:7.12.2a + ( nonvar(M) -> true ; throw(error(instantiation_error,on_signal/3)) ), + ( atom(M) -> true ; throw(error(type_error(callable,Action),on_signal/3)) ), + ( nonvar(Goal) -> true ; throw(error(instantiation_error,on_signal/3)) ), + recordz('$signal_handler', action(Signal,Action), _). '$reset_signal'(Signal, OldAction) :- recorded('$signal_handler', action(Signal,OldAction), Ref), !, -- 1.5.3.6 From c9adf985e373c3c7e1d4675fe3a7e112d31f0226@a4.complang.tuwien.ac.at Thu May 28 19:26:25 2009 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Thu, 28 May 2009 19:26:25 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from ) id 1M9jN2-0000aS-Vp; Thu, 28 May 2009 19:26:24 +0200 From: Ulrich Neumerkel Date: Thu, 28 May 2009 19:23:43 +0200 Subject: [PATCH-YAP] FIX #85 (defaultyness & meta_predicate), and thus #84, #82, #69 Message-Id: --- pl/signals.yap | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/pl/signals.yap b/pl/signals.yap index e349389..cdd121c 100644 --- a/pl/signals.yap +++ b/pl/signals.yap @@ -211,6 +211,10 @@ on_signal(Signal,OldAction,default) :- '$reset_signal'(Signal, OldAction). on_signal(Signal,OldAction,Action) :- var(Action), !, + throw(error(system_error,'Somehow the meta_predicate declarations of on_signal are subverted!')). +on_signal(Signal,OldAction,Action) :- + Action = (_:Goal), + var(Goal), !, '$check_signal'(Signal, OldAction), Action = OldAction. on_signal(Signal,OldAction,Action) :- @@ -235,6 +239,10 @@ on_signal(Signal,OldAction,Action) :- alarm(Interval, Goal, Left) :- + Interval == 0, !, + on_signal(sig_alarm, _, Goal), + '$alarm'(Interval, 0, Left, _). +alarm(Interval, Goal, Left) :- integer(Interval), !, on_signal(sig_alarm, _, Goal), '$alarm'(Interval, 0, Left, _). -- 1.5.3.6 From 41a35ef9ceac23bdd8879cf3ff2e7ef1e56c94de@a4.complang.tuwien.ac.at Fri May 29 00:17:44 2009 Return-path: <41a35ef9ceac23bdd8879cf3ff2e7ef1e56c94de@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Fri, 29 May 2009 00:17:44 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <41a35ef9ceac23bdd8879cf3ff2e7ef1e56c94de@a4.complang.tuwien.ac.at>) id 1M9nuy-0008SN-L2; Fri, 29 May 2009 00:17:44 +0200 From: Ulrich Neumerkel Date: Fri, 29 May 2009 00:15:40 +0200 Subject: [PATCH-YAP] Forgotten failure - found by #22 Message-Id: --- library/timeout.yap | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/library/timeout.yap b/library/timeout.yap index f59c5bf..d234a52 100644 --- a/library/timeout.yap +++ b/library/timeout.yap @@ -35,7 +35,7 @@ time_out(Goal, Time, Result) :- alarm(0,_,RT)), ( var(RT) -> alarm(0,_,_), - ( true ; alarm(T.UT,throw(time_out),_) ) + ( true ; alarm(T.UT,throw(time_out),_), fail ) ; true ) ), -- 1.5.3.6 From 3b9bf083befaf43cf31e6f412c8a891f8b86c685@a4.complang.tuwien.ac.at Mon Jun 01 23:44:21 2009 Return-path: <3b9bf083befaf43cf31e6f412c8a891f8b86c685@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 01 Jun 2009 23:44:21 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <3b9bf083befaf43cf31e6f412c8a891f8b86c685@a4.complang.tuwien.ac.at>) id 1MBFIr-0003TZ-6O; Mon, 01 Jun 2009 23:44:21 +0200 From: Ulrich Neumerkel Date: Sat, 30 May 2009 20:04:24 +0200 Subject: [PATCH-YAP] alarm(0,Any1,Any2) steadfast: Always disables alarm. Message-Id: --- pl/signals.yap | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/pl/signals.yap b/pl/signals.yap index cdd121c..cfc9ca5 100644 --- a/pl/signals.yap +++ b/pl/signals.yap @@ -240,8 +240,9 @@ on_signal(Signal,OldAction,Action) :- alarm(Interval, Goal, Left) :- Interval == 0, !, + '$alarm'(0, 0, Left0, _), on_signal(sig_alarm, _, Goal), - '$alarm'(Interval, 0, Left, _). + Left = Left0. alarm(Interval, Goal, Left) :- integer(Interval), !, on_signal(sig_alarm, _, Goal), -- 1.5.3.6 From 60eb1edfeb853aef3c7aba6ec2a1a3bdf9cb7fc9@a4.complang.tuwien.ac.at Tue Jun 02 20:24:48 2009 Return-path: <60eb1edfeb853aef3c7aba6ec2a1a3bdf9cb7fc9@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 02 Jun 2009 20:24:48 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <60eb1edfeb853aef3c7aba6ec2a1a3bdf9cb7fc9@a4.complang.tuwien.ac.at>) id 1MBYfI-0003kw-71; Tue, 02 Jun 2009 20:24:48 +0200 From: Ulrich Neumerkel Date: Tue, 2 Jun 2009 20:20:17 +0200 Subject: [PATCH-YAP] Forgotten change to virtual Message-Id: --- library/hacks.yap | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/library/hacks.yap b/library/hacks.yap index 1785c03..3b22640 100644 --- a/library/hacks.yap +++ b/library/hacks.yap @@ -44,7 +44,7 @@ virtual_alarm(Interval, Goal, Left) :- virtual_alarm(Interval, Goal, Left) :- integer(Interval), !, on_signal(sig_alarm, _, Goal), - alarm(Interval, 0, Left, _). + virtual_alarm(Interval, 0, Left, _). virtual_alarm(Interval.USecs, Goal, Left.LUSecs) :- on_signal(sig_alarm, _, Goal), virtual_alarm(Interval, USecs, Left, LUSecs). -- 1.5.3.6 From 86d84144ef5074c14a6e1f914eabb533d86d44b3@a4.complang.tuwien.ac.at Tue Jun 09 00:35:04 2009 Return-path: <86d84144ef5074c14a6e1f914eabb533d86d44b3@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 09 Jun 2009 00:35:04 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <86d84144ef5074c14a6e1f914eabb533d86d44b3@a4.complang.tuwien.ac.at>) id 1MDnQm-0002Sz-8R; Tue, 09 Jun 2009 00:35:04 +0200 From: Ulrich Neumerkel Date: Fri, 5 Jun 2009 09:54:25 +0200 Subject: [PATCH-YAP] Instantiation error for looping :- meta_predicate P. Message-Id: --- pl/modules.yap | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/pl/modules.yap b/pl/modules.yap index cbf44d3..362d1a3 100644 --- a/pl/modules.yap +++ b/pl/modules.yap @@ -400,6 +400,9 @@ module(N) :- :- multifile '$meta_predicate'/4. +'$meta_predicate'(P, M) :- + var(P), + '$do_error'(instantiation_error,module(M)). '$meta_predicate'((P,Ps), M) :- !, '$meta_predicate'(P, M), '$meta_predicate'(Ps, M). -- 1.5.3.6 From c29bf5e1135e5ef2b5b3e03bbe037be6d8b37685@a4.complang.tuwien.ac.at Tue Jun 09 00:35:16 2009 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 09 Jun 2009 00:35:16 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from ) id 1MDnQy-0002TA-Kc; Tue, 09 Jun 2009 00:35:16 +0200 From: Ulrich Neumerkel Date: Tue, 9 Jun 2009 00:32:01 +0200 Subject: [PATCH-YAP] Doc: module related Message-Id: --- docs/yap.tex | 81 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 43 insertions(+), 38 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index 62b411a..3495455 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -2089,13 +2089,12 @@ are global to the system. Moreover, the module system is flat, meaning that we do not support a hierarchy of modules. Modules can automatically import other modules, though. For compatibility with other module systems the YAP module system is non-strict, meaning both that -there is both a way to access predicates private to a module and that it +there is a way to access predicates private to a module and that it is possible to declare predicates for a module from some other module. YAP allows one to ignore the module system if one does not want to use it. Last note that using the module system does not introduce any -significant overheads: only meta-calls that cross module boundaries are -slowed down by the presence of modules. +significant overheads. @menu @@ -2145,7 +2144,7 @@ module. Otherwise, it is the module the file is being loaded into or the type-in module. One can override this rule by prefixing a goal with the module it is -supposed to be executed into, say: +supposed to be executed in, say: @example nasa:launch(apollo,13). @end example @@ -2165,17 +2164,18 @@ A new module is defined by a @code{module} declaration: @findex module/2 (directive) @syindex module/2 (directive) @cnindex module/2 (directive) -This predicate defines the file where it appears as a module file; it +This directive defines the file where it appears as a module file; it must be the first declaration in the file. @var{M} must be an atom specifying the module name; @var{L} must be a list containing the module's public predicates specification, in the form @code{[predicate_name/arity,...]}. The public predicates of a module file can be made accessible by other -files through the predicates @code{consult/1}, @code{reconsult/1}, -@code{ensure_loaded/1} or @code{use_module/2}. The non-public predicates +files through the directives @code{use_module/1}, @code{use_module/2}, +@code{ensure_loaded/1} and the predicates @code{consult/1} or +@code{reconsult/1}. The non-public predicates of a module file are not visible by other files; they can, however, be -accessed if the module name is prefixed to the file name through the +accessed by prefixing the module name with the @code{:/2} operator. @end table @@ -2187,8 +2187,8 @@ The built-in @code{module/1} sets the current source module: @findex module/3 (directive) @syindex module/3 (directive) @cnindex module/3 (directive) -Similar to @code{module/2}, this predicate defines the file where it -appears as a module file; it must be the first declaration in the file. +Similar to @code{module/2}, this directive defines the file where it +appears in as a module file; it must be the first declaration in the file. @var{M} must be an atom specifying the module name; @var{L} must be a list containing the module's public predicates specification, in the form @code{[predicate_name/arity,...]}. @@ -2264,27 +2264,22 @@ importing the predicates specified in the list @var{L}. The module system must know whether predicates operate on goals or clauses. Otherwise, such predicates would call a goal in the module they were defined, instead of calling it in the module they are currently -executing. So, for instance: +executing. So, for instance, consider a file example.pl: @example :- module(example,[a/1]). -... - a(G) :- call(G) - -... - @end example -The expected behavior for this procedure is to execute goal @var{G} -within the current module, that is, within @code{example}. -On the other hand, when executing @code{call/1} the system only knows -where @code{call/1} was defined, that is, it only knows of -@code{primitives}. A similar problem arises for @code{assert/1} and -friends. + +We import this module with @code{use_module(example)} into module +@code{user}. The expected behavior for a goal @code{a(p)} is to +execute goal @code{p} within the module @code{user}. However, +@code{a/1} will call @code{p} within module @code{example}. The @code{meta_predicate/1} declaration informs the system that some -arguments of a procedure are goals, clauses or clauses heads, and that -these arguments must be expanded to receive the current source module: +arguments of a predicate are goals, clauses, clauses heads or other +terms related to a module, and that these arguments must be prefixed +with the current source module: @table @code @@ -2292,35 +2287,44 @@ these arguments must be expanded to receive the current source module: @findex meta_predicate/1 (directive) @syindex meta_predicate/1 (directive) @cnindex meta_predicate/1 (directive) -Each @var{Gi} is a mode specification. For example, a declaration for -@code{call/1} and @code{setof/3} would be of the form: +Each @var{Gi} is a mode specification. + +If the argument is @code{:} or an integer, the argument is a call and +must be expanded. Otherwise, the argument is not expanded. Note +that the system already includes declarations for all built-ins. + +For example, the declaration for @code{call/1} and @code{setof/3} are: @example :- meta_predicate call(:), setof(?,:,?). @end example -If the argument is @code{:} or an integer, the argument is a call and -must be expanded. Otherwise, the argument should not be expanded. Note -that the system already includes declarations for all built-ins. - @end table - -In the previous example, the only argument to @code{call/1} must be -expanded, resulting in the following code: +The previous example is expanded to the following code which explains, +why the goal @code{a(p)} calls @code{p} in @code{example} and not in +@code{user}. The goal @code{call(G)} is expanded because of the +meta-predicate declaration for @code{call/1}. @example :- module(example,[a/1]). -... - a(G) :- call(example:G) +@end example -... +By adding a meta-predicate declaration for @code{a/1}, the goal +@code{a(p)} in module user will be expanded to @code{a(user:p)} +thereby preserving the module information. +@example +:- module(example,[a/1]). + +:- meta_predicate a(:). +a(G) :- call(G) @end example -You can avoid goal expansion by using @code{module_transparent/1}. +An alternate mechanism is the directive @code{module_transparent/1} +offered for compatibility with SWI-Prolog. @table @code @@ -2328,7 +2332,8 @@ You can avoid goal expansion by using @code{module_transparent/1}. @findex module_transparent/1 (directive) @syindex module_transparent/1 (directive) @cnindex module_transparent/1 (directive) - @var{Preds} is a comma separated list of name/arity pairs (like + @var{Preds} is a comma separated sequence of name/arity predicate + indicators (like @code{dynamic/1}). Each goal associated with a transparent declared predicate will inherit the context module from its parent goal. @end table -- 1.5.3.6 From 3d0a269df7d6e5bdff987f12abce2caa58281b06@a4.complang.tuwien.ac.at Thu Jun 11 05:34:50 2009 Return-path: <3d0a269df7d6e5bdff987f12abce2caa58281b06@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Thu, 11 Jun 2009 05:34:50 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <3d0a269df7d6e5bdff987f12abce2caa58281b06@a4.complang.tuwien.ac.at>) id 1MEb3x-00054v-TR; Thu, 11 Jun 2009 05:34:49 +0200 From: Ulrich Neumerkel Date: Thu, 11 Jun 2009 05:32:06 +0200 Subject: [PATCH-YAP] Operator change for ISO/SWI Message-Id: --- C/init.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/C/init.c b/C/init.c index efef8bb..ebe01d7 100644 --- a/C/init.c +++ b/C/init.c @@ -405,7 +405,7 @@ static Opdef Ops[] = { {"#", yfx, 500}, {"+", fx, 500}, {"-", fy, 200}, - {"\\", fx, 500}, + {"\\", fy, 200}, {"rdiv", yfx, 400}, {"*", yfx, 400}, {"/", yfx, 400}, -- 1.5.3.6 From 010cd1ba49f965f922752c571de2553dfd8c791d@a4.complang.tuwien.ac.at Mon Jun 15 02:44:56 2009 Return-path: <010cd1ba49f965f922752c571de2553dfd8c791d@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 15 Jun 2009 02:44:56 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.63) (envelope-from <010cd1ba49f965f922752c571de2553dfd8c791d@a4.complang.tuwien.ac.at>) id 1MG0Jj-00006s-Ri; Mon, 15 Jun 2009 02:44:56 +0200 From: Ulrich Neumerkel Date: Mon, 15 Jun 2009 02:41:52 +0200 Subject: [PATCH-YAP] typo Message-Id: --- docs/swi.tex | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/docs/swi.tex b/docs/swi.tex index 8b62940..c35d5e5 100644 --- a/docs/swi.tex +++ b/docs/swi.tex @@ -307,7 +307,7 @@ present. @snindex attr_unify_hook/2 @cnindex attr_unify_hook/2 Hook that must be defined in the module an attributed variable refers -to. Is is called @emph{after} the attributed variable has been +to. It is called @emph{after} the attributed variable has been unified with a non-var term, possibly another attributed variable. @var{AttValue} is the attribute that was associated to the variable in this module and @var{VarValue} is the new value of the variable. -- 1.5.3.6 From 878bc63ec8e4bcab1380019d74917fd42b71322d@a4.complang.tuwien.ac.at Sun Jul 11 13:44:39 2010 Return-path: <878bc63ec8e4bcab1380019d74917fd42b71322d@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sun, 11 Jul 2010 13:44:39 +0200 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from <878bc63ec8e4bcab1380019d74917fd42b71322d@a4.complang.tuwien.ac.at>) id 1OXuxb-0000Gu-4P; Sun, 11 Jul 2010 13:44:39 +0200 From: Ulrich Neumerkel Date: Sat, 10 Jul 2010 18:08:22 +0200 Subject: [PATCH-YAP] fix #168 setof/3, bagof/3 Message-Id: ?- setof(t,findall(t,true,[t],[]),[t]). Existence error for t/0. Now succeeds. --- pl/setof.yap | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pl/setof.yap b/pl/setof.yap index a626b69..5049a23 100644 --- a/pl/setof.yap +++ b/pl/setof.yap @@ -150,7 +150,7 @@ bagof(Template, Generator, Bag) :- '$excess_vars'((P,S), _, NY, L0, L). '$excess_vars'(findall(X,P,S), findall(X,P,S), Y, L0, L) :- !, '$excess_vars'(S, _, Y, L0, L). -'$excess_vars'(findall(X,P,S0,S), (X,P,S0,S), Y, L0, L) :- !, +'$excess_vars'(findall(X,P,S0,S), findall(X,P,S0,S), Y, L0, L) :- !, '$excess_vars'(S, _, Y, L0, L). '$excess_vars'(\+G, \+G, _, L0, LF) :- !, L0 = LF. -- 1.6.3.3 From af50a8a7d6231aa3141970f956788ae1be120771@a4.complang.tuwien.ac.at Thu Nov 04 14:34:51 2010 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Thu, 04 Nov 2010 14:34:51 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from ) id 1PDzxr-0008JO-Kb; Thu, 04 Nov 2010 14:34:51 +0100 From: Ulrich Neumerkel Date: Thu, 4 Nov 2010 14:34:22 +0100 Subject: [PATCH-YAP] Change + to fy, DTC2 Message-Id: --- C/init.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/C/init.c b/C/init.c index aa94df0..e4726f5 100755 --- a/C/init.c +++ b/C/init.c @@ -416,7 +416,7 @@ static Opdef Ops[] = { {">>", yfx, 400}, {"mod", yfx, 400}, {"rem", yfx, 400}, - {"+", fx, 200}, + {"+", fy, 200}, {"-", fy, 200}, {"\\", fy, 200}, {"//", yfx, 400}, -- 1.6.3.3 From ed5a410b9146c438898e26102424f92214bd1973@a4.complang.tuwien.ac.at Tue Nov 09 18:58:11 2010 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 09 Nov 2010 18:58:11 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from ) id 1PFsSR-0003yq-0I; Tue, 09 Nov 2010 18:58:11 +0100 From: Ulrich Neumerkel Date: Tue, 9 Nov 2010 18:57:35 +0100 Subject: [PATCH-YAP] ISO: Always bracket atoms that are current operators when written as operands (7.10.5 h 2 ii) Message-Id: --- C/write.c | 18 ++++-------------- 1 files changed, 4 insertions(+), 14 deletions(-) diff --git a/C/write.c b/C/write.c index cabb218..75c7884 100755 --- a/C/write.c +++ b/C/write.c @@ -303,16 +303,6 @@ legalAtom(unsigned char *s) /* Is this a legal atom ? */ return (TRUE); } -static int LeftOpToProtect(Atom at, int p) -{ - return Yap_IsOpMaxPrio(at) > p; -} - -static int RightOpToProtect(Atom at, int p) -{ - return Yap_IsOpMaxPrio(at) > p; -} - static wtype AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */ { @@ -788,7 +778,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str Term tright = ArgOfTerm(1, t); int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) && - RightOpToProtect(AtomOfTerm(tright), rp); + Yap_IsOp(AtomOfTerm(tright)); if (op > p) { /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ if (lastw != separator && !rinfixarg) @@ -818,7 +808,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str Int sl = 0; int bracket_left = !IsVarTerm(tleft) && IsAtomTerm(tleft) && - LeftOpToProtect(AtomOfTerm(tleft), lp); + Yap_IsOp(AtomOfTerm(tleft)); if (op > p) { /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ if (lastw != separator && !rinfixarg) @@ -858,10 +848,10 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str Int sl = 0; int bracket_left = !IsVarTerm(tleft) && IsAtomTerm(tleft) && - LeftOpToProtect(AtomOfTerm(tleft), lp); + Yap_IsOp(AtomOfTerm(tleft)); int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) && - RightOpToProtect(AtomOfTerm(tright), rp); + Yap_IsOp(AtomOfTerm(tright)); if (op > p) { /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ -- 1.6.3.3 From c51168591474bb23e5329644aa5364a8d3a786c4@a4.complang.tuwien.ac.at Sun Nov 14 00:29:51 2010 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Sun, 14 Nov 2010 00:29:51 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from ) id 1PHPXb-0004fw-30; Sun, 14 Nov 2010 00:29:51 +0100 From: Ulrich Neumerkel Date: Sun, 14 Nov 2010 00:23:56 +0100 Subject: [PATCH-YAP 2/2] ISO: conforming type errors for setof/3 etc Message-Id: --- pl/setof.yap | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pl/setof.yap b/pl/setof.yap index 5049a23..198c9d5 100644 --- a/pl/setof.yap +++ b/pl/setof.yap @@ -32,7 +32,11 @@ _^Goal :- findall(Template, Generator, Answers) :- - '$check_list_for_bags'(Answers, findall(Template, Generator, Answers)), + ( '$partial_list_or_list'(Answers) -> + true + ; + '$do_error'(type_error(list,Answers), findall(Template, Generator, Answers)) + ), '$findall'(Template, Generator, [], Answers). @@ -76,7 +80,11 @@ findall(Template, Generator, Answers, SoFar) :- % This is the setof predicate setof(Template, Generator, Set) :- - '$check_list_for_bags'(Set, setof(Template, Generator, Set)), + ( '$partial_list_or_list'(Set) -> + true + ; + '$do_error'(type_error(list,Set), setof(Template, Generator, Set)) + ), '$bagof'(Template, Generator, Bag), '$sort'(Bag, Set). @@ -87,10 +95,14 @@ setof(Template, Generator, Set) :- % of these variables bagof(Template, Generator, Bag) :- + ( '$partial_list_or_list'(Bag) -> + true + ; + '$do_error'(type_error(list,Bag), bagof(Template, Generator, Bag)) + ), '$bagof'(Template, Generator, Bag). - + '$bagof'(Template, Generator, Bag) :- - '$check_list_for_bags'(Bag, bagof(Template, Generator, Bag)), '$variables_in_term'(Template, [], TemplateV), '$excess_vars'(Generator, StrippedGenerator, TemplateV, [], FreeVars), ( FreeVars \== [] -> @@ -223,10 +235,8 @@ all(T,G,S) :- '$$split'([T1|Tn],T,X,S1,[T1|S2]) :- '$$split'(Tn,T,X,S1,S2). -'$check_list_for_bags'(V, _) :- var(V), !. -'$check_list_for_bags'([], _) :- !. -'$check_list_for_bags'([_|B], T) :- !, - '$check_list_for_bags'(B,T). -'$check_list_for_bags'(S, T) :- - '$do_error'(type_error(list,S),T). +'$partial_list_or_list'(V) :- var(V), !. +'$partial_list_or_list'([]) :- !. +'$partial_list_or_list'([_|B]) :- ! + '$partial_list_or_list'(B). -- 1.6.3.3 From 160c157117ab476fba76d8303fbb46fd48be2265@a4.complang.tuwien.ac.at Mon Nov 15 00:39:48 2010 Return-path: <160c157117ab476fba76d8303fbb46fd48be2265@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 15 Nov 2010 00:39:48 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from <160c157117ab476fba76d8303fbb46fd48be2265@a4.complang.tuwien.ac.at>) id 1PHmAm-0008EV-Ng; Mon, 15 Nov 2010 00:39:48 +0100 From: Ulrich Neumerkel Date: Mon, 15 Nov 2010 00:38:01 +0100 Subject: [PATCH-YAP 4/4] ISO: quote atoms starting with /* (7.10.5 d) Message-Id: --- C/write.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/C/write.c b/C/write.c index 75c7884..79cc460 100755 --- a/C/write.c +++ b/C/write.c @@ -285,6 +285,8 @@ legalAtom(unsigned char *s) /* Is this a legal atom ? */ return (*++s == ']' && !(*++s)); else if (ch == '{') return (*++s == '}' && !(*++s)); + else if (ch == '/') + return (*++s != '*'); else if (Yap_chtype[ch] == SL) return (!*++s); else if ((ch == ',' || ch == '.') && !s[1]) -- 1.6.3.3 From 1c023895ca90eba6537c8b568644702b53e7400e@a4.complang.tuwien.ac.at Mon Nov 15 00:40:41 2010 Return-path: <1c023895ca90eba6537c8b568644702b53e7400e@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 15 Nov 2010 00:40:41 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from <1c023895ca90eba6537c8b568644702b53e7400e@a4.complang.tuwien.ac.at>) id 1PHmBc-0008Fi-SD; Mon, 15 Nov 2010 00:40:40 +0100 From: Ulrich Neumerkel Date: Sun, 14 Nov 2010 20:52:05 +0100 Subject: [PATCH-YAP 3/4] ISO: Restrict binary, octal, hexadecimal integer constant indicators and exponent char to minuscules. (6.4.4) Message-Id: Invalidates: 0B1. 0O1. 0X1. 1E9. --- C/scanner.c | 26 +++++++++----------------- 1 files changed, 9 insertions(+), 17 deletions(-) diff --git a/C/scanner.c b/C/scanner.c index c856977..415b74e 100755 --- a/C/scanner.c +++ b/C/scanner.c @@ -547,7 +547,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted ch = Nxtch(inp_stream); } } - } else if ((ch == 'x' || ch == 'X') && base == 0) { + } else if (ch == 'x' && base == 0) { might_be_float = FALSE; if (--max_size == 0) { Yap_ErrorMessage = "Number Too Long"; @@ -571,11 +571,11 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted } *chp = ch; } - else if ((ch == 'o' || ch == 'O') && base == 0) { + else if (ch == 'o' && base == 0) { might_be_float = FALSE; base = 8; ch = Nxtch(inp_stream); - } else if ((ch == 'b' || ch == 'B') && base == 0) { + } else if (ch == 'b' && base == 0) { might_be_float = FALSE; base = 2; ch = Nxtch(inp_stream); @@ -602,7 +602,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted has_overflow = TRUE; ch = Nxtch(inp_stream); } - if (might_be_float && (ch == '.' || ch == 'e' || ch == 'E')) { + if (might_be_float && (ch == '.' || ch == 'e' )) { if (ch == '.') { if (--max_size == 0) { Yap_ErrorMessage = "Number Too Long"; @@ -628,7 +628,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted } while (chtype(ch = Nxtch(inp_stream)) == NU); } - if (ch == 'e' || ch == 'E') { + if (ch == 'e') { char *sp0 = sp; char cbuff = ch; @@ -654,15 +654,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted /* error */ char *sp; *chp = ch; - if (*sp0 == 'E') { - /* code the fact that we have E and not e */ - if (cbuff == '+') - *chbuffp = '='; - else - *chbuffp = '_'; - } else { - *chbuffp = cbuff; - } + *chbuffp = cbuff; *sp0 = '\0'; for (sp = s; sp < sp0; sp++) { if (*sp == '.') @@ -685,11 +677,11 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted *sp = '\0'; /* skip base */ *chp = ch; - if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) + if (s[0] == '0' && s[1] == 'x') return read_int_overflow(s+2,16,val,sign); - else if (s[0] == '0' && (s[1] == 'o' || s[1] == 'O')) + else if (s[0] == '0' && s[1] == 'o') return read_int_overflow(s+2,8,val,sign); - else if (s[0] == '0' && (s[1] == 'b' || s[1] == 'B')) + else if (s[0] == '0' && s[1] == 'b') return read_int_overflow(s+2,2,val,sign); if (s[1] == '\'') return read_int_overflow(s+2,base,val,sign); -- 1.6.3.3 From 845c3f3b61ba02f9e0ca144ddba4cd4619f29f16@a4.complang.tuwien.ac.at Mon Nov 15 19:03:16 2010 Return-path: <845c3f3b61ba02f9e0ca144ddba4cd4619f29f16@a4.complang.tuwien.ac.at> Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Mon, 15 Nov 2010 19:03:16 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from <845c3f3b61ba02f9e0ca144ddba4cd4619f29f16@a4.complang.tuwien.ac.at>) id 1PI3Oe-0002zl-1M; Mon, 15 Nov 2010 19:03:16 +0100 From: Ulrich Neumerkel Date: Mon, 15 Nov 2010 19:02:37 +0100 Subject: [PATCH-YAP 5/5] ISO: reject 1E1 as float notation Message-Id: --- C/scanner.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/C/scanner.c b/C/scanner.c index 801b0dd..e8b0c9a 100755 --- a/C/scanner.c +++ b/C/scanner.c @@ -602,7 +602,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted has_overflow = TRUE; ch = Nxtch(inp_stream); } - if (might_be_float && (ch == '.' || ch == 'e' || ch == 'E')) { + if (might_be_float && ch == '.') { if (ch == '.') { if (--max_size == 0) { Yap_ErrorMessage = "Number Too Long"; -- 1.6.3.3 From bc191c48efd9b4c5799d933686f8c1d9a3d4bbbe@a4.complang.tuwien.ac.at Tue Nov 16 16:28:03 2010 Return-path: Envelope-to: ulrich@a4.complang.tuwien.ac.at Delivery-date: Tue, 16 Nov 2010 16:28:03 +0100 Received: from ulrich by a4.complang.tuwien.ac.at with local (Exim 4.69) (envelope-from ) id 1PINRz-0006fr-1p; Tue, 16 Nov 2010 16:28:03 +0100 From: Ulrich Neumerkel Date: Tue, 16 Nov 2010 16:26:58 +0100 Subject: [PATCH-YAP 6/6] ISO: compound(+1). now holds. Message-Id: --- C/parser.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/C/parser.c b/C/parser.c index d10863f..664022c 100644 --- a/C/parser.c +++ b/C/parser.c @@ -456,10 +456,6 @@ ParseTerm(int prio, JMPBUFF *FailBuff) t = MkLongIntTerm(-LongIntOfTerm(t)); NextToken; break; - } else if ((Atom)t == AtomPlus) { - t = Yap_tokptr->TokInfo; - NextToken; - break; } } else if (Yap_tokptr->Tok == Name_tok) { Atom at = (Atom)Yap_tokptr->TokInfo; -- 1.6.3.3