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 EAA08110; Thu, 28 Jun 2001 04:55:30 +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 EAA08058 for ; Thu, 28 Jun 2001 04:55:29 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f5S2tSH02735 for ; Thu, 28 Jun 2001 04:55:28 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id TAA27403; Wed, 27 Jun 2001 19:55:27 -0700 (PDT) Date: Wed, 27 Jun 2001 19:55:27 -0700 (PDT) From: Brian Rogoff To: Chris Hecker cc: caml-list@inria.fr Subject: Re: [Caml-list] checking for same ctor type? In-Reply-To: <200106280240.TAA14693@smtp2-cm.mail.eni.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 27 Jun 2001, Chris Hecker wrote: > What's the right way to check if two variants have the same ctor, but > not necessarily the same values in the ctor parms? > > For example, I want to check if both data_types are Strings: > > type data_type = > String of string > | Float of float > > let a = String "foo" > let b = String "bar" > let c = Float 2.0 > > let ctor_equal a b = ??? let ctor_equal a b = match a,b with String(_),String(_) | Float(_),Float(_) -> true | _,_ -> false > ctor_equal a b = true > ctor_equal a c = false > > I can think of a couple definitions of ctor_equal, one using > Hashtbl.hash_param 1 1 and one using Obj.tag (which both appear to be > doing the same thing). Both of these seem a bit cheesy and > implementation dependent. Yes, but there's only one implementation, right? > Is there a better way? Beauty is in the eye of the beholder. -- Brian ------------------- 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