[mercury-users] Conditional compilation

Peter Hawkins peter at hawkins.emu.id.au
Tue Aug 16 14:46:26 AEST 2005


Hi...

Is there a way of having conditionally compiled debugging code in Mercury?

I tried this:

:- pred debugging is semidet.
debugging :- semidet_fail.
or
debugging :- semidet_succeed.

main(!IO) :-
    (if debugging then
       do stuff
     else
       true
    )

Unfortunately the mercury compiler doesn't optimize away the 
if-then-else, even if I add a :- pragma inline to the debugging 
predicate. The only way to avoid a runtime slowdown is to declare the 
debugging predicate like this:
:- pred debugging is failure.
or
:- pred debugging is det.
but this leads to a compiler warning whenever you actually use it.

Does anyone have any suggestions as to how I can have debugging code 
that I can turn off?

=)
Peter
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list