[m-dev.] clauses --> switches
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri May 29 18:00:03 AEST 1998
On 29-May-1998, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> Let's consider a Mercury predicate defining by several clauses.
> Is it true to say that those clauses will be converted into exactly one
> switch ?
No.
> Are there some cases where it can be splited into several
> switches (on different arguments of the predicate) ?
Yes, either on different arguments of the predicate, or
on different parts of the same argument. E.g.
:- type foo ---> f(char) ; g(char, char).
:- pred p(foo, int).
:- mode p(in, out).
p(f(a), 1).
p(f(b), 2).
p(g(c,d), 3).
p(g(c,e), 4).
This will be split into three switches. The top-level switch will switch
between the first argument being f/1 and g/2. The switch in the one
branch of the main switch will switch between the first argument of
the functor f/1 being a/0 and b/0. The switch in the other branch of
the main switch will switch between the second argument of g/2
being d/0 or e/0.
> In other words, is it true to say that a goalpath of the form "s1;..."
> corresponds to an event occuring in the first clause, "s2;..." in the
> second clause, ... ?
No.
--
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 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list