From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA22433; Wed, 9 Apr 2003 17:59:37 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA22455 for caml-list@pauillac.inria.fr; Wed, 9 Apr 2003 17:59:36 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA16897 for ; Tue, 8 Apr 2003 18:15:25 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h38GFNX25548 for ; Tue, 8 Apr 2003 18:15:23 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.9/1.01.28121999) with ESMTP id h38GFEbX053876 ; Tue, 8 Apr 2003 18:15:14 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id h38GFCt3010611 ; Tue, 8 Apr 2003 18:15:12 +0200 (MET DST) X-Authentication-Warning: clipper.ens.fr: frisch owned process doing -bs Date: Tue, 8 Apr 2003 18:15:12 +0200 (MET DST) From: Alain.Frisch@ens.fr X-X-Sender: frisch@clipper.ens.fr Reply-To: Alain.Frisch@ens.fr To: Lukasz Lew cc: Caml list Subject: Re: [Caml-list] Feature request. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Spam: no; 0.00; alain:01 frisch:01 caml-list:01 lukasz:01 lew:01 foo:01 struct:01 camlp:01 eleves:01 openin:01 run-time:01 encode:01 syntax:02 parser:02 exception:02 X-Spam: no; 0.00; alain:01 frisch:01 caml-list:01 lukasz:01 lew:01 foo:01 struct:01 camlp:01 eleves:01 openin:01 run-time:01 encode:01 syntax:02 parser:02 exception:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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