[m-rev.] EDCG implementation
Peter Nicholas MALKIN
pnmalk at students.cs.mu.oz.au
Sat Mar 17 00:53:04 AEDT 2001
Hi,
On Fri, 16 Mar 2001, Ralph Becket wrote:
> Peter, it isn't immediately clear to me how far EDCG inference goes.
> What I hope it doesn't do is thread EDCG parameters through predicates
> that do not have appropriate edcg annotations in their declarations.
There are two modes of operation for EDCG inference:
(i) A single parse of the HLDS is performed to infer the form of use of
EDCGs for all predicates. In this case all that is happening is that EDCG
declarations are being checked to ensure that the actual form use of EDCGs
is compatible with the declared form of use. Any violation of this results
in an error. If an EDCG argument is not declared for a predicate then this
is taken to mean that the predicate does not use that EDCG argument.
Also, a warning will be given if the declared form is more strict
than the actual form; for instance, declaring a form of `passed' when the
actual form was `nothing' (not used at all). This is the default mode
of operation.
Actually I do not parse all predicates, but only those predicates which
have some EDCG constructs in them, which eliminates those predicates
which will not have any inferred forms for EDCGs arguments. Which
predicates to parse is determined during purity checking with minimal
overhead. This is also the case for EDCG expansion (HLDS -> HLDS
transformation). So if a program does not use EDCGs at all or only in a
few predicates then the compilation required for EDCGs is minimal.
(ii) Fixed point iteration is used to infer EDCG argument form of use for
all predicates. The inferred forms are then used in two ways. Firstly, if
a predicates has EDCGs declared then the declared forms are checked
against the inferred and any discrepancy will result in an error (or a
warning). Note that EDCG declarations for predicates are always all or
nothing. If not all EDCG arguments are listed in a declaration then those
not listed are assumed to have a form of `nothing'. It is not possible to
just declare forms for some EDCG arguments for a predicate and let the
compiler infer the forms for the rest, that is an error. Secondly,
if a predicate has no EDCG arguments declared and some are inferred, then
the inferred forms are output and an EDCG transformation is performed
(without an error given).
This time all predicates are parsed repeatedly for fixed point iteration.
However, again for EDCG expansion only those predicates requiring
expansion are parsed.
In summary:
- EDCG predicate declarations are complete and final, and cannot
be circumvented.
- Predicates without EDCG declarations can have EDCG argument
forms inferred but only if specified (compiler option
`--infer-edcgs').
NB: EDCG goals are treated, in both modes of operation, like predicates
with declared EDCG arguments forms. Declared forms for EDCG goals are
always checked against inferred forms.
The second mode of operation is not expected to be used repeatedly but
only occasionally, once or twice, when new EDCG arguments are added to the
source.
Peter
P.S. I recognise that this particular way of approaching inference is
not necessarily better than other ways. There is a lot of possible
variation. This is just the way I chose to implement it, based loosely
upon how typecheck approaches inference. I am, as always, open to
suggestions.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list