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 BCF6D7F75C for ; Wed, 10 Sep 2014 14:08:13 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yotambarnoy@gmail.com) identity=pra; client-ip=209.85.192.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yotambarnoy@gmail.com designates 209.85.192.51 as permitted sender) identity=mailfrom; client-ip=209.85.192.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qg0-f51.google.com) identity=helo; client-ip=209.85.192.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="postmaster@mail-qg0-f51.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AucBAK8+EFTRVcAzm2dsb2JhbABZg2BXBIJ4xzeHTAGBBAgWEAEBAQEBBgsLCRQqhAQBAQMBEhEdARQHHQEDAQsGAwIEBwM0AgIiAREBBQEcBhMJGYgLAQMJCA2LcZAqa4swgW0FgxCJEwoZJw1mhVMBEQEFDo8ZIgQHgnmBUwWGGo9XhHWCDZM8GCmFLiEvAYJOAQEB X-IPAS-Result: AucBAK8+EFTRVcAzm2dsb2JhbABZg2BXBIJ4xzeHTAGBBAgWEAEBAQEBBgsLCRQqhAQBAQMBEhEdARQHHQEDAQsGAwIEBwM0AgIiAREBBQEcBhMJGYgLAQMJCA2LcZAqa4swgW0FgxCJEwoZJw1mhVMBEQEFDo8ZIgQHgnmBUwWGGo9XhHWCDZM8GCmFLiEvAYJOAQEB X-IronPort-AV: E=Sophos;i="5.04,498,1406584800"; d="scan'208";a="93946436" Received: from mail-qg0-f51.google.com ([209.85.192.51]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Sep 2014 14:08:12 +0200 Received: by mail-qg0-f51.google.com with SMTP id e89so5252270qgf.10 for ; Wed, 10 Sep 2014 05:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=AjwmX7iSReoLKV/y0TL5mGGm9LFVGiPB5AJDTKOKp+o=; b=N6gW24RfVKgieZjYNnxEQHF7FtvCi56bxQ7ppvkJOcCPclOsHA9tp1xIji2nuvabul TL3xUzpMJZedec9yEArkXBTp45Dj1leLFE7Tla0slDHMP1x5P7TBEo9OqvUDO6V8k1pQ vUJx7Aj68GeE4FXD5Qghd13zGJ4pdPNR+KUrmbK0uoxQh08/g1GK6AXxBFFvkk4V0bJM Qhlo7S6rJAouVs/PpPVpGhwhSI7Q6ciAcs4S3O/j8PNzRJKMIJDUJfwMLfABj+FH/mI9 y37QNj/8z0rcOor1CL8CrtSXJJp4HTs261G48X7tlBs+dbXEJkQAVST0EKzW/BL2HLJp Eahg== X-Received: by 10.140.38.114 with SMTP id s105mr2206635qgs.4.1410350892070; Wed, 10 Sep 2014 05:08:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.174.68 with HTTP; Wed, 10 Sep 2014 05:07:51 -0700 (PDT) In-Reply-To: <1410348425.3003.11.camel@thinkpad> References: <54101221.3010304@users.sourceforge.net> <1410348425.3003.11.camel@thinkpad> From: Yotam Barnoy Date: Wed, 10 Sep 2014 08:07:51 -0400 Message-ID: To: Gerd Stolpmann Cc: SF Markus Elfring , Ocaml Mailing List Content-Type: multipart/alternative; boundary=001a11c1303eee40bb0502b4e7b2 Subject: Re: [Caml-list] Clarification for the configuration of comparison functions --001a11c1303eee40bb0502b4e7b2 Content-Type: text/plain; charset=UTF-8 Another reason is performance. The generic, polymorphic comparison function drops you out into C (which has a cost) and has to compare every single possible value combination. A customized comparison function stays in ocaml and handles only what you need ie. it's driven by type information that the generic function lacks. Yotam On Wed, Sep 10, 2014 at 7:27 AM, Gerd Stolpmann wrote: > Am Mittwoch, den 10.09.2014, 10:56 +0200 schrieb SF Markus Elfring: > > Hello, > > > > I extended my software development experience a bit for the programming > language > > "OCaml". I find my knowledge incomplete here to resolve an issue like > > "Comparison function application" alone. > > https://github.com/elfring/OTCL/issues/4 > > There are three reasons why you want to have your own comparison > function: > > - You need a different ordering than provided by Pervasives.compare. > For compound types the ordering of compare is implementation-defined, > and currently the implementation prefers the fastest way of comparing. > E.g. if you compare arrays, you don't get a lexicographic ordering. > This is sometimes not what you need. > - Your values are cyclic. compare may hang if you try to compare cyclic > values. > - Your values contains parts that cannot be compared, like functions. > With a custom comparison function you can skip these parts. > > Gerd > > > How do you think about to discuss corresponding implementation details > for an > > evolving class library? > > > > I would appreciate your advices. > > > > Regards, > > Markus > > > > -- > ------------------------------------------------------------ > Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de > My OCaml site: http://www.camlcity.org > Contact details: http://www.camlcity.org/contact.html > Company homepage: http://www.gerd-stolpmann.de > ------------------------------------------------------------ > > --001a11c1303eee40bb0502b4e7b2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Another reason is performance. The generic, polymorphic co= mparison function drops you out into C (which has a cost) and has to compar= e every single possible value combination. A customized comparison function= stays in ocaml and handles only what you need ie. it's driven by type = information that the generic function lacks.

Yotam
=

On Wed, Sep= 10, 2014 at 7:27 AM, Gerd Stolpmann <info@gerd-stolpmann.de><= /span> wrote:
Am Mittwoch, den 10.09.2014= , 10:56 +0200 schrieb SF Markus Elfring:
> Hello,
>
> I extended my software development experience a bit for the programmin= g language
> "OCaml". I find my knowledge incomplete here to resolve an i= ssue like
> "Comparison function application" alone.
> https://github.com/elfring/OTCL/issues/4

There are three reasons why you want to have your own comparison
function:

- You need a different ordering than provided by Pervasives.compare.
=C2=A0 For compound types the ordering of compare is implementation-defined= ,
=C2=A0 and currently the implementation prefers the fastest way of comparin= g.
=C2=A0 E.g. if you compare arrays, you don't get a lexicographic orderi= ng.
=C2=A0 This is sometimes not what you need.
- Your values are cyclic. compare may hang if you try to compare cyclic
=C2=A0 values.
- Your values contains parts that cannot be compared, like functions.
=C2=A0 With a custom comparison function you can skip these parts.

Gerd

> How do you think about to discuss corresponding implementation details= for an
> evolving class library?
>
> I would appreciate your advices.
>
> Regards,
> Markus
>

--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany=C2=A0 =C2=A0 gerd@gerd-stolpmann.de
My OCaml site:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.camlcity.org
Contact details:=C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.camlcity.org/contact.html
Company homepage:=C2=A0 =C2=A0 =C2=A0 =C2=A0
http://www.gerd-stolpmann.de
------------------------------------------------------------


--001a11c1303eee40bb0502b4e7b2--