From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA09328 for caml-red; Fri, 30 Jun 2000 17:36:06 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA07583 for ; Fri, 30 Jun 2000 15:15:11 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e5UDFA517256; Fri, 30 Jun 2000 15:15:10 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA10805; Fri, 30 Jun 2000 15:15:10 +0200 (MET DST) Message-ID: <20000630151510.42620@pauillac.inria.fr> Date: Fri, 30 Jun 2000 15:15:10 +0200 From: Xavier Leroy To: Juergen Pfitzenmaier , caml-list@inria.fr Subject: Re: too many constructors References: <200006281716.TAA02282@sunstroke.informatik.uni-tuebingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <200006281716.TAA02282@sunstroke.informatik.uni-tuebingen.de>; from Juergen Pfitzenmaier on Wed, Jun 28, 2000 at 07:16:45PM +0200 Sender: weis@pauillac.inria.fr > when defining a lot of variants the following message seems to restrictive: > Too many constructors -- maximum is 248 constructors > What is the reason for this ? Can this limit be pushed higher ? Actually, the limit is 248 non-constant constructors. The reason is that the "tag" that identifies a non-constant constructor is stored in a 8-bit field in the block header, and some values for this "tag" field are reserved by the runtime system, leaving only 248 tags for non-constant constructors. As for constant constructors, these are represented by integers, so there is essentially no limit. This said, there is a small bug in the compiler: it limits the total number of constructors to 248, instead of the number of non-constant constructors. This bug was recently reported to us, and a patch for OCaml 3.00 is included below. - Xavier Leroy Index: csl/typing/typedecl.ml diff -c csl/typing/typedecl.ml:1.36 csl/typing/typedecl.ml:1.37 *** csl/typing/typedecl.ml:1.36 Tue Mar 21 15:43:24 2000 --- csl/typing/typedecl.ml Mon May 22 10:24:05 2000 *************** *** 10,16 **** (* *) (***********************************************************************) ! (* $Id: typedecl.ml,v 1.36 2000/03/21 14:43:24 xleroy Exp $ *) (**** Typing of type definitions ****) --- 10,16 ---- (* *) (***********************************************************************) ! (* $Id: typedecl.ml,v 1.37 2000/05/22 08:24:05 xleroy Exp $ *) (**** Typing of type definitions ****) *************** *** 141,147 **** raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); all_constrs := StringSet.add name !all_constrs) cstrs; ! if List.length cstrs > Config.max_tag then raise(Error(sdecl.ptype_loc, Too_many_constructors)); Type_variant(List.map (fun (name, args) -> --- 141,148 ---- raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); all_constrs := StringSet.add name !all_constrs) cstrs; ! if List.length (List.filter (fun (name, args) -> args <> []) cstrs) ! > Config.max_tag then raise(Error(sdecl.ptype_loc, Too_many_constructors)); Type_variant(List.map (fun (name, args) -> *************** *** 355,361 **** | Duplicate_constructor s -> fprintf ppf "Two constructors are named %s" s | Too_many_constructors -> ! fprintf ppf "Too many constructors -- maximum is %i constructors" Config.max_tag | Duplicate_label s -> fprintf ppf "Two labels are named %s" s --- 356,363 ---- | Duplicate_constructor s -> fprintf ppf "Two constructors are named %s" s | Too_many_constructors -> ! fprintf ppf "Too many non-constant constructors -- \ ! maximum is %i non-constant constructors" Config.max_tag | Duplicate_label s -> fprintf ppf "Two labels are named %s" s