From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 35A46820A1 for ; Thu, 5 Sep 2013 04:11:51 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of anthony.tavener@gmail.com) identity=pra; client-ip=209.85.215.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="anthony.tavener@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of anthony.tavener@gmail.com designates 209.85.215.182 as permitted sender) identity=mailfrom; client-ip=209.85.215.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="anthony.tavener@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ea0-f182.google.com) identity=helo; client-ip=209.85.215.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="postmaster@mail-ea0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqcBAMnnJ1LRVde2k2dsb2JhbABbgzxRrnyKCYhBgSIIFg4BAQEBBwsLCRQEJIIkAQEEAUABGxILAQMBCwYFBAcNDSEhAQERAQUBChIGExKHXQEDCQYMnCeMUIMFhDQKGScDCmSIOwEFDIxogmgEB4QdA4k1imaBcYFpgS+JEIF4g0YYKYRnHQ X-IPAS-Result: AqcBAMnnJ1LRVde2k2dsb2JhbABbgzxRrnyKCYhBgSIIFg4BAQEBBwsLCRQEJIIkAQEEAUABGxILAQMBCwYFBAcNDSEhAQERAQUBChIGExKHXQEDCQYMnCeMUIMFhDQKGScDCmSIOwEFDIxogmgEB4QdA4k1imaBcYFpgS+JEIF4g0YYKYRnHQ X-IronPort-AV: E=Sophos;i="4.90,843,1371074400"; d="scan'208";a="25750666" Received: from mail-ea0-f182.google.com ([209.85.215.182]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Sep 2013 04:11:50 +0200 Received: by mail-ea0-f182.google.com with SMTP id o10so582322eaj.27 for ; Wed, 04 Sep 2013 19:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WRzq88TPNM3elkpxKidYArnWuXDIUwnSYCay972MXSY=; b=HKwDTtezgsN8/zz36Ov1+GJsO7EJQxI2t0jLq7j1Lb2OeWywumN3DUL2/NoyUvcLjy smfnqSX52PuzQNry7DDAbbBUv6AsvVtMGxl4ZoR8dquRQvjXP03DrnZXabKDTf5ekREt 1OND/OcGyTELxjbACTHReJxlJmpTDwEU1Baumj0qgmACz5MFAGViqRAN0vvX+pZZEBMu piYpDB3gT7J7qex+g2M68bqsUTHLhyKIUL3dEC9EfU0eCKVlJzM2IQc/K9lkYwDCFteM 6cN5OOJBATcW6VGkwwWqUyW9D3rEzNkpm9rWBnISWAbc32slSHW8KBVgonxNxBDzK0Xo 12UA== MIME-Version: 1.0 X-Received: by 10.14.210.8 with SMTP id t8mr9277639eeo.39.1378347109970; Wed, 04 Sep 2013 19:11:49 -0700 (PDT) Received: by 10.14.10.68 with HTTP; Wed, 4 Sep 2013 19:11:49 -0700 (PDT) In-Reply-To: References: Date: Wed, 4 Sep 2013 20:11:49 -0600 Message-ID: From: Anthony Tavener To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: caml list Content-Type: multipart/alternative; boundary=047d7b603fe2de16b904e5997187 Subject: Re: [Caml-list] Stability of order between polymorphic variants --047d7b603fe2de16b904e5997187 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Addendum: On a 32b arch, those names will wrap. On Wed, Sep 4, 2013 at 8:06 PM, Anthony Tavener 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=FCnzli > wrote: > >> Hello, >> >> I have this type >> >> type weight =3D [ `W100 | `W200 | `W300 | `W400 | `W500 | `W600 | `W70= 0 | >> `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 >> > > --047d7b603fe2de16b904e5997187 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Addendum: On a 32b arch, those names will wrap.


On Wed, Sep 4, 201= 3 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 s= imple hashing-type function (byterun/hash.c: caml_hash_variant). A multipli= cation 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 imagi= ne it would make some things a lot simpler...



On Wed, Sep 4, 2013 at 6:17 PM, Daniel B=FCnzli <daniel.buenzli@= erratique.ch> wrote:
Hello,

I have this type

=A0 type weight =3D [ `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 pro= vided by the compiler or is it subject to change ?

Best,

Daniel



--
Caml-list mailing list. =A0Subscription management and archives:
ht= tps://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


--047d7b603fe2de16b904e5997187--