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
Estimating the size of the ocaml community
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-05 (16:37)
From: Richard Jones <rich@a...>
Subject: Why can't types and exceptions be nested (was: Re: [Caml-list] Estimating the size of the ocaml community)
On Sat, Feb 05, 2005 at 02:14:18PM +0100, Oliver Bandel wrote:
> ...well....
> type sometimes_t = Integer of int | One_symbol | Another_symbol

Another annoyance of OCaml is that 'type' definitions (and exception
defns for that matter) can't be nested.  I'm a big big fan of nested
functions, and sometimes I want to return a type which is only used
briefly between two nested functions.  Instead the type has to go
right at the start of the outer function, which may be many pages of
code away.  This reduces readability.

Is there a reason why types (and exceptions) can't appear nested?  I
suppose that a nested type might "escape" the scope where it appears,
but then surely it becomes an opaque type, just like types hidden in
modules.  The reason why exceptions cannot be nested is slightly more
understandable, because the runtime appears to build up a global list
of exceptions, but I'm sure there's some workaround.


Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology -
Team Notepad - intranets and extranets for business -