Subject: Re: tree and _X

From: Jan Wielemaker <[email-masked]>
Date: Fri, 15 Sep 2000 14:24:25 +0200

On Fri, 15 Sep 2000, Nicos Angelopoulos wrote:
>On Fri, 15 Sep 2000, Waseem Besada wrote:

>> another question:
>> 
>> What is the difference between a variable wriiten as X and _X ?

>	_X is an anonymous variable which normaly is used to 
>	signal to the compiler that s/he shouldnt worry about the
>	fact that this variable appears only once in the current 
>	clause
>
>	for instance 
>
>isnogood( Z ) :-
>	isnosobad( X, Z ).
>
>	will (normaly) raise a warning when compiled/consulted
>	whereas if you replace X by _X the warning disappears 

Not completely true.  The only anonymous variable in Prolog is
the sole '_' character: even if multiple occur in the same term
(clause) they are not unified.  If multiple _Name variables occur
in a term they do unify:

1 ?- write(foo(_,_)).
foo(_G252, _G253)

Yes
2 ?- write(foo(_X,_X)).
foo(_G264, _G264)

The compiler indeed doesn't warn on singleton variables for
variables starting with an underscore.  As far as I'm aware
this behaviour conforms to the standard and standard practice.

	--- Jan