[m-dev.] trace goal `state' parameters

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Mar 16 02:15:58 AEDT 2007

Currently trace goals support a "state" parameter that allows one to specify
the name of a mutable and the name of a state variable that is used to
thread the value of the mutable through the body of the trace goal.  This
arrangement is currently a bit delicate w.r.t intermodule optimization.  If
the clause containing the trace goal ends up in the .opt file there is no
guarantee that the predmode decls for the mutable access preds will also end
up there.

Another minor problem is that the compiler does deal with attempts to
specify a constant mutable in the state parameter particularly gracefully.
(You will get an error message about a missing set_ predicate).

In fact state parameters aren't really as useful as they might seem since
they are implicitly subject to the same visibility restrictions that
mutables are.  For mutables these restrictions are what we want** but it
doesn't really make sense for state parameters.  The logging example in the
reference manual is a case in point; I would like to be able to refer to the
logging level in many modules - it is truly global, however mutables are
(intentionally) module local.  Currently the only way to "export" a mutable
it to manually introduce access predicates for it in the interface of a
module.  (This won't work with trace goals since the transformation that
handles state parameters knows nothing of the manually introduced

(** at least they were the ones we wanted when we designed mutables)

As I see it we can either remove support for state parameters in trace
goals or modify the compiler's support for mutables to make them work
safely.  The latter IMO will be a fairly large piece of work since it
involves adding several things, e.g. exported mutables, that the current
implementation was never designed to handle.

My choice would be to remove support for state parameters.

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