[mercury-users] difference between is and =?

Ralph Becket rbeck at microsoft.com
Fri Apr 27 21:01:02 AEST 2001


> in the last clause of this function, is is used instead of =. Why is
> this? In fact, what is is?
> 
> float__pow(X, Exp) = Ans :-
> 	( Exp < 0 ->
> 		error("float__pow taken with exponent < 0\n")
> 	; Exp = 1 ->
> 		Ans =  X
> 	; Exp = 0 ->
> 		Ans = 1.0
> 	;
> 		New_e is Exp - 1,
> 		Ans is X * float__pow(X, New_e)
> 	).

`is' is a throwback to the old Prolog days.  Prolog lacks functions, so
any arithmetic had to be computed using is/2 which would interpret its
right hand argument as an arithmetic expression, compute the result,
and unify that with its left hand argument.

Mercury has functions and so is/2 is just a synonym for =/2 (i.e.
built-in
unification).  Much old code in the library is written in the subset of
Mercury that is compatible with prolog because, in the early days, that
was how Mercury was debugged.

So, for `is' read `=' in Mercury; don't use `is' in your own code.

-- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list