[m-dev.] Re: conditional compilation

Peter Wang novalazy at gmail.com
Wed Jan 6 13:50:41 AEDT 2010

On 2010-01-06, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> Hi all (and happy new year),
> On Tue, 5 Jan 2010, Peter Wang wrote:
> >On 2010-01-05, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
> >>On Tue, Jan 05, 2010 at 05:41:08PM +1100, Peter Wang wrote:
> >>>
> >>>With conditional implementation sections I could cleanly separate the
> >>>two completely different implementations, while providing the single
> >>>module interface.
> >>
> >>An extra benefit that we can get here is that the 'disabled' sections can be
> >>error checked but not compiled.  This can help us verify that these sections
> >>are correct even when they aren't applicable to the current backend/platform.
> >
> >Actually, probably not.
> I am strongly opposed to not always checking the conditional
> sections.  We already have this problem to some extent with Mercury
> clauses not being checked in the presence of foreign clauses.
> I definitely do not want C style conditional compilation (i.e. no
> checking of the alternatives) in Mercury.

That would only remain possible with simpler conditions, e.g. based on
the foreign language only.

I don't think conditional sections will be needed all that often.
In the situation I described, the altenatives are to:

    - clutter the source with a heap of dummy foreign procs
    - use a preprocessor to cut out irrelevant code
    - use different files implementating the same module

all of which are designed to bypass the compiler checking anyway.

> Some other observations related to this thread:
> (1) the reference manual doesn't actually specify what an implementation
> (or for that matter, interface) section is.  There is a long standing
> XXX regarding this.
> (2) It seems that with this feature then private interface files, .int0,
> will depend upon what compiler flags are given, i.e. they will have to
> become grade dependent (they currently aren't).
> (This assumes that the visibility rules for conditional implementation
> sections w.r.t to sub-modules are the normal ones.)

Grade-dependent won't be enough for arbitrary conditions.  Perhaps the
implementation sections will have to be kept and written out to to
interface files with their conditions.  I'm not sure.

.int files also contain a few things from implementation sections.

mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au

More information about the developers mailing list