[mercury-users] Math Module

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Tue Oct 22 01:06:24 AEST 2002


> >> Here is the error...
> >> Nex_int.m:006: In `main(di, uo)':
> >> Nex_int.m:006:   error: determinism declaration not 
> >satisfied.
> >> Nex_int.m:006:   Declared `det', inferred `semidet'.
> >> Nex_int.m:010:   In the return value of call to function
> >> `math:round/1':
> >> Nex_int.m:010:   unification with `Radius' can fail.
> >>
> >> Whatever I try by changing its determinism, it does not solve 
> >the
> >> problem. Plz do help.
> Here is the error I get...
> Nex_int.m:012: In clause for predicate `Nex_int:main/2':
> Nex_int.m:012:   error: ambiguous overloading causes type 
> ambiguity.
> Nex_int.m:012:   Possible type assignments include:
> Nex_int.m:012: RoundedRadius :: float or (pred float)

Darn, i never liked the functions anyway ;-) I guess you are using
version 0.10 of the compiler and its libraries? In these libraries you 
can find that there are two math_round thingies: 
	- a math__round predicate
	- a math__round function
If you construct something like math__round(Radius), a priori the
compiler can interpret this as either a function call, or a kind of
partial predicate (it may be interesting to look up some information on
higher order calls). The compiler would be able to decide which
interpretation is correct if it had some additional hints from the
programmer. Unfortunately you love to use "print" to print your
information on stdout. If you use "io__write_float" you give that extra 
info to the compiler that RoundedRadius is a float and not a predicate. 

So, there are two options you may choose from: 
1. either use the predicate math__round instead of the function:
	..., {math__round(Radius, RoundedRadius)}, print(RoundedRadius). 
2. or use io__write_float to give that extra hint to the compiler: 
	..., {RoundedRadius = math__round(Radius)}, 
	io__write_float(RoundedRadius). 


Ciao, 
Nancy
--------------------------------------------------------------------------
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