[mercury-users] Pred defns
fjh at cs.mu.OZ.AU
Fri Apr 3 02:18:50 AEST 1998
On 31-Mar-1998, Peter Schachte <pets at students.cs.mu.oz.au> wrote:
> On Tue, 31 Mar 1998, Bart Demoen wrote:
> > The next step is not to require argument threading for implementing
> > this; it has problems related to modules and higher-order.
> I don't think the cross-module threading problem is much of problem: just
> require declarations of the "global variables" that are needed/defined by
> exported predicates. The rest can be inferred if you wish.
> Higher-order uses are more of a problem, but, I think, one that can be
Yes, you could include "hidden arguments" / "global variables" decls as part
of higher-order pred types, just as you made them part of pred declarations.
> As to implementation approach, Fergus and I came up with a simple Mercury
> extension that would allow the two approaches to be equivalent. The basic
> idea is to allow users to declare a "register" name, and then to associate
> at most one register with each predicate argument. This is a suggestion to
> the compiler to pass that argument in some special location, rather than the
> usual argument registers. Of course, only one or two arguments to a given
> predicate can be assigned the same register, and two only if the two
> arguments have in and out (or di, uo, or mdi, muo) modes in all modes for
> that predicate. This avoids shuffling these things around in argument
> registers. It basically gives you the performance of the non-threading
> approach without the (unnecessary) impurity of imperative global variables.
> Much nicer.
Yes, and it would work fine with multithreading, so long as these "registers"
are stored in thread-local storage rather than in global storage.
The only major drawback is that it would interact badly with exception
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 184.108.40.206 | -- the last words of T. S. Garp.
More information about the users