Dispatch on what? (Was: seeking ideas for short lecture on type classes)

Jerzy Karczmarczuk karczma@info.unicaen.fr
Tue, 04 Feb 2003 15:46:17 +0100


This is a somewhat older thread, but I ask you to enlighten me.

Norman Ramsey wrote:
> A fact that I know but don't understand the implication of is that
> Haskell dispatches on the static type of a value, whereas OO languages
> dispatch on the dynamic type of a value.  But I suspect I'll leave
> that out :-)


Dean Herington:
> Perhaps I misunderstand, but I would suggest that "fact" is, if not 
> incorrect, at least oversimplified.  I would say Haskell dispatches on the
> dynamic type of a value, in the sense that a single polymorphic function
> varies its behavior based on the specific type(s) of its argument(s).
> What may distinguish Haskell from typical OO languages (I'm not an expert
> on them) is that in Haskell such polymorphic functions could (always or at
> least nearly so) be specialized statically for their uses at different types.


Fergus Henderson wrote:
 > I agree.  The above characterization is highly misleading.  It would be
 > more accurate and informative to say that both Haskell and OO languages
 > dispatch on the dynamic type of a value.
 >


================================

Now my brain ceased to understand... Are you sure that OO dispatch schemas
are based on the *argument* type?

I would say that - unless I am dead wrong, the OO languages such as Smalltalk
do not dispatch on dynamic types of a value. The receiver is known, so its vir.
f. table (belonging to the receiver's class) is known as well, the dispatching
is based on the *message identifiers* independently of subsidiary arguments.
Only after that - perhaps - some "reversions", message propagation depending on
the arg(s) value(s), etc. may take place, but all this is irrelevant...
Forgive me if I write stupidities.


Jerzy Karczmarczuk