Xref: utzoo comp.sys.amiga:20951 comp.lang.prolog:1075 Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!mailrus!cornell!uw-beaver!teknowledge-vaxc!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.sys.amiga,comp.lang.prolog Subject: Re: SBProlog and clause/2.. Message-ID: <166@quintus.UUCP> Date: 11 Jul 88 02:18:18 GMT References: <732@kuling.UUCP> <6183@megaron.arizona.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 25 In article <6183@megaron.arizona.edu> debray@arizona.edu (Saumya Debray) writes: >In article <732@kuling.UUCP>, jonasf@kuling.UUCP (Jonas Flygare) writes: >> I would appreciate any help on implementing clause/2 in SBProlog ... >Meanwhile, the following quick hack provides a poor man's clause/2 on >sbprolog: [ He exhibits a variant of assert which stores two copies of the clause. ] A little bit of history may be of interest: one of the design goals of the Prolog system Lawrence Byrd and Bill Clocksin put together (which later became Bill Clocksin's Prolog-X) was that there shouldn't be any distinction between compiled and interpreted code. (This was '82, I think.) So the ZIP instructions had three modes: read, write, and copy. (This is similar to the techniques that ALS use, except they are WAM-based rather than ZIP-based.) However, it was found that this put too much of a burden on the compiler: it couldn't even optimise "p :- q, true, true" to "p :- q" because clause/[2,3] had to see the original code. (This is why my 1984 proposal for Prolog evaluable predicates specified that assert/1 _should_ be allowed to make this kind of change, by the way.) So eventually Bill Clocksin ended up compiling two copies of each and every clause (and assert/1 compiles). If I recall correctly, a specialised version of the compiler was created for unit clauses so that the second copy could be compiled faster, and of course that made life better for setof/3 as well. Oddly enough, ZIP code was very compact, so compiling two copies of a clause in Prolog-X took less space than asserting one copy in many other Prologs.