From: Yoann Padioleau <padator@wanadoo.fr>
To: Alain Frisch <alain@frisch.fr>
Cc: David Allsopp <dra-news@metastack.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Lazy modules
Date: Mon, 22 Mar 2010 11:08:26 -0700 [thread overview]
Message-ID: <8307EBEB-28BA-452F-BAF4-06A65DACD9AD@wanadoo.fr> (raw)
In-Reply-To: <4BA11E37.7000207@frisch.fr>
On Mar 17, 2010, at 11:23 AM, Alain Frisch wrote:
>
> 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.
Which makes me wonder why people not use simply record or tuples to solve such problem ...
Many times I've found that passing a record of functions was as good as functors and simply
more flexible because they are in the same "value" world.
> 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
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
next prev parent reply other threads:[~2010-03-22 18:11 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
2010-03-18 11:10 ` David Allsopp
2010-03-22 18:08 ` Yoann Padioleau [this message]
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=8307EBEB-28BA-452F-BAF4-06A65DACD9AD@wanadoo.fr \
--to=padator@wanadoo.fr \
--cc=alain@frisch.fr \
--cc=caml-list@yquem.inria.fr \
--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