Page 1 of 1

Must Unify

Posted: 30 Jul 2014 21:44
by Martin Meyer
Hi Thomas,

in new VIP 7.5 the clause

Code: Select all

run() :-     X == 1.
throws error c609 : Variable 'X' is not completely bound. Is it a bug or has Must Unify been changed for a reason?

Regards,
Martin

Posted: 31 Jul 2014 7:32
by Vitaly Markov

Code: Select all

run() :-     X = read(),     X == 1,     write("Ok").
If you input 1 then "Ok". Else exception.

Posted: 31 Jul 2014 10:40
by Thomas Linder Puls
Yes, must unify has been changed.

Your example clause should use a regular "=", using "==" is misleading because it indicates (to other programmers) that a "cannot unify" exception could potentially be raised, which it can't.

"=" and "==" have same semantics for terms that will always unify, but it was never the intention to let "==" play the role of "=" in such cases.

Posted: 31 Jul 2014 14:40
by Martin Meyer
Thanks Thomas! I see.

Btw. the change of Must Unify does not cover flows like for example (tuple(o, o), tuple(i, i)). The clause

Code: Select all

run() :-     tuple(X, Y) == tuple(1, 2).
is still compiling. I suppose, you liked to exclude such usages too.

Regards,
Martin

Posted: 1 Aug 2014 8:11
by Thomas Linder Puls
In principle, but I am not sure it is worth the effort.