On 5 January 2014 07:30, Jonathan S. Shapiro <[email protected]> wrote:
> The first way achieves polymorphism by polyinstantiation of code. The second
> way achieves it by existential encapsulation and indirection. Offhand it
> isn't obvious to me which one is more efficient in real use. It depends a
> lot on how the inlining plays out, and the fact that interface instances are
> compile-time shallow-const allows them to be inlined if we wanted to do so.
>
> Perhaps it's just that my head is presently scrunched up sideways on this
> stuff, but the two things look similar to me. Enough so that I suspect
> programmers will be confused about when to use which one.
>
> Assuming we have both in the language, how do we explain when to use
> interfaces vs. when to use type classes? It seems to me that when I am
> trying to do information hiding the answer is clearly interfaces. But in
> some other cases it doesn't seem nearly so clear. So how do we explain this?

It looks a bit like the real distinction is not the interface or
instance definition at all, but about whether a function will treat
the instance as a compile-time constant argument or accept a vtable as
an argument at runtime.  Maybe the difference is really a property of
the function you're calling?

-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely may reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to deny you those rights would be illegal without
prior contractual agreement.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to