Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Feature request.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-04-09 (15:59)
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
    let result = e
  end in

I wrote a Camlp4 syntax extension to support this:

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

 let f (x : 'a) =
   let module Foo = struct
     exception E of 'a;;
     raise (E x)
   end in

-- Alain

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: