English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Defining a family of functors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-01-29 (21:15)
From: Mauricio Fernandez <mfp@a...>
Subject: Re: [Caml-list] Defining a family of functors
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:


Mauricio Fernandez  -   http://eigenclass.org