caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anthony Tavener <anthony.tavener@gmail.com>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
Cc: caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] Stability of order between polymorphic variants
Date: Wed, 4 Sep 2013 20:11:49 -0600	[thread overview]
Message-ID: <CAN=ouMQ+vC1uR4M3EqS8odZ2M+ohRY-wx7hD9ZA2Dz_c5wPzrA@mail.gmail.com> (raw)
In-Reply-To: <CAN=ouMR37Wszt1GT_t3+joaPkS9A1cQB8ONkwB86SfFVF3RkEA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]

Addendum: On a 32b arch, those names will wrap.


On Wed, Sep 4, 2013 at 8:06 PM, Anthony Tavener
<anthony.tavener@gmail.com>wrote:

> I haven't looked at how the compare happens for polyvariants, but I assume
> it's going to treat them as integers. And the integer value of the
> polymorphic variants is a simple hashing-type function (byterun/hash.c:
> caml_hash_variant). A multiplication by 223 is involved for each character
> of the variant name, so with a long enough name, compared to the integer
> size, you'll get wraparound. The short names you have there are okay.
>
> I'd be uncomfortable relying on this ordering, but I can imagine it would
> make some things a lot simpler...
>
>
>
> On Wed, Sep 4, 2013 at 6:17 PM, Daniel Bünzli <daniel.buenzli@erratique.ch
> > wrote:
>
>> Hello,
>>
>> I have this type
>>
>>   type weight = [ `W100 | `W200 | `W300 | `W400 | `W500 | `W600 | `W700 |
>> `W800 | `W900 ]
>>
>> In the current compiler it has the property that `Wx00 < `Wy00 if x < y.
>>
>> The question is, is the order between polymorphic variants an invariant
>> provided by the compiler or is it subject to change ?
>>
>> Best,
>>
>> Daniel
>>
>>
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>
>
>

[-- Attachment #2: Type: text/html, Size: 2401 bytes --]

  reply	other threads:[~2013-09-05  2:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05  0:17 Daniel Bünzli
2013-09-05  2:06 ` Anthony Tavener
2013-09-05  2:11   ` Anthony Tavener [this message]
2013-09-05  2:18     ` Francois Berenger
2013-09-05  2:31       ` Anthony Tavener
2013-09-05  7:47         ` Stéphane Glondu
2013-09-05  8:24 ` Jacques Garrigue
2013-09-05  8:39   ` Mark Shinwell
2013-09-05  9:26 ` Jeremy Yallop
2013-09-05 14:46   ` Goswin von Brederlow

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='CAN=ouMQ+vC1uR4M3EqS8odZ2M+ohRY-wx7hD9ZA2Dz_c5wPzrA@mail.gmail.com' \
    --to=anthony.tavener@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /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).