🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1511

Re: Writing portable code.

#1511
From: Jose Alberto Fernandez R
Date: Tue, 29 Sep 1992 16:41
53 lines
2745 bytes
In article <BvBEny.4M8@gabriel.keele.ac.uk> csa09@seq1.keele.ac.uk (Paul Singleton) writes:

   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?  

I have some problems in using partial evaluation as the means of
achieving this. In particular the partial evaluator will modify not
only those parts of the program that have to do with the dialects but
it will also modify other parts of the program that have nothing to do
with it. If for example, the code represents a library, you have two
alternatives:

1) To partially evaluate the code when the libraries are installed, in
this case the version of the libraries the the users have access to,
have been partially evaluated and therefore its logical structure has
being modified. It will not be easy to read since many predicates have
beeing optimized (partially evaluated).

2) To partially evaluate the code when the library is loaded. In this
case, the system must doit automatically. You can not put the burden
of nowing what must be partially evaluated and what not, to the user
of a shipped peace of software.

The advantage of using a macro processor (not necessarily CPP) is that
the instalation language is separated from the object language. It is
very clear what is a statement about how to install the software and
what is a statement of the code of the language.
With partial evaluation we mix the two as if they were talking about
the same thing.

	Jose Alberto.

--
:/       \ Jose Alberto Fernandez R | INTERNET: alberto@cs.umd.edu
:| o   o | Dept. of Computer Sc.    | BITNET: alberto@cs.umd.edu
:|   ^   | University of Maryland   | UUCP: {...}!mimsy!alberto
:\  \_/  / College Park, MD 20742   | 
Technical Details
Message-ID: <ALBERTO.92Sep29124149@karna.cs.umd.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!swrinde!sdd.hp.com!uakari.primate.wisc.edu!ames!nsisrv!mimsy!mimsy.umd.edu!alberto
References: <ALBERTO.92Sep28113506@karna.cs.umd.edu> <BvBEny.4M8@gabriel.keele.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!swrinde!sdd.hp.com!uakari.primate.wisc.edu!ames!nsisrv!mimsy!mimsy.umd.edu!alberto
From: alberto@cs.umd.edu (Jose Alberto Fernandez R)
Newsgroups: comp.lang.prolog
Subject: Re: Writing portable code.
Message-ID: <ALBERTO.92Sep29124149@karna.cs.umd.edu>
Date: 29 Sep 92 16:41:49 GMT
References: <ALBERTO.92Sep28113506@karna.cs.umd.edu> <BvBEny.4M8@gabriel.keele.ac.uk>
Sender: news@mimsy.umd.edu
Organization: University of Maryland Computer Sc.
Lines: 53
In-reply-to: csa09@seq1.keele.ac.uk's message of 29 Sep 92 00:57:33 GMT