[m-dev.] Stream2000

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 2 22:06:19 AEDT 2000


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.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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