* [Caml-list] module/signature pattern concerns
@ 2002-11-28 17:30 mattwb
2002-11-29 8:27 ` Jean-Christophe Filliatre
0 siblings, 1 reply; 2+ messages in thread
From: mattwb @ 2002-11-28 17:30 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] module/signature pattern concerns
2002-11-28 17:30 [Caml-list] module/signature pattern concerns mattwb
@ 2002-11-29 8:27 ` Jean-Christophe Filliatre
0 siblings, 0 replies; 2+ messages in thread
From: Jean-Christophe Filliatre @ 2002-11-29 8:27 UTC (permalink / raw)
To: mattwb; +Cc: caml-list
mattwb writes:
>
> 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.
An ocaml defunctorizer, developped by Julien Signoles, is to be
released soon. Using it, you'll get an equivalent code without any
functor anymore. I guess it'll ease your paranoia...
Moreover, the first benchmarks with this defunctorizer proved that
using many functors does not have necessarily a (bad) impact on
performance. So you can really stop being paranoid :-)
--
Jean-Christophe Filliâtre (http://www.lri.fr/~filliatr)
-------------------
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-11-29 8:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-28 17:30 [Caml-list] module/signature pattern concerns mattwb
2002-11-29 8:27 ` Jean-Christophe Filliatre
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).