Subject: Anonymous variables

From: Luis Iraola Moreno <[email-masked]>
Date: Fri, 09 Jul 1999 14:25:53 +0100 (WET DST)

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.