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=1.5 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 8DD49BB84 for ; Sat, 17 Jan 2009 22:22:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiIDAAPbcUlDWxLCbmdsb2JhbACBbJIZPq0phgiGWoVz X-IronPort-AV: E=Sophos;i="4.37,282,1231110000"; d="scan'208";a="33886952" Received: from ip67-91-18-194.z18-91-67.customer.algx.net (HELO server1.bertec.net) ([67.91.18.194]) by mail4-smtp-sop.national.inria.fr with ESMTP; 17 Jan 2009 22:22:22 +0100 Received: from pc54.bertec.net (pc54.bertec.net [192.168.2.54]) by server1.bertec.net (Postfix) with ESMTP id 57BF41056C4 for ; Sat, 17 Jan 2009 16:22:20 -0500 (EST) Message-Id: From: Kuba Ober To: caml-list@yquem.inria.fr In-Reply-To: <200901171659.36732.jon@ffconsultancy.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: [Caml-list] C++/C# inheritance is bad? Date: Sat, 17 Jan 2009 16:22:19 -0500 References: <200901171327.19141.jon@ffconsultancy.com> <200901171659.36732.jon@ffconsultancy.com> X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; ocaml:01 ocaml's:01 lablgtk:01 datatypes:01 syntax:01 verbose:01 event-based:01 parsers:01 c-like:01 cheers:01 2009:98 wrote:01 wrote:01 abstract:01 rewrite:01 On Jan 17, 2009, at 11:59 AM, Jon Harrop wrote: > On Saturday 17 January 2009 14:35:22 Kuba Ober wrote: >> I wonder how such a hierarchy would be implemented in a natural way >> in OCaml? > > Assuming you stick with accepted wisdom, you would mimic the same > effects > using OCaml's object system, just as LablGTK does. However, you have > picked > the only pedagogical OO example: GUI widgets. Perhaps that's where OO paradigm really shines. I'm very much against shoehorning everything into it, of course. > In contrast, metaprogramming is the pedagogical example for algebraic > datatypes. There is almost no need for users to extend the abstract > syntax > tree but there is huge value in being able to rewrite expressions > using > pattern matching. There is an idiomatic OOP solution to this problem > that > involves visitor patterns and so forth but it is comparatively > verbose, > obfuscated and unmaintainable. You've got me there -- I never liked the visitor pattern, and by extension the event-based XML parsers written in C-like languages. Cheers, Kuba