[m-rev.] Added int:'/'/2 and builtin false/0
Ralph Becket
rafe at cs.mu.OZ.AU
Mon May 20 13:55:31 AEST 2002
Michael Day, Monday, 20 May 2002:
>
> > Amidst all the sarcasm, I can't tell which way you're leaning :)
>
> Well actually I think using / is justified for ints in Mercury due to the
> fact that there are no implict type conversions between int and float. So
> if you write X / Y you're going to get what you asked for to the precision
> that the type of X and Y supports, whether they be ints, floats, integers,
> whatever.
Ah, good, we agree.
> It doesn't seem worth pushing a strictly mathematical approach to the
> naming of the operators, especially when some code divides by zero
> intentionally as the result (+/-inf or nan? I can't remember...) can be
> compared conveniently to avoid explicitly checking for special cases like
> a slope of 0. Presumably in a truly mathematical language dividing by zero
> would blow up the universe, or at least place all subsequent computation
> on an extremely dubious foundation.
A logic programmer should hope such a program would just return "no" or
an exception - a logic program is a declarative specification of a
relationship between input and output; if the program succeeds then it
returns a constructive demonstration that the relationship holds by
providing appropriate bindings for output variables.
On the whole I like the current Mercury convention of having operators
be safe by default and having unchecked versions for when you as the
programmer are (a) in dire need of that extra jot of performance and (b)
are prepared to take on the proof burden of correctness.
I just think that '//'/2 is an anachronism that makes Mercury harder for
newcomers to read and understand (currently, if you inadvertently use
'/'/2, the compiler simply reports "error: undefined symbol `//2'",
which is really not very helpful if you don't know the history...)
- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list