At 8:02 am +1000 21/5/99, Fergus Henderson wrote:
> On 20-May-1999, S. Alexander Jacobson <[EMAIL PROTECTED]> wrote:
> > For example, how does overloading interact with the module system?
> > When you import a function from another module, do you need to specify a
> > type as well as a name?
>
> In Mercury, the current answer is that each module can only define one
> function with a given name and arity (number of arguments), although you
> The rationale for this is so that functions can be uniquely referred to by
> just specifying a module name, function name, and arity, without needing
> to specify the argument types. This keeps some things a little bit simpler.
Why is it any simpler? When you have overloading a name may refer to a set
of things. Using a module (in another) just increases the size of the set. Hope+C
allows overloading within a module and with things (a technical term for functions,
types, constructors, etc :-)) imported from others. I never considered this made
it more difficult.
> > Does overloading mean that you don't need Existential types?
>
> No. Existential types are needed for creating heterogenous collections,
> and overloading doesn't help with that.
Absolutely! :-)
> > How does overloading interact with operator precedence?
> ...
> > There is already ambiguity about operator precedence and modules? Now it
> > seems much worse.
>
> Ah, now this is a tricky one. Mercury doesn't allow user-defined
> operators, and the main reason for this is some tricky interactions
> between operator precedence, the module system, and overloading.
Hmmm... I think Hope+C solves the problem by requiring all in-scope definitions
of an operator to have the same precedence. Having two defs in the same module
with different precedences would be very confusing (note for example Ada where you
can only overload existing operators and can't specific precedence at all to avoid
problems). That just leaves a check on import that the precedences match.
Operators are commonly overloaded, so allowing the latter and not the former
is a major restriction.
Cheers,
Nigel
--
Nigel Perry, New Zealand