Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

FAQ: Prolog Resource Guide 1/2 [Monthly posting]
Section - [1-14] How do you write portable programs in Prolog?

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Airports ]


Top Document: FAQ: Prolog Resource Guide 1/2 [Monthly posting]
Previous Document: [1-13] What is Constraint Logic Programming?
Next Document: [1-15] World-Wide Web (WWW) Resources
See reader questions & answers on this topic! - Help others by sharing your knowledge

The de-facto standard syntax for Prolog is known as the Edinburgh
standard. It is based on the syntax of DEC-10 Prolog, an early Prolog
implementation developed at the University of Edinburgh.
See question [1-1] for information on the draft ISO standard for
Prolog.

Unfortunately, not every Prolog implementation is Edinburgh compatible.
There also isn't any notion of read-conditionalization, like #+ and #-
*features* in Common Lisp. 

One option is to use the C preprocessor on Prolog code before loading
it into Prolog.  Or you could use term-expansion to roll your own
conditional compilation system. Term expanding a clause to []
effectively discards it.

Another possibility is to conditionalize the execution instead of the
compilation. The user would have to uncomment a line like one of the
following, 
   % this_is(quintus).
   % this_is(sicstus).    
and the code would have to test for the proper literal
   a :- this_is(quintus), blah, blah, blah.
   a :- this_is(sicstus), blah, blah, blah.
at a slight cost in efficiency. (If you first feed the program through
a general partial evaluator, you'll get an equivalent program without
the inefficiency. Partial evaluation is in some sense a more powerful
and semantically cleaner form of source preprocessing. Given
        <head> :- <condition>, <rest of body>.
If <condition> is always false, we can safely drop the clause. If
<condition> is always true, we can drop it from any clauses that
include it.) 

Another possibility is Richard O'Keefe's environment package for
Prolog. It was posted to comp.lang.prolog on 1-SEP-94; a copy can be
found in
   ftp://ftp.cs.cmu.edu/user/ai/lang/prolog/code/ext/env/

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: FAQ: Prolog Resource Guide 1/2 [Monthly posting]
Previous Document: [1-13] What is Constraint Logic Programming?
Next Document: [1-15] World-Wide Web (WWW) Resources

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
mkant+prg@cs.cmu.edu





Last Update March 27 2014 @ 02:12 PM