Browse thread
[Caml-list] Feature request.
-
Lukasz Lew
- tim@f...
- Jean-Christophe Filliatre
- Alain.Frisch@e...
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alain.Frisch@e... |
| Subject: | Re: [Caml-list] Feature request. |
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