[m-dev.] Stream2000

Peter Ross peter.ross at miscrit.be
Thu Nov 2 22:14:58 AEDT 2000


On Thu, Nov 02, 2000 at 10:06:19PM +1100, Fergus Henderson wrote:
> On 02-Nov-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> > The next question is which is better?  
> > It shouldn't really matter which method we use, except that one case may
> > have better error messages then the other.
> > 
> > The nice thing about existential types is that they simplify the
> > interface, as all the instance declarations are local to the module.
> > 
> > The nice thing about the abstract types approach is that I feel that
> > programmers may find it more comfortable (I now it took me a while to
> > get my head around existential types).
> 
> Another advantage of the abstract types approach is that it can be
> more efficient (in the absence of intermodule optimization).  Because
> the compiler knows the type, it can specialize the method calls, doing
> static dispatch rather than dynamic dispatch.
> 
> In situations where you can use either, I'd generally advise using
> abstract types.  I'd save existential types for situations that
> abstract types won't handle, e.g. when you're going to be returning
> different types for different calls.
> 
Specialisation is definately very important, so I will switch over to
using the abstract types approach.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list