From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 47A1ABC88 for ; Sat, 5 Feb 2005 17:37:35 +0100 (CET) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j15GbYXF006723 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 5 Feb 2005 17:37:35 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1CxSw8-0003Qs-00 for ; Sat, 05 Feb 2005 16:37:32 +0000 Date: Sat, 5 Feb 2005 16:37:32 +0000 Cc: caml-list@yquem.inria.fr Subject: Why can't types and exceptions be nested (was: Re: [Caml-list] Estimating the size of the ocaml community) Message-ID: <20050205163732.GA13169@furbychan.cocan.org> References: <8008871f05020213362d21ba87@mail.gmail.com> <000f01c50971$baad4840$0100a8c0@mshome.net> <1107403128.32586.223.camel@pelican.wigram> <20050203173556.4acec1c5.ocaml-erikd@mega-nerd.com> <009a01c50a1e$f6c92080$0100a8c0@mshome.net> <20050204103006.GA498@first.in-berlin.de> <20050205131418.GC484@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050205131418.GC484@first.in-berlin.de> User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at nez-perce with ID 4204F64E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 oliver:01 bandel:01 wrote:01 ocaml:01 runtime:01 notepad:01 ...:98 ....:98 exception:01 workaround:01 integer:01 exceptions:01 exceptions:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: 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. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com