Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!europa.eng.gtefsd.com!howland.reston.ans.net!news.sprintlink.net!EU.net!uknet!festival!hwcee!andrew
From: andrew@cee.hw.ac.uk (Andrew Dinn)
Subject: Re: numbervars/3 bug in Quintus and Sicstus
Message-ID: <CyDrHs.HwG@cee.hw.ac.uk>
Sender: news@cee.hw.ac.uk (News Administrator)
Organization: Dept of Computing and Electrical Engineering, Heriot-Watt University
X-Newsreader: TIN [version 1.2 PL2]
References: <38jqt7$5bn@coli-gate.coli.uni-sb.de> <PEREIRA.94Oct25231821@alta.research.att.com> <38lgc9$m8k@coli-gate.coli.uni-sb.de>
Date: Fri, 28 Oct 1994 11:20:14 GMT
Lines: 41

Gregor Erbach (erbach@coli.uni-sb.de) wrote:
: pereira@alta.research.att.com (Fernando Pereira) writes:

: >In article <38jqt7$5bn@coli-gate.coli.uni-sb.de> erbach@coli.uni-sb.de (Gregor Erbach) writes:

[regarding numbervars munging of '$VAR'/1 terms]

: There is some confusion here. My program does not use terms with functor
: '$VAR'/1, but a user of my system uses the '$VAR'/1 terms exactly with
: the purpose of matching against the results of numbervars/3. However,
: when his program is compiled into a Prolog program, a term '$VAR'(_) is
: just replaced by a variable.

This is because the compiler applies the numbervars transformation to
each clause it reads so that it can detect and correctly handle
non-ground clauses. So, the '$VAR'/1 term is assumed to arise from the
numbering process rather than the source.

There is a standard workaround when writing programs which expect to
handle '$VAR'/1 terms which is not to write the '$VAR'/1 terms
literally in the code but to manipulate them using functor and arg
e.g. replace clauses of the form

    user_pred('$VAR'(_), ...) :-
	...

with

    user_pred(V, ...) :-
	functor(V, '$VAR', 1),
	...

and so on.

The above workaround is common in compiler code to allow the compiler
itself to refer to '$VAR'/1 terms without mentioning them directly.


Andrew Dinn
-----------
there is no map / and a compass / wouldn't help at all
