Article View: comp.lang.prolog
Article #1510Re: Writing portable code.
From: Micha Meier
Date: Tue, 29 Sep 1992 12:22
Date: Tue, 29 Sep 1992 12:22
43 lines
2487 bytes
2487 bytes
In article 1a3srjINNsgm@darkstar.UCSC.EDU, kjell@cse.ucsc.edu (Kjell Post) writes: > >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. It really depends on what you want to do with the source. If you want to have *exactly* the same source being compiled into different Prolog systems and work correctly, there is no straightforward way to do it, as there is no prolog_dialect/1 flag nor other portable way to identify the Prolog it is running on. The general idea is then to take the system which is less idiosyncratic about failing or undefined queries in a compiled file and write code which is then ignored by this system but executed by the other. The case of retractall is easy, but sometimes one needs to redefine a predicate using itself, which may be quite tricky. If the requirement is less strict, there are other ways: - Most prolog systems have an initialization file, e.g. .sicstusrc, .sepiarc, and you can put into it the compatibility stuff. Normally, since Sepia already has a SICStus compatibility library, all you'd have to do is to create a .sepiarc file and put into it the goal :- sicstus. - You can have a top-level file which is different for every different Prolog dialect. There one can have all sorts of compatibility stuff and the command to compile the common, 'portable' files. I am using this approach for my suite of test programs, as it is better than to rewrite existing, non-portable programs. - You can also wait for the standard to come out... :-) --Micha --- Micha Meier ------------------------------------------------ ECRC, Arabellastr. 17 The opinions expressed above are private D-8000 Munich 81 and may not reflect those of my employer. micha@ecrc.de, Tel. +49-89-92699-108, Fax +49-89-92699-170
Technical Details
Message-ID:
<1992Sep29.122242.27174@ecrc.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!ecrc!acrab6!michaReferences:
<1a3srjINNsgm@darkstar.UCSC.EDU>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!ecrc!acrab6!micha From: micha@ecrc.de (Micha Meier) Subject: Re: Writing portable code. Message-ID: <1992Sep29.122242.27174@ecrc.de> Sender: news@ecrc.de Reply-To: micha@ecrc.de Organization: European Computer-Industry Research Centre References: <1a3srjINNsgm@darkstar.UCSC.EDU> Date: Tue, 29 Sep 1992 12:22:42 GMT Lines: 44