From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7RJbR6d006252 for ; Sat, 27 Aug 2011 21:37:28 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUBAPtGWU7U4xEIkWdsb2JhbABChEyUKY8bFAEBAQEJCwsHFAMigUABAQUjVhALGAICJgICVxkJh2sCqBqQV4EshA+BEQSMB4wmi3g X-IronPort-AV: E=Sophos;i="4.68,290,1312149600"; d="scan'208";a="106830373" Received: from moutng.kundenserver.de ([212.227.17.8]) by mail4-smtp-sop.national.inria.fr with ESMTP; 27 Aug 2011 21:37:22 +0200 Received: from office1.lan.sumadev.de (dslb-084-059-070-124.pools.arcor-ip.net [84.59.70.124]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MN728-1Qqp7B1kQS-007Jf7; Sat, 27 Aug 2011 21:37:21 +0200 Received: from [192.168.1.111] (546BF154.cm-12-4d.dynamic.ziggo.nl [84.107.241.84]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 120BFC00C7; Sat, 27 Aug 2011 21:37:21 +0200 (CEST) From: Gerd Stolpmann To: david.baelde@ens-lyon.org Cc: Chris Yocum , caml-list@inria.fr In-Reply-To: References: <4E58CCC3.4040901@gmail.com> <1314457588.3496.86.camel@thinkpad> Content-Type: text/plain; charset="UTF-8" Date: Sat, 27 Aug 2011 21:37:20 +0200 Message-ID: <1314473840.3496.132.camel@thinkpad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:CvV4umaEyopvOkwD5+WQjOaua9qRmrnEsB21Ke4puAK OBgCUGRt3/vLlEY/ejxqFZrbIovHQMEv71P/za0kve2EWnhwEK QjHFRFoY5S+uXDiUmCKv/LJMDUJYVpeDY4JrSpsW6Tcnl/lVP1 myV+aEHCcgGPSQ3WEunonMFmpiCJLskT9rD1ssPCj2u+ldy1Yn Ori+x7Yz9JwEX2opIaO/A== Subject: Re: [Caml-list] Ocaml and the Fragile Base Class Problem Am Samstag, den 27.08.2011, 18:59 +0200 schrieb David Baelde: > On Sat, Aug 27, 2011 at 5:06 PM, Gerd Stolpmann wrote: > > I think it is a non-issue in practice. Simply because inheritance is > > quite seldom in Ocaml, even in programs using a lot of OO features. > > Perhaps the issue is the reason why we don't use more OO in OCaml? > That kind of problem did bit us once. It's particularly dangerous when > combined with recursive methods -- when you override, it breaks > recursion. Right, but as noted, you can easily live without inheritance in OCaml. I can only speculate why OO is not that much used in OCaml. I've got the impression that the "disliked" feature is not object-orientation as such, but the structural typing (which includes polymorphic variants, which I also see rarely). I guess the biggest problem is that structural typing does not offer much for getting information hiding - once a method is public, it is fully public. This is, in some sense, against the mindset of the typical OCaml programmer. Second, there are practical difficulties - sometimes very long error messages (1000 lines and more), and surprising weak spots in the type checker (e.g. when a method has optional arguments). OO is definitely nothing for OCaml beginners. Nevertheless, I think that there are very good examples of OO in OCaml. For instance, any kind of I/O device or I/O processor - which usually profit a lot from dynamic binding and subtyping, and for which information hiding is not an issue (you communicate with the system). For this reason there is a lot of OO in OCamlnet. Strange enough, I count as "OO guy" in the OCaml scene, although I don't use it much outside the context of I/O operations. Let me reformulate your question: We should better ask which OO design patterns are still adequate in OCaml. Obviously, many textbook design patterns feel strange in OCaml - the language has simply better alternatives. The remaining interesting cases seem to always use dynamic binding and optionally subtyping. Gerd > > David > -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de *** Searching for new projects! Need consulting for system *** programming in Ocaml? Gerd Stolpmann can help you. ------------------------------------------------------------