From jan@swi.psy.uva.nl  Fri Jul  9 16:47:19 1999
Received: from gollem.swi.psy.uva.nl (jan@gollem.swi.psy.uva.nl [145.18.114.15])
	by swi.swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id QAA13328
	for <prolog@swi.psy.uva.nl>; Fri, 9 Jul 1999 16:47:18 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.8.8/8.8.8) id QAA27187;
	Fri, 9 Jul 1999 16:47:59 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
To: prolog@swi.psy.uva.nl, Luis Iraola Moreno <liraola@opera.dia.fi.upm.es>
Subject: Re: Anonymous variables
Date: Fri, 9 Jul 1999 16:44:04 +0200
X-Mailer: KMail [version 0.7.9]
Content-Type: text/plain
References: <Pine.SOL.3.95.990709134528.18876A-100000@opera>
MIME-Version: 1.0
Message-Id: <99070916475904.26091@gollem>
Content-Transfer-Encoding: 8bit

On Fri, 09 Jul 1999, Luis Iraola Moreno wrote:

>Just a remark about how SWI (3.2.7) handles anonymous variables.
>
>During compile time, any expression starting with an underscore (e.g.
>"_var") is considered an anonymous variable: the compiler stops warning
>you about using the variable just once in a clause. 
>
>But in run time, only expressions consisting *only* of an underscore
>are treated as anonymous variables. E.g.
>
>?- _ = a, _ = b.
>yes.
>
>Perfect, the unification of the anonymous variable "_" in the first goal
>is not taken into account when proving the second. But
>
>?- _var = a, _var = b.
>no.

Just '_' is an anonymous variable.  _name is a normal variable, though
singleton checking does not warn you.

I don't know by heart wat ISO says.  The motivation is for compatibility
with BIM-Prolog, which used _var for normal variables (and some projects
had to be portable long ago).  In practice,  Use ThisVar for normal
variables, _ if you really want announynous and _var to add comment to
it.   Maybe there should be a feature declaraction to control this
behaviour.

>Here the first unification of "_var" is maintained when trying to prove
>the second goal, therefore it fails.
>
>So, I guess that expressions like "_var" are just like any other standard
>variable (though the compiler does not warn you) and only "_" names the
>anonymous variable.
>
>This posses no problem at all (I am not claiming it is a bug), but
>sometimes it is convenient (I think) to have "named" anonymous variables
>like "_Digit" just for improving the readability of the code.

	--- Jan

