Version française
Home     About     Download     Resources     Contact us    
Browse thread
C++/C# inheritance is bad?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] C++/C# inheritance is bad?
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.

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.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e