[m-dev.] Stream2000
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Nov 2 23:19:27 AEDT 2000
On 02-Nov-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> 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.
Specialization is in general very important not so much because it is
such a win in itself, but because it enables further optimizations
such as inlining and deforestation. But in this case, if you don't
have intermodule optimization, you won't get inlining or deforestation
anyway, all you'll get is specialization of the dynamic dispatch.
And that is in an ideal compiler. Our current implementation still
does dynamic dispatch in such cases! (It does however specialize
things reasonable well if intermodule optimization is enabled,
but even then it doesn't do a great job of inlining afterwards.)
Anyway I still prefer the abstract types approach ;-)
--
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