From: Brian Rogoff <bpr@best.com>
To: Chris Hecker <checker@d6.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] checking for same ctor type?
Date: Wed, 27 Jun 2001 19:55:27 -0700 (PDT) [thread overview]
Message-ID: <Pine.BSF.4.21.0106271950090.28760-100000@shell5.ba.best.com> (raw)
In-Reply-To: <200106280240.TAA14693@smtp2-cm.mail.eni.net>
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
next prev parent reply other threads:[~2001-06-28 2:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-28 2:40 Chris Hecker
2001-06-28 2:55 ` Brian Rogoff [this message]
[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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.BSF.4.21.0106271950090.28760-100000@shell5.ba.best.com \
--to=bpr@best.com \
--cc=caml-list@inria.fr \
--cc=checker@d6.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).