Article View: comp.lang.prolog
Article #1531Re: Writing portable code./partial evaluation
From: goldsmig
Date: Thu, 01 Oct 1992 15:44
Date: Thu, 01 Oct 1992 15:44
46 lines
2316 bytes
2316 bytes
In article <BvBEny.4M8@gabriel.keele.ac.uk>, csa09@seq1.keele.ac.uk (Paul Singleton) writes: > From article <ALBERTO.92Sep28113506@karna.cs.umd.edu>, by alberto@cs.umd.edu (Jose Alberto Fernandez R): > >> One way to solve this is to use in the code macro commands that >> expand to the right thing for each system. Assume that your >> distributed source code is in files with extensions `.pli'. >> In your case, the macro definitions look something like this: >> >> #ifdef SEPIA >> #define RETRACTALL(x) retract_all(x) >> #else >> #define RETRACTALL(x) retractall(x) >> #endif >> >> and in your code you use the macro RETRACTALL(x): >> >> ...:- ..., RETRACTALL(foo(X,Y)), .... >>... >> It would be nice if a facility like this would have been provided as >> part of the language. Then we wouldn't need to borrow tools from 'C'. > > Prolog is a sufficiently wide-spectrum language that we don't need to > borrow bolt-on programming-in-the-large languages. I think if we write > > retract_all_unit_clause( X) :- > ( dialect( sepia) > -> retract_all( X) > ; dialect( sicstus) > -> retractall( X) > ). > > then add either > > dialect( sepia). > or > dialect( sicstus). > > as a fact, and partially evaluate the program, we get the effect of macro > substitution. Isn't this a neater way of doing things? > ---- > __ __ Paul Singleton (Mr) JANET: paul@uk.ac.keele.cs > |__) (__ Computer Science Dept. other: paul@cs.keele.ac.uk > | . __). Keele University, Newcastle, tel: +44 (0)782 621111 x7355 > Staffs ST5 5BG, ENGLAND fax: +44 (0)782 713082 Sorry to be on the ignorant side, but what is meant by partial evaluation?
Technical Details
Message-ID:
<1992Oct1.074401.1@cgsvax.claremont.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!swrinde!sdd.hp.com!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!news.claremont.edu!cgsvax.claremont.edu!goldsmigReferences:
<ALBERTO.92Sep28113506@karna.cs.umd.edu> <BvBEny.4M8@gabriel.keele.ac.uk>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!swrinde!sdd.hp.com!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!news.claremont.edu!cgsvax.claremont.edu!goldsmig From: goldsmig@cgsvax.claremont.edu Subject: Re: Writing portable code./partial evaluation Message-ID: <1992Oct1.074401.1@cgsvax.claremont.edu> Lines: 46 Sender: news@muddcs.claremont.edu (The News System) Organization: The Claremont Graduate School References: <ALBERTO.92Sep28113506@karna.cs.umd.edu> <BvBEny.4M8@gabriel.keele.ac.uk> Date: 1 Oct 92 07:44:01 PST