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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 01C1B820A1 for ; Thu, 5 Sep 2013 04:18:47 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of berenger@riken.jp) identity=pra; client-ip=134.160.33.161; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of berenger@riken.jp designates 134.160.33.161 as permitted sender) identity=mailfrom; client-ip=134.160.33.161; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@postman.riken.jp designates 134.160.33.161 as permitted sender) identity=helo; client-ip=134.160.33.161; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="postmaster@postman.riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhkBAGnpJ1KGoCGhnGdsb2JhbABbgzyvTZJKgUAOAQEBAQEICwkJFCiCJAEBBAEyAQU2CgYLCxgJBBIIBwkDAgECAQ8kARETBgIBAQ6HXgMJBgywfQMKiSWMdIJzFoQHA4kzimiBcYFpgS+EfYQTgXiIXg X-IPAS-Result: AhkBAGnpJ1KGoCGhnGdsb2JhbABbgzyvTZJKgUAOAQEBAQEICwkJFCiCJAEBBAEyAQU2CgYLCxgJBBIIBwkDAgECAQ8kARETBgIBAQ6HXgMJBgywfQMKiSWMdIJzFoQHA4kzimiBcYFpgS+EfYQTgXiIXg X-IronPort-AV: E=Sophos;i="4.90,843,1371074400"; d="scan'208";a="31538683" Received: from postman1.riken.jp (HELO postman.riken.jp) ([134.160.33.161]) by mail2-smtp-roc.national.inria.fr with ESMTP; 05 Sep 2013 04:18:44 +0200 Received: from postman.riken.jp (postman1.riken.jp [127.0.0.1]) by postman.riken.jp (Postfix) with SMTP id 278542588001 for ; Thu, 5 Sep 2013 11:18:41 +0900 (JST) Received: from [172.27.98.103] (rikad98.riken.jp [134.160.214.98]) by postman.riken.jp (Postfix) with ESMTPA id 3CD1532A0085 for ; Thu, 5 Sep 2013 11:18:40 +0900 (JST) Message-ID: <5227E9FA.1020301@riken.jp> Date: Thu, 05 Sep 2013 11:18:34 +0900 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: caml-list@inria.fr References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.9.5.20915 Subject: Re: [Caml-list] Stability of order between polymorphic variants On 09/05/2013 11:11 AM, Anthony Tavener wrote: > Addendum: On a 32b arch, those names will wrap. Why not write a to_int for your type and then a specialized comparator using it? > 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ünzli > > > 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 > > >