Article View: comp.lang.prolog
Article #3140Re: Compilation in Trilogy
From: Paul Voda
Date: Wed, 23 Mar 1988 19:44
Date: Wed, 23 Mar 1988 19:44
78 lines
3518 bytes
3518 bytes
In article <794@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
>In article <1897@ubc-cs.UUCP>, voda@ubc-cs (Paul Voda) writes:
>{ criticising Prolog }
>> ...
>
>{ praising Trilogy }
>> Trilogy is careful to preserve the logic in similar situation by copying out the
>> value of y into the variable x. ^^^^^^^
>
>When does Trilogy require copying? Does it use reference counting,
>as SETL used to, or is it a compile time analysis?
Typical O'Keefe he cannot resist inserting the cute remarks in the brackets!
Here is the answer formulated in a slightly more general setting:
The modes and types of Trilogy permit the native code compilation
of programs in such a way that there are no run-time tags on
most of the values, neither there are any reference counters.
The decision when to copy out and when to share the
values of input-output variables is done by a compile
time data-flow analysis. Similarly, the compiler of Trilogy checks whether
the output variables are assigned values in all branches of a predicate
(whether all input-output variables are initialized). There
is also a check to see that if-then-elses do not backtrack
(either before thens or among the branches), e.g.
if x = 1 | x = 2 then
x <> 1 & P(x)
else
......
end
The above is dissalowed by the compiler if x is output or
symbolic (logical), but is OK if x is input or input/output.
Thus we can guarantee that the negation of the formula
before a then is always properly computable.
Consequently if-then-elses and the formulas before thens
are compiled without any settings of choice points. We are
just releasing a version where non-backtracking ors (|)
(implemented by jumps instead of choice points) are permitted
in procedures (this is useful for the writing of the Trilogy
counterparts of Pascal's boolean functions).
There are two situations where the run-time tags on Trilogy values
are present:
1) the tags discriminating the union values, these should
be also present in Pascal programs.
For instance, the universal type U of all Trilogy's values has a
form of a union:
U = R(R) | S(S) | P(U,U)
The tags R(eal), S(tring), and P(air) are thus present in the
values of U variables.
If a value is not of a union type (tuple, list, array,
integer, enumerated-type etc.) then it contains no tags,
except of course the tags of any of its union constituents.
2) When a variable is of symbolic (logical) mode then Trilogy
uses the type specific tags to identify the constraints
attached to the variable (=, <, <>, etc.).
Because of the typing, modes, pred/proc modifiers and a quite extensive
data-flow analysis the compiler of Trilogy produces a procedural
code of Pascal-like quality while offering all the high-level
comfort of symbolic values with their associated constructors
and destructors as we know it from Prolog.
Technical Details
Message-ID:
<1901@ubc-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!oddjob!gargoyle!att-ih!alberta!ubc-cs!vodaReferences:
<4381@megaron.arizona.edu> <1897@ubc-cs.UUCP> <794@cresswell.quintus.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!oddjob!gargoyle!att-ih!alberta!ubc-cs!voda From: voda@ubc-cs (Paul Voda) Newsgroups: comp.lang.prolog Subject: Re: Compilation in Trilogy Message-ID: <1901@ubc-cs.UUCP> Date: 23 Mar 88 19:44:15 GMT References: <4381@megaron.arizona.edu> <1897@ubc-cs.UUCP> <794@cresswell.quintus.UUCP> Sender: nobody@ubc-cs.UUCP Reply-To: voda@ubc-cs.UUCP (Paul Voda) Organization: UBC Department of Computer Science, Vancouver, B.C., Canada Lines: 78 Keywords: run-time tags, reference counters