From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.3 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 5B992BB84 for ; Thu, 29 Jan 2009 22:15:00 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0GAJurgUnVBJXyV2dsb2JhbACBbpIdARYICwgQuEeEEAY X-IronPort-AV: E=Sophos;i="4.37,346,1231110000"; d="scan'208";a="20369128" Received: from outmailhost.telefonica.net (HELO ctsmtpout1.frontal.correo) ([213.4.149.242]) by mail2-smtp-roc.national.inria.fr with ESMTP; 29 Jan 2009 22:14:59 +0100 Received: from NANA.localdomain (83.59.8.125) by ctsmtpout1.frontal.correo (7.2.056.6) (authenticated as ferferse$telefonica.net) id 496219E600832C24 for caml-list@inria.fr; Thu, 29 Jan 2009 22:14:59 +0100 Received: from mfp by NANA.localdomain with local (Exim 4.69) (envelope-from ) id 1LSeDy-0006h0-Gd for caml-list@inria.fr; Thu, 29 Jan 2009 22:14:58 +0100 Date: Thu, 29 Jan 2009 22:14:58 +0100 From: Mauricio Fernandez To: caml-list@inria.fr Subject: Re: [Caml-list] Defining a family of functors Message-ID: <20090129211458.GK25469@NANA.localdomain> Mail-Followup-To: caml-list@inria.fr References: <497DD1F5.7050702@yahoo.fr> <497DD398.5030501@mcmaster.ca> <7d8707de0901270630mf12c557oc0554a4276b62463@mail.gmail.com> <497F1E8D.2080000@mcmaster.ca> <1233090779.6463.10.camel@Blefuscu> <1233102370-sup-9649@ausone.local> <1233141926.6908.4.camel@Blefuscu> <1233221605-sup-9234@ausone.local> <00ed01c981fe$167d0c60$43772520$@com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00ed01c981fe$167d0c60$43772520$@com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Spam: no; 0.00; functors:01 compiler:01 ocaml:01 recompile:01 ocaml:01 node:01 2009:98 mssql:98 config:01 config:01 wrote:01 wrote:01 caml-list:01 functions:01 functions:01 On Thu, Jan 29, 2009 at 10:40:50AM -0000, David Allsopp wrote: > > > On the other hand, it was pointed to me that Alain already wrote a > > > compiler patch implementing first-class modules. > > > > That's right. > > I have two questions - the first of which will probably demonstrate my lack > of skill with the OCaml module system. > > 1. Does first-class modules, as with first-class functions mean that you can > pass them around in code? For example, I have a web-app where all of the > stuff which has to access databases is put into a single module with a known > signature DB. I then have two modules MSSQLDriver and PGSQLDriver which > implement the database functions for two different back-ends and have in > DB.ml > > module DB = MSSQLDriver > include DB > > So when I build for Postgres, I just change the module statement and > recompile. Would first class modules allow me to read the back-end > configuration from a config file and write something like: > > module DB = if Config.driver = `MSSQL then MSSQLDriver else PGSQLDriver > > Or is it about something totally different? :o) See this page: http://ocaml.janestreet.com/?q=node/29#comment-77 -- Mauricio Fernandez - http://eigenclass.org