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 BAA12678; Sun, 29 Sep 2002 01:03:20 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA12903 for ; Sun, 29 Sep 2002 01:03:18 +0200 (MET DST) Received: from relay.pair.com (relay1.pair.com [209.68.1.20]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g8SN3H504073 for ; Sun, 29 Sep 2002 01:03:18 +0200 (MET DST) Received: (qmail 7408 invoked from network); 28 Sep 2002 23:03:16 -0000 Received: from adsl-host-sf-228.apexworld.net (HELO checkerlap.d6.com) (66.114.212.228) by relay1.pair.com with SMTP; 28 Sep 2002 23:03:16 -0000 X-pair-Authenticated: 66.114.212.228 Message-Id: <4.3.2.7.2.20020928155628.03c6f400@mail.d6.com> X-Sender: checker@mail.d6.com X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Sat, 28 Sep 2002 16:03:20 -0700 To: "John Gerard Malecki" , caml-list@inria.fr From: Chris Hecker Subject: Re: [Caml-list] Design advice In-Reply-To: <15766.9898.869203.134558@spike.artisan.com> References: <20020928190216.GA9876@force.stwing.upenn.edu> <4.3.2.7.2.20020928033941.03b2eb10@mail.d6.com> <20020928190216.GA9876@force.stwing.upenn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > type card = Number of int | Jack | Queen | King | Ace On a related note, for Xavier et al., why wasn't Number's field 0 assigned to the same counter as the int of the non-argument constructors? In other words, why isn't there a single incrementing int id from left to right, regardless of arguments? That would have made algorithmic manipulations on variants easier, because then you just have: let card_to_int (c : card) : int = let r = Obj.repr c in if Obj.is_int r then Obj.magic c else Obj.obj (Obj.field r 0);; I don't think it's possible to write card_to_int the way the compiler currently works. If there was a card_cardinality (!) function then you could do that + field 0 and the argument constructors would start at the end (still not as nice as if they were in the source code order, but better than nothing). Maybe you can write that with camlp4 (of course, with camlp4 you can probably just write the longhand match-with form, but if you're doing this a lot I'd assume match-with would be slower than just fetching the field). Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners