Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xleroy@pauillac.inria.fr>
To: arc@labri.u-bordeaux.fr
Cc: caml-list@pauillac.inria.fr
Subject: Re: modules local to functions.
Date: Wed, 10 Jan 1996 16:27:22 +0100 (MET)	[thread overview]
Message-ID: <199601101527.QAA22663@pauillac.inria.fr> (raw)
In-Reply-To: <9601081207.AA14189@waves.labri.u-bordeaux.fr> from "Andrew Conway" at Jan 8, 96 01:07:25 pm


Andrew Conway wrote:

> However, there are cases when I want to define a module in the middle
> of a function [...] That is, I would like to be abe to do:
> 
>   let toto digits =
> 	module Fred = Makespecific(struct let n = digits end) in
> 	Fred.mirror ();;

Christian Boos replied:

> My understanding is that YOU CAN'T do that in CSL at all: functor
> application means code generation, and there's no runtime code
> generation!

This is wrong. Functors are compiled once and for all, and functor
application proceeds exactly as function application.

Ada generics and C++ templates are generally implemented by
recompilation as Christian described, but that's just because these
languages don't implement lexical closures in their full generality.

So, there is no deep reason why modules could not be defined locally
to a (core-language) expression. Standard ML allows this (the "let
structure" and "local" constructs). That was left out of Caml Special
Light for simplicity. In particular, not having module expressions
inside core-language expressions avoids mutual recursion between the
module language and the core language; this makes both the theory and
the implementation simpler.

I still need to be convinced of the usefulness of local functor
applications (Andrew Conway's example was too sketchy to illuminate me),
but it can definitely be done.

- Xavier Leroy





  parent reply	other threads:[~1996-01-10 16:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-01-08 12:07 Andrew Conway
1996-01-09  8:04 ` Christian Boos
1996-01-09  9:34   ` Andrew Conway
1996-01-10 15:27 ` Xavier Leroy [this message]
1996-01-10 16:22   ` Andrew Conway
1996-01-10 17:08   ` Error message format (was Re: modules local to functions.) Christian Boos
1996-02-16 10:12   ` modules local to functions. (again) Christian Boos

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=199601101527.QAA22663@pauillac.inria.fr \
    --to=xleroy@pauillac.inria.fr \
    --cc=arc@labri.u-bordeaux.fr \
    --cc=caml-list@pauillac.inria.fr \
    /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