From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: david.baelde@ens-lyon.org
Cc: Chris Yocum <cyocum@gmail.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Ocaml and the Fragile Base Class Problem
Date: Sat, 27 Aug 2011 21:37:20 +0200 [thread overview]
Message-ID: <1314473840.3496.132.camel@thinkpad> (raw)
In-Reply-To: <CAFqqUFG2Gqop7BqdSsm4Y5CHQ8KB1mG9J62=8hS9faqKJbtkfQ@mail.gmail.com>
Am Samstag, den 27.08.2011, 18:59 +0200 schrieb David Baelde:
> On Sat, Aug 27, 2011 at 5:06 PM, Gerd Stolpmann <info@gerd-stolpmann.de> 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.
------------------------------------------------------------
next prev parent reply other threads:[~2011-08-27 19:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-27 10:53 Chris Yocum
2011-08-27 11:24 ` Jacques Garrigue
2011-08-27 15:06 ` Gerd Stolpmann
2011-08-27 16:59 ` David Baelde
2011-08-27 19:37 ` Gerd Stolpmann [this message]
2011-08-27 20:21 ` Jeff Meister
2011-08-27 23:08 ` Gerd Stolpmann
2011-08-28 9:31 ` Andreas Rossberg
2011-08-28 10:04 ` Guillaume Yziquel
2011-08-28 10:11 ` Gerd Stolpmann
2011-08-28 10:50 ` Andreas Rossberg
2011-08-29 3:35 ` Jacques Garrigue
2011-08-29 11:19 ` Chris Yocum
2011-08-29 11:47 ` Guillaume Yziquel
2011-08-29 12:03 ` Chris Yocum
2011-08-31 21:33 ` Alain Frisch
2011-08-31 23:39 ` Jacques Garrigue
2011-08-28 17:58 ` Julien Signoles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1314473840.3496.132.camel@thinkpad \
--to=info@gerd-stolpmann.de \
--cc=caml-list@inria.fr \
--cc=cyocum@gmail.com \
--cc=david.baelde@ens-lyon.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox