English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2009-01-17 (16:55)
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.