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 KAA12459; Thu, 14 Jun 2001 10:39:30 +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 KAA12411 for ; Thu, 14 Jun 2001 10:39:29 +0200 (MET DST) Received: from mta5.snfc21.pbi.net (mta5.snfc21.pbi.net [206.13.28.241]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f5E8dSj01216 for ; Thu, 14 Jun 2001 10:39:29 +0200 (MET DST) Received: from checkerlap.d6.com ([64.160.54.6]) by mta5.snfc21.pbi.net (Sun Internet Mail Server sims.3.5.2000.01.05.12.18.p9) with ESMTP id <0GEW0099ZW1JA2@mta5.snfc21.pbi.net> for caml-list@inria.fr; Thu, 14 Jun 2001 01:39:25 -0700 (PDT) Date: Thu, 14 Jun 2001 01:41:29 -0700 From: Chris Hecker Subject: Re: [Caml-list] enums in OCaml? In-reply-to: <20010614011550.A28578@jean> X-Sender: def6@shell16.ba.best.com To: leary@nwlink.com, caml Message-id: <4.3.2.7.2.20010614013609.02977630@shell16.ba.best.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Content-type: text/plain; charset="us-ascii" References: <20010612192126.B24440@jean> <20010612192126.B24440@jean> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >So, what's so wrong with just using variables? >let Accel = 1;; >let Stop = 0;; >seems pretty short to write and shortest to use... Am I missing something >( elegant | obvious )? Is that just ugly? You can't pattern match on variables (even constant nonmutable ones like that). See the list archives for threads about this. You have to do this: match value with | v when v = accel -> blah | v when v = stop -> etc Not very pretty. If you're going to be using them in code a lot, then I'd just use variants (sum types). Yes, it'd be best to be able to switch on the constants, but this is apparently hard; see the archive. Chris ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr