From: Alain Frisch <alain@frisch.fr>
To: David Allsopp <dra-news@metastack.com>
Cc: 'Dario Teixeira' <darioteixeira@yahoo.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Lazy modules
Date: Wed, 17 Mar 2010 19:23:51 +0100 [thread overview]
Message-ID: <4BA11E37.7000207@frisch.fr> (raw)
In-Reply-To: <00d801cac5f9$474281f0$d5c785d0$@romulus.metastack.com>
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
next prev parent reply other threads:[~2010-03-17 18:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-17 17:04 Dario Teixeira
2010-03-17 17:36 ` [Caml-list] " Alain Frisch
2010-03-17 18:18 ` Dario Teixeira
2010-03-17 17:42 ` David Allsopp
2010-03-17 18:23 ` Alain Frisch [this message]
2010-03-18 11:10 ` David Allsopp
2010-03-22 18:08 ` Yoann Padioleau
2010-03-17 18:37 ` Dario Teixeira
2010-03-18 11:10 ` David Allsopp
2010-03-18 14:22 ` Goswin von Brederlow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA11E37.7000207@frisch.fr \
--to=alain@frisch.fr \
--cc=caml-list@yquem.inria.fr \
--cc=darioteixeira@yahoo.com \
--cc=dra-news@metastack.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).