🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1494

Re: Writing portable code.

#1494
From: Paul Singleton
Date: Sun, 27 Sep 1992 14:00
33 lines
1954 bytes
From article <1a3srjINNsgm@darkstar.UCSC.EDU>, by kjell@cse.ucsc.edu (Kjell Post):
 
> Let me explain by an example what I'm looking for.  I want to write a
> program that works for both SICStus Prolog and Sepia.  The problem is
> that I need to retract all clauses foo/n when the program is started.
> Now, in SICStus the procedure is called retractall/2, but in Sepia it
> is retract_all/2.  That extra underscore (or absence of it) is really 
> annoying!  So I'd like to hear about efficient and portable tricks to
> write code that works in both languages.

    invent some novel name for the facility you require
    (e.g. retract_all_matching_unit_clauses)

    write your portable code in terms of this

    write compatibility libraries for each target Prolog implementation
    e.g.
	retract_all_matching_unit_clauses( X) :-
		retractall( X).

    to port to Prolog X:

	link your source with the Prolog X compatibility library (linking
	in Prolog is particularly trivial: 'cat' does it)

	feed the result through a general-purpose partial evaluator
	(e.g. Dan Sahlin's Mixtus) to eliminate the redundant procedures.

----
  __   __    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
Technical Details
Message-ID: <Bv8pLG.L9@gabriel.keele.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!mica.inel.gov!ux1!news.byu.edu!gatech!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!keele!news
References: <1a3srjINNsgm@darkstar.UCSC.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!mica.inel.gov!ux1!news.byu.edu!gatech!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!keele!news
From: csa09@seq1.keele.ac.uk (Paul Singleton)
Newsgroups: comp.lang.prolog
Subject: Re: Writing portable code.
Message-ID: <Bv8pLG.L9@gabriel.keele.ac.uk>
Date: 27 Sep 92 14:00:52 GMT
References: <1a3srjINNsgm@darkstar.UCSC.EDU>
Sender: news@gabriel.keele.ac.uk (UseNet News Service)
Organization: Keele University, England
Lines: 33
Nntp-Posting-Host: seq1.cc.keele.ac.uk