From liraola@opera.dia.fi.upm.es  Fri Jul  9 14:28:18 1999
Received: from goofy.fi.upm.es (goofy.fi.upm.es [138.100.8.23])
	by swi.swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA07400
	for <prolog@swi.psy.uva.nl>; Fri, 9 Jul 1999 14:28:18 +0200 (MET DST)
Received: from conversion.relay.fi.upm.es by relay.fi.upm.es
 (PMDF V5.2-32 #39034) id <01JDD3WETIS0000TC2@relay.fi.upm.es> for
 prolog@swi.psy.uva.nl; Fri, 9 Jul 1999 14:27:58 MET-DST
Received: from opera.dia.fi.upm.es (opera.dia.fi.upm.es [138.100.11.43])
 by relay.fi.upm.es (PMDF V5.2-32 #39034)
 with ESMTP id <01JDD3WEDK9C000PYA@relay.fi.upm.es> for prolog@swi.psy.uva.nl;
 Fri, 09 Jul 1999 14:27:58 +0200 (MET-DST)
Received: from localhost by opera.dia.fi.upm.es (8.8.4/FI-4.1) Fri,
 9 Jul 1999 14:25:59 +0100 (WET DST)
Date: Fri, 09 Jul 1999 14:25:53 +0100 (WET DST)
From: Luis Iraola Moreno <liraola@opera.dia.fi.upm.es>
Subject: Anonymous variables
X-Sender: liraola@opera
To: prolog@swi.psy.uva.nl
Message-id: <Pine.SOL.3.95.990709134528.18876A-100000@opera>
MIME-version: 1.0
Content-type: TEXT/PLAIN; charset=US-ASCII


Dear all,

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.

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.

Regards,

Luis Iraola.

