prologinstantiation-error

Why does =:= give an error when the variable is not instantiated, but == doesn't?


3 == X.

would result in the answer 'no', but

3 =:= X

would result in an error :

! Instantiation error in argument 2 of (=:=)/2
! goal:  3=:=_409

Why is this happening? Shouldn't both of them behave the same when one is an uninstantiated variable?


Solution

  • =:=/2 will evaluate the expressions and compare the results - so it cannot have any terms that are not fully instantiated.

    In other words, X =:= Y is similar to EX is X, EY is Y, EX = EY - but it will also do implicit casts e.g. 1 =:= 1.0 evaluates to true.