caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matt Gushee <matt@gushee.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Duplicate functionality?
Date: Fri, 21 Oct 2005 23:57:06 -0600	[thread overview]
Message-ID: <4359D4B2.2000509@gushee.net> (raw)
In-Reply-To: <200510220431.18749.jon@ffconsultancy.com>

Jon Harrop wrote:

>> On Saturday 22 October 2005 02:04, Stephen Brackin wrote:
>>
>
>>>>My biggest initial question is why OCaml has both a modules system and
>>>>objects: Aren't they different ways of accomplishing the same things?
>
>>
>> Both modules and objects allow you to encapsulate related
definitions, yes.
>>
>> However, modules are much more static by nature and objects are much
more
>> dynamic, i.e. you get stronger static checking using modules than you do
>> using objects, giving more comprehensible error messages and more
robust and
>> faster code.


That's certainly true ... I've probably spent twice as much time
debugging type errors in mutually recursive objects as I have on all
other kinds of errors put together.

On the other hand (as Jon's statement implies), it's much easier to
write extensible code with objects. When you call a function on a module
(except within a functor) you are using a specific implementation,
whereas you can call an object method, say foo#display (), where foo can
be any object with a 'display' method that matches the expected type.

And even if modules and objects were functionally equivalent, I think
one of the great things about OCaml is the freedom it gives you to
structure your application in the best way for the problem.

--
Matt Gushee
Englewood, CO, USA


  reply	other threads:[~2005-10-22  5:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-22  1:04 Stephen Brackin
2005-10-22  3:31 ` [Caml-list] " Jon Harrop
2005-10-22  5:57   ` Matt Gushee [this message]
2005-10-22  8:47   ` Gerd Stolpmann
2005-10-22  5:49 ` Jacques Garrigue
2005-10-22 10:07   ` Lauri Alanko
2005-10-22 21:12 ` Brian Hurt
2005-10-24  3:14 ` Ant: " Martin Chabr
2005-10-25 16:25   ` Didier Remy

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=4359D4B2.2000509@gushee.net \
    --to=matt@gushee.net \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).