Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Style question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andreas Rossberg <rossberg@p...>
Subject: Re: [Caml-list] Style question
Sven wrote:
> 
> > Not sure, since I don't understand your code snippet, or how it is
> > related to local or open. Could you clarify a bit?
> 
> Well, consider :
> 
> let module M = struct let f x = x * x end in M.f 5 ;;
> 
> Sure, you still have to access f trough M., but you could imagine something
> with the open/include directive.

I suspect you are mixing up issues. Brian asked what the best OCaml
translation of SML's "local" construct would be. In SML "local" allows
to limit the scope of declarations. Unlike "let", its body is not an
expression but again a sequence of declarations, so that the whole
construct is a declaration. I argued that the one of the few real uses
of that construct is to restrict the scope of an "open" declaration in
SML.

So we were not discussing how to encode something like "let open M in
exp" in OCaml (although that also might be an issue when translating SML
to OCaml). That is relatively easy with "let module" and has been
discussed here before, IIRC:

	let module Aux = struct open M val body = exp end in Aux.body

Was that what you were aiming at?

	- Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
 as kids, we would all be running around in darkened rooms, munching
 magic pills, and listening to repetitive electronic music."
 - Kristian Wilson, Nintendo Inc.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr