Must Unify

Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Must Unify

Unread post 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
Vitaly Markov
Active Member
Posts: 40
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov »

Code: Select all

run() :-     X = read(),     X == 1,     write("Ok").
If you input 1 then "Ok". Else exception.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1177
Joined: 28 Feb 2000 0:01

Unread post 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.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Unread post 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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1177
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

In principle, but I am not sure it is worth the effort.
Regards Thomas Linder Puls
PDC
Post Reply