caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] checking for same ctor type?
@ 2001-06-28  2:40 Chris Hecker
  2001-06-28  2:55 ` Brian Rogoff
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Hecker @ 2001-06-28  2:40 UTC (permalink / raw)
  To: caml-list


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 = ???

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.

Is there a better way?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-06-29 13:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-28  2:40 [Caml-list] checking for same ctor type? Chris Hecker
2001-06-28  2:55 ` Brian Rogoff
     [not found] ` <Pine.BSF.4.21.0106271950090.28760-100000@shell5.ba.best.co m>
2001-06-28  3:06   ` Chris Hecker
2001-06-29 13:14 ` Chris Quinn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).