From: Alain.Frisch@ens.fr
To: Lukasz Lew <ll189417@zodiac.mimuw.edu.pl>
Cc: Caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] Feature request.
Date: Tue, 8 Apr 2003 18:15:12 +0200 (MET DST) [thread overview]
Message-ID: <Pine.SOL.4.44.0304081805480.4273-100000@clipper.ens.fr> (raw)
In-Reply-To: <Pine.LNX.4.44.0304081318010.16256-100000@zodiac.mimuw.edu.pl>
On Tue, 8 Apr 2003, Lukasz Lew wrote:
> I found that it would be usefull if some of the language constructions
> could be made localy. For example "open ... in" or "type ... in".
> Why "open in" isn't in standard parser?
>
> Why some constructions are restricted to global (module) use?
Local modules can help you !
If X is a structure item (open, type, exception,...), you can
encode (X in e) as:
let module Foo = struct
X
let result = e
end in
Foo.result
I wrote a Camlp4 syntax extension to support this:
http://www.eleves.ens.fr/home/frisch/soft#openin
It defines the following construction:
open M in e
and the generalization:
struct ... end in e
There is a small run-time overhead, because of the creation of the local
structure. Also, note that type variables defined outside a local
structure are not visible within the structure; the following does not
work:
let f (x : 'a) =
let module Foo = struct
exception E of 'a;;
raise (E x)
end in
()
-- Alain
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-04-09 15:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-08 11:31 Lukasz Lew
2003-04-08 16:15 ` Alain.Frisch [this message]
2003-04-08 19:06 ` Lukasz Lew
2003-04-08 18:03 ` Tim Freeman
2003-04-09 6:32 ` Jean-Christophe Filliatre
2003-04-09 7:44 ` Alain.Frisch
2003-04-12 20:35 ` Andreas Rossberg
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=Pine.SOL.4.44.0304081805480.4273-100000@clipper.ens.fr \
--to=alain.frisch@ens.fr \
--cc=caml-list@inria.fr \
--cc=ll189417@zodiac.mimuw.edu.pl \
/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