From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 2171DBBAF for ; Wed, 2 Jun 2010 18:28:08 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AncDAEIjBkzB/Bd4lGdsb2JhbACSAowXFQEBAQEUCAkRAx/BPYUWBA X-IronPort-AV: E=Sophos;i="4.53,348,1272837600"; d="scan'208";a="63853546" Received: from smtp-msa-out01.orange.fr ([193.252.23.120]) by mail4-smtp-sop.national.inria.fr with ESMTP; 02 Jun 2010 18:28:07 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id 3B4E81C00D76 for ; Wed, 2 Jun 2010 18:28:07 +0200 (CEST) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id 265091C011AA for ; Wed, 2 Jun 2010 18:28:07 +0200 (CEST) Received: from [192.168.1.90] (APuteaux-154-1-70-204.w81-249.abo.wanadoo.fr [81.249.113.204]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id DC7011C0173B for ; Wed, 2 Jun 2010 18:28:06 +0200 (CEST) X-ME-UUID: 20100602162806903.DC7011C0173B@mwinf5a04.orange.fr X-ME-User-Auth: lexifi Message-ID: <4C068697.5050007@frisch.fr> Date: Wed, 02 Jun 2010 18:28:07 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Questions concerning modules as first-class values References: <367372.3609.qm@web111501.mail.gq1.yahoo.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 signoles:01 functors:01 functors:01 compilation:01 ocaml:01 functor:01 functor:01 lexifi:01 runtime:01 command-line:01 resp:01 resp:01 wrote:01 On 06/02/2010 03:43 PM, Julien Signoles wrote: > If I well understood what Alain Frisch and Xavier Leroy explained, > modules (including both structures and functors) become first class > value: structures may be converted to records and functors to functions; > and conversely. But I let more informed person confirm this. Not really. What you describe is the internal compilation strategy for modules (structures -> records; functors -> functions), which did not change with the introduction of 1st class modules. What's possible in OCaml 3.12 is to turn a module (be it a structure or a functor) into a "package", which is a first-class value. A package is just the wrapper around a module that makes it a first-class value. In particular, a package that wraps a structure (resp. a functor) is *not* converted to a record (resp. a function). What you can with a package: - whatever you can do with a first-class value (pass it to a function, store it in a data structure, etc); - unwrap it back into the underlying module. We've been using first-class modules for more than one year at LexiFi and we have never found a use for packing functors into first-class values, but I've no doubt people will find some. In particular, this allows the program to decide at runtime (given an environment variable or a command-line argument) to use some particular (functorized) implementation of a data structure over another. Alain