[m-dev.] Re: conditional compilation

Peter Wang novalazy at gmail.com
Tue Jan 5 17:41:08 AEDT 2010


2009/3/25 Peter Wang <novalazy at gmail.com>:
> Hi,
>
> 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"))).
...
> 2. Modules which paper over platform differences or work with optional
> dependencies would be easier to write, or become possible without an
> explicitly preprocessing pass.  Any number of situations, really.

I didn't get any response to this last year. Today I came across
another situation where it would really help.

The problem is that I have a Mercury+C implementation of a network
protocol. In Java grades I don't want that implementation, I want to
call an external Java library instead. I can use "Java" foreign_procs
to override the Mercury predicates, and foreign_types to override the
Mercury types. However, I'd also have to override any internal
predicates used in the Mercury+C implementation even if they aren't
used in the Java grade, because those predicates access fields in the
Mercury types which are overridden.

With conditional implementation sections I could cleanly separate the
two completely different implementations, while providing the single
module interface.

Peter

--------------------------------------------------------------------------
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