Version française
Home     About     Download     Resources     Contact us    
Browse thread
Operator overloading
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Operator overloading
On Fri, 2007-03-09 at 14:52 +0100, Andreas Rossberg wrote:
> 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.

I'm sorry to write so poorly. This isn't the comparison I'm
drawing. 

Consider *implementing* typeclasses with records,
as in Oleg's Ocaml examples.

Ok, now replace the records with classes. Classes
are more powerful because they provide

(a) state
(b) inheritance etc

They also don't make the weak assumption of an 
abstraction (possibly with default methods as in Haskell)
and a single instantiation: in C++ at least you can
have sequence of more derived classes.

So the type model associated with this implementation
can do more than the one just using plain records:
records aren't typeclasses, so the class based implementation
can't be compared with them:

	records   		classes
	typeclasses		???????

Clearly ???? is more expressive than typeclasses, whatever it
is .. I am guessing the state of the classes provides dependent
typing but I don't really know.

Anyhow my ARGUMENT was actually that using classes
subsumes plain old records .. and classes are
limited by the covariance problem, so records
must be limited too.



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net