caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* local Open
@ 2005-01-25 13:27 Oliver Bandel
  2005-01-25 18:37 ` [Caml-list] " Brian Sniffen
  2005-01-26 10:58 ` Julien Signoles
  0 siblings, 2 replies; 3+ messages in thread
From: Oliver Bandel @ 2005-01-25 13:27 UTC (permalink / raw)
  To: caml-list

Hello,

is it planned to have a local Open-statement in OCaml
in newer Versions?
This would help a lot to easily write code with
opened modules and at the same time to have
unpolluted namespace.

There are local modules... but not local Open's?!

Any idea about that?

Ciao,
    Oliver


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] local Open
  2005-01-25 13:27 local Open Oliver Bandel
@ 2005-01-25 18:37 ` Brian Sniffen
  2005-01-26 10:58 ` Julien Signoles
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Sniffen @ 2005-01-25 18:37 UTC (permalink / raw)
  To: Oliver Bandel; +Cc: caml-list

On Tue, 25 Jan 2005 14:27:40 +0100, Oliver Bandel
<oliver@first.in-berlin.de> wrote:
> is it planned to have a local Open-statement in OCaml
> in newer Versions?

There is no local open because open is entirely syntactic.  What you
can do to simulate a local open is this: wrap your code in a module
which is a functor.  Provide as arguments the modules you wish to
"locally open".  Then you can write in those terms inside your
functor.

Also, be aware that "open" is only scoped to that file in which it
occurs, and you can acheive similar effects with less writing by
splitting your code into separate files.

-- 
Brian T. Sniffen
bts@alum.mit.edu    or    brian.sniffen@gmail.com
http://www.evenmere.org/~bts


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] local Open
  2005-01-25 13:27 local Open Oliver Bandel
  2005-01-25 18:37 ` [Caml-list] " Brian Sniffen
@ 2005-01-26 10:58 ` Julien Signoles
  1 sibling, 0 replies; 3+ messages in thread
From: Julien Signoles @ 2005-01-26 10:58 UTC (permalink / raw)
  To: Oliver Bandel; +Cc: caml-list

Hello,

> There are local modules... but not local Open's?!
>
> Any idea about that?

openin is probably your friend. It is a camlp4 syntax extension by Alain
Frisch allowing local open's and struct's. The file is available at:

	http://www.eleves.ens.fr/home/frisch/soft.html#openin

exemple:

module M = struct let x = 0 end
let y = open M in x top

-->

let y =
  let module OPENIN_1 = struct open M let res = x in
  OPENIN_1.res

Hope this helps,
Julien Signoles
-- 
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-26 10:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-25 13:27 local Open Oliver Bandel
2005-01-25 18:37 ` [Caml-list] " Brian Sniffen
2005-01-26 10:58 ` Julien Signoles

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).