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 (21:22)
From: Kuba Ober <ober.14@o...>
Subject: Re: [Caml-list] C++/C# inheritance is bad?

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  
the event-based XML parsers written in C-like languages.

Cheers, Kuba