[m-dev.] Re: conditional compilation

Zoltan Somogyi zs at csse.unimelb.edu.au
Wed Jan 6 08:50:07 AEDT 2010

On 05-Jan-2010, Peter Wang <novalazy at gmail.com> wrote:
> > Here is another idea: conditional sections, where a section is kept or
> > omitted depending on compile time flags and/or grades.  If we borrow the
> > feature from trace goals, we might have something like this:
> >
> >    :- implementation(not(flag("production"))).

I don't have objection to this feature being added, but I think adding it
would be quite complicated.

The reason is that the parse tree currently does not have any representation
of sections of any kind in the source code. All it has is a list of items
with no further structure on top of that. This means that this feature would
have to be implemented by either (a) evaluating the conditions as the items are
read, and immediately discarding both the items in the unwanted sections *and*
the markers surrounding it, or (b) *all* the parts of the compiler that scan
the item list, which are already complicated enough partly because of the lack
of documentation of the rules they follow, would have to become significantly
more complicated still.

I have long-term plans for changing the representation of the parse tree
to impose structure on the item list, but this won't happen soon.

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