From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA17273; Thu, 31 May 2001 18:34:18 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA17052 for ; Thu, 31 May 2001 18:34:17 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f4VGYDb27329; Thu, 31 May 2001 18:34:14 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id JAA18823; Thu, 31 May 2001 09:34:09 -0700 (PDT) Date: Thu, 31 May 2001 09:34:09 -0700 (PDT) From: Brian Rogoff To: Luc Maranget cc: John Max Skaller , caml-list@inria.fr Subject: Re: [Caml-list] ocaml and named constants In-Reply-To: <200105310922.LAA0000007458@beaune.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 31 May 2001, Luc Maranget wrote: > But I have another remark > as far a ``manifest constants'' are the issue, Polymorphic > variants > (http://caml.inria.fr/ocaml/htmlman/manual003.html) > seem to do the job. > > After all, provided you do not care much about the actual value of Foo) Ah, the problem for me is that I really do care about the actual value for the constants. It turns out that I may process binary file formats (GDSII is the canonical example) where I want the name to correspond to a number. Of course, I can and do do it by hand (or use P4) by writing the equivalent of Ada's 'Pos and 'Val attributes for enumerated types. I would use plain old sum types too since I don't need them to be open for extension. It's a bit more cumbersome than I'd like it since I have to specify the mapping twice (constructor -> integer and integer -> constructor) which is cumbersome. -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr