[m-dev.] Re: Mercury Tcl/Tk interface broken

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Aug 26 14:20:10 AEST 1999


> I'm now trying to rebuild a version from just before this change.  I'll let 
> you know how it goes.

It will work, but for the wrong reason.

DJ and I just tracked down the cause of this. The problem is the handling
of the mode declaration for get:

:- pred get(tcl_interp, widget, string, io__state, io__state).
:- mode get(in, in(entry), out, di, uo) is det.
:- mode get(in, in(text), out, di, uo) is det.

The clauses for get are:

get(Interp, entry(Path), String) -->
        { string__format("%s get", [s(Path)], CmdStr) },
        eval(Interp, CmdStr, Res, String),
        { Res = tcl_ok -> true ; error(String) }.
get(Interp, text(Path), String) -->
        { string__format("%s get 1.0 end", [s(Path)], CmdStr) },
        eval(Interp, CmdStr, Res, String),
        { Res = tcl_ok -> true ; error(String) }.

These are turned into a disjunction, and in each mode of get, mode analysis
replaces the unification with Headvar2 in one arm of the disjunction with
fail.

The problem is that after this step, that arm of the disjunction reads
"Headvar1 = Interp, fail" instead of just "fail". Since removing code before
a fail may in general change the operational semantics, simplification does
not remove the arm of the disjunction, so the disjunction has one arm with
detism det and one arm with detism failure, so its overall detism is det.

In April Fergus changed unique mode checking so that any unique variable that
is live on entry to any disjunction, even a model-det disjunction like this
one, will be set to mostly_unique.

There are two changes we can make to fix this problem. First, Fergus should
change unique-mode checking again, so that what you check before making
a unique variable into only a mostly-unique variable is not the detism
of the disjunction, but the detism of the disjunct; you cannot backtrack
out of a det disjunct. This will avoid Warwick's problem without reintroducing
Serge's. The other is to modify simplication so that any sequence of primitive
unifications (i.e. any unification that cannot call a user-defined equality
predicate) followed by a fail are replaced by fail. This will allow the
existing code in simplification, which removes a disjunct if it consists
of only "fail", to kick in.

Fergus, can you please implement one or both of these fixes sometime soon?
I will start teaching the Mercury segment of 257 next week, and I may want
to use the tk interface as part of the project (I haven't decided yet).

To avoid similar problems in the future, we put the tcl interface, and
some client of it, in the tests directory. (We don't want a tk client,
the nightly tests shouldn't write on any terminal.)

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