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 D0879BC57 for ; Wed, 17 Mar 2010 19:24:09 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsQBAB67oEvUGyoFkWdsb2JhbACDC5d9FQEBAQEJCwoHEwMfqlWQQYEsgmBqBA X-IronPort-AV: E=Sophos;i="4.51,260,1267398000"; d="scan'208";a="59258097" Received: from smtp5-g21.free.fr ([212.27.42.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 17 Mar 2010 19:24:08 +0100 Received: from smtp5-g21.free.fr (localhost [127.0.0.1]) by smtp5-g21.free.fr (Postfix) with ESMTP id 241ECD480CF; Wed, 17 Mar 2010 19:24:02 +0100 (CET) Received: from [192.168.0.3] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp5-g21.free.fr (Postfix) with ESMTP id DEC50D4824F; Wed, 17 Mar 2010 19:23:59 +0100 (CET) Message-ID: <4BA11E37.7000207@frisch.fr> Date: Wed, 17 Mar 2010 19:23:51 +0100 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100305 Shredder/3.0.4pre MIME-Version: 1.0 To: David Allsopp Cc: 'Dario Teixeira' , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Lazy modules References: <571731.77500.qm@web111510.mail.gq1.yahoo.com> <00d801cac5f9$474281f0$d5c785d0$@romulus.metastack.com> In-Reply-To: <00d801cac5f9$474281f0$d5c785d0$@romulus.metastack.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 afaik:01 syntax:01 compiler:01 syntax:01 renames:01 toplevel:01 endline:01 runtime:01 sub-modules:01 runtime:01 functor:01 recursive:01 functors:01 On 3/17/2010 6:42 PM, David Allsopp wrote: > AFAIK local modules is a syntax extension not a compiler extension - I > expect (not looked at it) that the syntax extension simply alpha renames > all the local module declarations to make them unique and puts them > globally... a very useful extension but no expressive power added. This is not true. Local modules are not lifted in any way. This is not simply a syntax extension. For instance, if the local module has toplevel side-effects (e.g. a structure item like: let () = print_endline "Hello"), then the side effect will occur every time the local module is evaluated. At runtime, a structure is represented simply by a block with GC tag 0, exactly as a record or a tuple. The block contains dynamic components of the structure (values, sub-modules, exceptions, classes) in the order given by its signature. Evaluating a structure simply evaluates its runtime components a build the block. A functor is represented as a function. >The module system at present is a compile time feature (I think that's > universally true - even with weird things like recursive modules) - > functors are simply a way of introducing more modules so there is no > runtime overhead in using a functor. Modules and functors are much more dynamic than what you believe. The introduction of first-class module did not require any change in the way modules are compiled. A local module which is a functor application really applies the functor at runtime and evaluates the functor body every time the local module expression is evaluated. Alain