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:
> 
> >       local open M in
> >       ...
> >       end
> >
> > Of course, in OCaml this is solved by having open vs. include.
> 
> Also, would not :
> 
> let module = struct ... end in
> 
> be another solution for it, maybe in conjunction with the open syntax ?

Not sure, since I don't understand your code snippet, or how it is
related to local or open. Could you clarify a bit?

Anyway, there are of course several ways to rewrite SML's local. If it
involves only core declarations and the body consists of only one
function you might transform it into a let, although I think that is
usually not a good idea. On structure level the most faithful
translation to OCaml is:

module Local = struct (* Prefix *) module Body = struct (* Body *) end
end
include Local.Body

But this is quite unreadable and introduces the auxiliary module name
Local (which would not be necessary if OCaml supported let as module
expressions). In general relying on signature constraints is by far the
best solution and works for all sane uses of local.

	- 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