[m-dev.] logging proposal

Mark Brown mark at cs.mu.OZ.AU
Tue Feb 28 01:22:30 AEDT 2006


On 27-Feb-2006, Michael Day <mikeday at yeslogic.com> wrote:
> 
> > We add a special procedure `log' to the builtin module.  The new
> > procedure takes a string as input (or possibly an I/O closure).  The
> > compiler is then modified to treat calls to log as being the same as
> > true, unless an "--enable-logging" options is given.  If this option is
> > given then the logging predicates write their output somewhere (where
> > they write their output could be given by another mmc option).
> 
> If log was defined like this:
> 
>     :- pred log(string :: in) is det.
> 
> then could it potentially be reordered within this predicate:
> 
>     log("about to do something"),
>     do_something(!IO),
>     log("about to do something else"),
>     do_something_else(!IO)
> 
> as it seems that logically, the two calls to log are independent and could
> be reordered (or of course removed entirely, as they have no output).

I think what Ian is proposing is that the compiler would be aware of the
special nature of this predicate, and would treat it appropriately.  I'm
not sure whether he was intending the procedure to be impure, but even if
it wasn't explicitly impure the compiler would need to treat it as if it
implicitly was.

For the record, I don't see any good reason to make the procedure impure,
even though it has side effects.  After all, we still consider ordinary
Mercury code to be pure even when running it under mdb (where it has the
side effect of interacting with the debugger).

Cheers,
Mark.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list