[mercury-users] Math Module

Ralph Becket rafe at cs.mu.OZ.AU
Tue Oct 22 12:05:00 AEST 2002


Peter Schachte, Tuesday, 22 October 2002:
> 
> 	:- func reverse(list(T)) = list(T).
> 	:- func reverse(list(T),list(T)) = list(T).
> 
> (the second reverses the first argument and appends the second to the
> end), then
> 
> 	reverse(L)
> 
> could be a function call or a closure.  If the context doesn't
> disambiguate, there's a problem.

Well, this looks like an instance of poor naming to me.

The price we pay for overloading is that occasionally we need to supply
disambiguating information in the form of explicit module or type
qualification.

Most such problems can be resolved by carefully choosing names in the
first place.  But of course, the problem will never go away completely.

> Maybe both arity and func/pred overloading should go?  Or maybe
> currying should go?  The latter could be as simple and painless as
> requiring you to write something like "func reverse(L)" when you mean
> the closure (ie, all closures would be written as func/1 or pred/1
> terms).  If this would fix this class of pitfalls, it sounds like a
> good idea to me.

Couldn't we have proper currying if we do something like this?

- 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