[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-03-09 (13:52) |
From: | Andreas Rossberg <rossberg@p...> |
Subject: | Re: [Caml-list] Operator overloading |
skaller wrote: > > It's hard to say, because in OO terms Haskell typeclasses > are so weak it's surprising they're any use at all. Not sure how you come to that conclusion. Both concepts are somewhat incomparable, but there are a number of axes along which type classes are much more expressive than OO classes. Ignoring implementation inheritance, I claim that in combination with existential types, even relatively basic type classes are strictly more powerful than OO classes (modulo some lack of syntactic sugar). Have a look at Oleg's paper. > C++ classes can also provide state and inheritance. > The state looks vaguely like dependent typing to me .. :) I grant you (implementation) inheritance, but I don't understand the rest of your comment. State is orthogonal to classes. Surely you can define a type class that contains a, say, IORef (for per-class state). Likewise, you can instantiate type classes to stateful types (as the equivalent to per-object (mutable) state). > OK, so now we have a much more powerful model .. I don't think so. > yet > it has known limitations, in particular the so-called > 'covariance' problem prevents OO from modelling any > serious kind of system: for example a system > with binary operators doesn't admit an OO representation. Which is one of the problems type classes do not have, because qualified types *are* more expressive than subtyping in that respect. AFAICS, the rest of your argument hence does not follow. -- Andreas Rossberg, rossberg@ps.uni-sb.de