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
Re: polymorphic recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-10-12 (16:51)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Local definitions
> Why CaML doesn't not allow the following style of local definitions:
> [...]
> or, the second variant: simply allow declaration of
> types, exceptions, open statements and others in "let-in"
> expressions with the same translation:

I think types and exceptions are best handled at the level of
modules, if necessary by creating a sub-structure to restrict their scope.

I've never found a convincing example of a type or exception
declaration local to an expression.

It is true that "let module ... in <expr>" lets you achieve the same
effect, but that's really not the intended use of "let module", which
is to allow functor applications to structures whose value components
may depend on function parameters.

> This syntax allow more convenient notation for local types,
> classes, exceptions and others definitions, than explicit usage of 
> local modules.

This is true, but I'd still recommend that you don't use types,
classes and exceptions local to an expression.  The module system
handles this just fine.

Best regards,

- Xavier Leroy