On 21-May-1999, Nigel Perry <[EMAIL PROTECTED]> wrote:
> 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.

Right.  I think S. Alexander Jacobson's question was about when you
want to import just a single function from a module rather than
importing the whole module.  Mercury doesn't allow that, but similar issues
come up any time you want to name a single function; for example, in a
`pragma inline' declaration.

Ensuring that module name, function name, and arity uniquely identify a
function keeps the syntax for function specifiers (as used in
`pragma inline', `pragma c_code', `pragma obsolete', and many other
declarations) slightly simpler.  It also keeps the name mangling algorithm
considerably simpler.  And it makes identifying functions in the profiler,
debugger, etc. simpler and more concise.

Another reason why it is simpler is that we can avoid the issue
of adding syntax to say which declaration each clause belongs to.

These are all fairly minor points, but together they add up to a bit,
and the advantage of allowing overloading of a function name within a
module (rather than just between different (sub-)modules) is also fairly
minor, so it doesn't really seem worth the effort to allow that.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.


Reply via email to