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 TAA02158; Fri, 1 Jun 2001 19:02:23 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA02349 for caml-list@pauillac.inria.fr; Fri, 1 Jun 2001 19:02:22 +0200 (MET DST) 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 DAA22504 for ; Fri, 1 Jun 2001 03:46:01 +0200 (MET DST) Received: from localhost.localdomain (ppp239.dyn146.pacific.net.au [210.23.146.239]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f511jvb05712; Fri, 1 Jun 2001 03:45:58 +0200 (MET DST) Received: from ozemail.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id LAA08506; Fri, 1 Jun 2001 11:45:56 +1000 Message-ID: <3B16F3D4.74E326E0@ozemail.com.au> Date: Fri, 01 Jun 2001 11:45:56 +1000 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Luc Maranget CC: Brian Rogoff , caml-list@inria.fr Subject: Re: [Caml-list] ocaml and named constants References: <200105310922.LAA0000007458@beaune.inria.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Luc Maranget wrote: > But I have another remark as far a ``manifest constants'' are the issue, Polymorphic > variants seem to do the job. > > After all, provided you do not care much about the actual value of Foo) > you can write : > > match x with > | `Foo -> ... > | `Bar -> ... > | _ -> ... In the 'real world' the constants are often integers or strings whose values are dictated by standards, and this technique requires providing two functions to map the value to and from variants. Sometimes this is OK. Sometimes, it is a problem: for example the library Posix support is lacking all the error codes and socket options available on some platforms, and there is no workaround (other than magic). -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr