Article View: comp.lang.prolog
Article #3620Re: Seattle tutorial prolog
From: Richard A. O'Keefe
Date: Tue, 30 Aug 1988 05:29
Date: Tue, 30 Aug 1988 05:29
55 lines
3276 bytes
3276 bytes
In article <1415@kulcs.kulcs.uucp> bimbart@kulcs.UUCP (Bart Demoen) writes:
>Tutorial No:8 of LP'88 Seattle (R. O'Keefe) makes 'interesting' reading, but
>be careful not to believe everything without checking it on the system
>you use; here is an example
>
How 'kind' of you. The example in question is introduced with the
sentence "Here is a good example of a crutch using Quintus Prolog."
^^^^^^^^^^^^^^^^^^^^
Nothing is claimed about the performance of the method in any other Prolog.
Demoen cites the following times in seconds using BIM Prolog on a Sun 3/50:
> C OK B
> -------------------
> 5.8 30.4 4.9
If I understand correctly,
C = the foreign interface version, adapted from my tutorial
OK = the 'assert' version, adapted from my tutorial
B = the 'rerecord' version, written by Demoen.
It is something of a relief to find that Demoen reports that using the
foreign interface *is* faster than using 'assert', by a fairly large
factor.
We have an old BIM Prolog manual, but I don't know where it is and it's
10pm, so there's no-one else to ask. I take it that rerecord(Key, Datum)
is a BIM Prolog feature which acts like conventional assignment. Other
versions of Prolog would have to pick up the old assignment and delete
it using recorded/3 and erase/1, which might easily treble the time, or
they might have some other method of their own.
It came as a further relief to find that the foreign interface version,
using Quintus Prolog on a Sun 3/50, took 4.6 seconds, so that my claim
that this kind of thing is best done *in Quintus Prolog* via the foreign
interface stands up. (Loop overhead was subtracted out of *none* of
these figures.)
rerecord/2, however efficient it may be, has the problem that the
'recorded' data base is a global resource (that, at least in DEC-10
Prolog, is one of the things it is _for_). If you use the 'recorded'
data base to hold gensym counters, you can't use it for anything else.
Neither of the two methods described in my tutorial interferes with
other uses of any global resource.
Demoen found two mistakes in the C code:
return p; /* Missing from make_counter() */
++*p; /* in increment_counter(), had been *p++ */
The first worked by accident in the compiler I was using, the second
made no difference to the timings. He kindly refrained from comment
on an equally serious mistake, which was that the result of malloc()
was being dereferenced without checking that it wasn't NULL, but
that one was deliberate sloppiness.
Would anyone finding mistakes in any draft of the tutorial please send
me E-mail, in case I miss comments sent here? (Please refer to section
names rather than page numbers; page numbers change a lot from draft to
draft.)
Technical Details
Message-ID:
<329@quintus.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!teknowledge-vaxc!sri-unix!quintus!okReferences:
<1415@kulcs.kulcs.uucp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!teknowledge-vaxc!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Seattle tutorial prolog Message-ID: <329@quintus.UUCP> Date: 30 Aug 88 05:29:51 GMT References: <1415@kulcs.kulcs.uucp> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 55