Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!news.alpha.net!uwm.edu!cs.utexas.edu!uunet!allegra!ulysses!alice!pereira
From: pereira@alta.research.att.com (Fernando Pereira)
Subject: Re: numbervars/3 bug in Quintus and Sicstus
In-Reply-To: erbach@coli.uni-sb.de's message of 25 Oct 1994 21:47:35 +0100
Message-ID: <PEREIRA.94Oct25231821@alta.research.att.com>
Sender: netnews@ulysses.homer.att.com (Shankar Ishwar)
Reply-To: pereira@research.att.com
Organization: AT&T Bell Laboratories
References: <38jqt7$5bn@coli-gate.coli.uni-sb.de>
Date: Wed, 26 Oct 1994 03:18:20 GMT
Lines: 41

In article <38jqt7$5bn@coli-gate.coli.uni-sb.de> erbach@coli.uni-sb.de (Gregor Erbach) writes:
> The Sicstus manual states that numbervars(Term,FirstVar,LastVar)
>
>    Unifies each of the variables in term @var{Term} with a special term ...
>
> Consider what happens when I call
>
>    ?- numbervars('$VAR'(X),0,N).
>
> The solution I get is X = 0, N = 1; instead 
> of the expected X = '$VAR'(0), N = 1. 
>
> Btw, the same happens with Quintus Prolog (and its ancestors all the way
> back to C-Prolog?).

> I consider this a bug that should be fixed, and it is causing me some
> trouble in an application where I transform a Prolog program with sorted
> feature terms into a Prolog program in which the sorted feature terms are
> replaced by their Prolog term representation.
It is not a bug, it was designed to behave as you describe back in
DEC-10 Prolog. There's absolutely no reason for your program to use
terms with functor '$VAR'/1 except when matching against the results
of numbervars/3, which may contain ground terms with that principal
functor.
> When I write the output into
> a file, I want to use numbervars/3 to get a neat output, but I want any
> terms of the form '$VAR'(_X123) to be replaced by terms like '$VAR'(A), 
> and not by terms like A, as it is the case with the current implementation.
Unfortunately, almost everyone else wants the implemented behavior,
since one of the main uses of numbervars/3 is to make a term printable
with nice alaphabetic variable names. Again, why should your
compilation of sorted feature terms into Prolog terms have to generate
'$VAR'/1 terms at all? There are plenty of other functor names out
there...

--
Fernando Pereira
2D-447, AT&T Bell Laboratories
600 Mountain Ave, PO Box 636
Murray Hill, NJ 07974-0636
pereira@research.att.com
