From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA31166; Thu, 28 Nov 2002 18:30:36 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA31059 for ; Thu, 28 Nov 2002 18:30:35 +0100 (MET) Received: from mail3.sea.registeredsite.com (mail3.sea.registeredsite.com [66.111.73.203]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gASHUXX05926 for ; Thu, 28 Nov 2002 18:30:34 +0100 (MET) Received: from badgersys.com (technomediasolutions.com [66.111.64.35] (may be forged)) by mail3.sea.registeredsite.com (8.12.6/8.12.6) with ESMTP id gASHUWa9001494 for ; Thu, 28 Nov 2002 12:30:32 -0500 Received: from unknown427igcj (dialup-209.245.238.253.Dial1.Dallas1.Level3.net [209.245.238.253]) by badgersys.com (8.11.0/8.11.0) with SMTP id gASHUVr01319 for ; Thu, 28 Nov 2002 11:30:31 -0600 (CST) (envelope-from mattwb@alve.com) Message-ID: <003a01c29703$e1e2fa00$fdeef5d1@unknown427igcj> From: "mattwb" To: Subject: [Caml-list] module/signature pattern concerns Date: Thu, 28 Nov 2002 11:30:38 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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