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 TAA19129; Wed, 4 Aug 2004 19:24:25 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA19022 for ; Wed, 4 Aug 2004 19:24:24 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from wetware.com (wetware.wetware.com [199.108.16.1]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i74HOMmL006130 for ; Wed, 4 Aug 2004 19:24:23 +0200 Received: from [208.177.152.17] (helo=[10.0.1.10]) by wetware.com with esmtp (Exim 4.20) id 1BsPUz-0001pr-Tv; Wed, 04 Aug 2004 10:24:22 -0700 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=ISO-2022-JP; format=flowed Message-Id: <252D4C5C-E63B-11D8-B25A-000A958FF2FE@wetware.com> Content-Transfer-Encoding: 7bit Cc: caml-list@pauillac.inria.fr From: james woodyatt Subject: Re: [Caml-list] Conditional Modules Date: Wed, 4 Aug 2004 10:24:30 -0700 To: Ross Duncan X-Mailer: Apple Mail (2.618) X-Miltered: at nez-perce with ID 41111BC7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; woodyatt:01 jhw:01 wetware:01 caml-list:01 functor:01 val:01 val:01 ocaml:01 ocaml:01 sig:01 sig:01 command:98 behaviour:01 syntax:02 modules:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 04 Aug 2004, at 07:58, Ross Duncan wrote: > > Forgive me for asking what might be an easy question, I am just a > beginner with Ocaml. I want to do something like this: > > module M = if arg then M1 else M2 > module A = F (M) > (* define rest of program using fields of A *) > > The idea being that arg will come from e.g. the command line, and > modules M1, M2 and functor F are defined elsewhere. > > Of course "module M = if ... " is a syntax error. My question is: > how to achieve this behaviour (and generalisations of it) in ocaml? > > It seems that this is an obvious thing to want to do but I haven't > found any clues in the manual or the FAQs. Is it me? This is one of those cases where using classes and objects is the right way to go. class type c = object ... end class c1 : c class c2 : c module M: sig val c: c end module A(sig val c: c end): sig ... end ― ∴ ------------------- 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