[m-dev.] Re: bug in scoping for higher order terms

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Mar 8 16:17:21 AEDT 1999


On 08-Mar-1999, Lee Naish <lee at cs.mu.OZ.AU> wrote:
> 
> If you look at Prolog, it has basically the same scope/quantifier
> problem for aggregates.  Mercury avoids the problem with aggregates by
> using solutions/2 which accepts a closure.  This just make the same
> problem re-appear when creating closures.
> 
> The standard Prolog solution is to treat as quantified all variables
> appearing in the first argument of setof.  [...]

Actually it's more complicated than that.  Variables in the first argument
of setof are treated as locally quantified only if (at runtime) they are
uninstantiated.  If the they are happen to be ground at runtime, then
they are treated as being unquantified.
(Perhaps that's what you mean by saying that it is
"not done properly and its all not quite logical" ;-)

My point here is that Prolog sometimes locally quantifies the arguments and
sometimes doesn't, depending on the instantiation of variables at runtime,
so it doesn't set any clear precedent.

> Its cleaned up in NU-Prolog's solutions/3, which (properly) quantifies
> and scopes all variables in the first argument.  Variables in the second
> argument use the default NU-Prolog quantification rule (quantify if the
> variable occurs uniquely in the clause).

Actually this is only true of the NU-Prolog compiler.
The NU-Prolog interpreter doesn't get the quantification right,
instead it does much the same thing as Prolog.
So although NU-Prolog does provide some precedent, it isn't as
strong a precedent as it could be.

Thus I suggest that it is probably better to make a decision
based on general design considerations rather than precedent.
Of course, those considerations may well lead us to
the same conclusion.

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