From: "mattwb" <mattwb@alve.com>
To: <caml-list@inria.fr>
Subject: [Caml-list] module/signature pattern concerns
Date: Thu, 28 Nov 2002 11:30:38 -0600 [thread overview]
Message-ID: <003a01c29703$e1e2fa00$fdeef5d1@unknown427igcj> (raw)
A common pattern that has developed in much of my production
O'Caml code is to write interface files that look something like this:
foo.mli
module type PARAMS =
sig
(* define fixed, run-time configuration parameters *)
end
module type ELT =
sig
(* ... *)
end
module Make (P : PARAMS) : ELT
I define a set of parameters in the PARAMS signature which configure
the Make functor. So the user program would be something like this:
let module F = Foo.Make(
struct
(* ... *)
end)
in
F.main()
This has become a convenient pattern, and allows me to write more
'opaque' signatures because I don't have to include any parameters in the
ELT signature. I can use the resulting ELT module as a parameter
in other PARAM signatures in other modules. This leads to a nice layering
effect.
My concern is that I will take a significant performance hit by using
functors
so much and using so many layers. I haven't noticed this problem in any of
the code that I have written, but I am slightly paranoid that, at a much
larger
scale, this would become an issue.
As an alternative, I could write something similar without using functors
and
expose some of the module configuration:
foo.mli
module type ELT
sig
(* ... *)
end
(* List run-time configuration parameters here *)
(* This section matches the ELT signature *)
I realize I that I can check this easily myself, but I thought I'd ask the
list so
I could get some possibly new ideas.
Any suggestions?
Alternatives?
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2002-11-28 17:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-28 17:30 mattwb [this message]
2002-11-29 8:27 ` Jean-Christophe Filliatre
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='003a01c29703$e1e2fa00$fdeef5d1@unknown427igcj' \
--to=mattwb@alve.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;
as well as URLs for NNTP newsgroup(s).