From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 88842BC69 for ; Fri, 9 Mar 2007 12:09:42 +0100 (CET) Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [203.16.214.135]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l29B9eYF023401 for ; Fri, 9 Mar 2007 12:09:41 +0100 Received: from ppp19-103.lns2.syd7.internode.on.net (HELO [192.168.1.201]) ([59.167.19.103]) by ipmail03.adl2.internode.on.net with ESMTP; 09 Mar 2007 21:39:38 +1030 X-IronPort-AV: i="4.14,267,1170595800"; d="scan'208"; a="60344117:sNHT20814129" Subject: Re: [Caml-list] Operator overloading From: skaller To: oleg@pobox.com Cc: caml-list@inria.fr In-Reply-To: <20070309073658.8F020AD34@Adric.metnet.fnmoc.navy.mil> References: <20070309073658.8F020AD34@Adric.metnet.fnmoc.navy.mil> Content-Type: text/plain Date: Fri, 09 Mar 2007 22:09:34 +1100 Message-Id: <1173438574.22738.24.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 45F14074.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; overloading:01 oleg:01 haskell:01 threads:01 haskell:01 ralf:01 vaguely:01 model:01 model:01 inlining:01 compilation:01 typeclass:01 sourceforge:01 wrote:01 wrote:01 On Thu, 2007-03-08 at 23:36 -0800, oleg@pobox.com wrote: > John Skaller wrote: ``(Haskell does this little cheat .. it makes > typeclasses very easy to explain to OO people).'' Are you sure about > that? There has been many long and recurring threads on Haskell-Cafe > about typeclasses and OO classes. I think the common advice is _not_ > to think of Haskell typeclasses as of OO classes. Ralf Laemmel and I > once wanted to elaborate on the issue of OO in Haskell; we ended up > with a 79-page paper. I guess that shows that OO is never easy. Certainty requires at least a proof sketch, which I don't have. However I do have a 'gut feeling' :) It's hard to say, because in OO terms Haskell typeclasses are so weak it's surprising they're any use at all. If you consider your record implementation, observe it is just a weak special case of a C++ class. C++ classes can also provide state and inheritance. The state looks vaguely like dependent typing to me .. :) OK, so now we have a much more powerful model .. 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. So all you need to do is elevate this model up one kinding level to see typeclasses, even with the additional power of 'everything C++ classes can do' are limited. Of course it is argument by analogy and intuition, not any kind of formal proof, that's for the experts :) Felix currently has multi-parameter typeclasses which use inlining because it's a whole program analyser, so it can, however explicit objects would be required either for separate compilation, or simply to experiment with the 'extra power' of dynamic binding. The 'obvious' implementation is of course a C++ class. The difference to ordinary use is that the object doesn't represent a type, but a typeclass, possibly with dependent type parameters: eg a 'get' method for an array with the length as a state variable. -- John Skaller Felix, successor to C++: http://felix.sf.net