From: Vincent Aravantinos <vincent.aravantinos@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Include question
Date: Wed, 09 Nov 2011 10:41:15 -0500 [thread overview]
Message-ID: <4EBA9F1B.3060801@gmail.com> (raw)
In-Reply-To: <1320823798.6647.2.camel@Nokia-N900>
[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]
On 11/09/2011 02:29 AM, Cedric Cellier wrote:
> For some reasons though, despite functors being one of the greatest
> strength of the language, we do seam shy to use, recommand or brag
> about them. I wonder if this is due to the lack of proper documentation ?
I don't think there is a lack of proper documentation: it is introduced
right away in the "tutorial" part of the Ocaml manual (Part I), it is
described in the language description (Part II) and there are a couple
of examples in the std lib (Part IV). What do you think it lacks to be
properly documented (at least w.r.t other features of Ocaml)?
I actually wonder if they just *look* too complicated? Maybe because
they are verbose?
Each time you define a functor you also have to give the signature of
its argument, which, compared to a simple "include" can look overkilling.
Concretely:
module A = struct
...
end
module B = struct
include A
...
end
VS
module A = struct
...
end
module type B_INPUT = sig
... (can be big)
end
module Make_B (X:B_INPUT) = struct
...
end
For one module that's fine, but when you start having lots of modules
and intricate interactions between them, that can start to be a pain in
the ass.
In addition, this include->functor switch happens quite often when you
have sources that were not written in the first place with functors in
mind, so this is not an uncommon situation.
I think personally that this verbosity is actually a good thing because
it forces to give some documentation which is particularly needed when
many modules are interacting.
But then this documentation argument is a bit contradictory with what we
sell to beginners when they learn Ocaml: "Ocaml is great because it has
type inference, this removes verbosity!"...
--
Vincent Aravantinos
Postdoctoral Fellow, Concordia University, Hardware Verification Group
http://users.encs.concordia.ca/~vincent
[-- Attachment #2: Type: text/html, Size: 3371 bytes --]
next prev parent reply other threads:[~2011-11-09 15:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 15:03 Hans Ole Rafaelsen
2011-11-08 15:10 ` Gabriel Scherer
2011-11-08 15:45 ` Hans Ole Rafaelsen
2011-11-08 15:50 ` Thomas Gazagnaire
2011-11-08 15:49 ` Alexandre Pilkiewicz
2011-11-09 7:29 ` Cedric Cellier
2011-11-09 15:41 ` Vincent Aravantinos [this message]
2011-11-09 15:50 ` Vincent Aravantinos
2011-11-09 16:29 ` rossberg
2011-11-09 17:08 ` Vincent Aravantinos
2011-11-09 23:36 ` Jacques Garrigue
2011-11-10 12:08 ` rossberg
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=4EBA9F1B.3060801@gmail.com \
--to=vincent.aravantinos@gmail.com \
--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