caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yotam Barnoy <yotambarnoy@gmail.com>
To: Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: SF Markus Elfring <elfring@users.sourceforge.net>,
	Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Clarification for the configuration of comparison functions
Date: Wed, 10 Sep 2014 08:07:51 -0400	[thread overview]
Message-ID: <CAN6ygO=U3uN+U2iTJvbRv6a+92GO_cZYxM==Q6YGqGw1bnE6-Q@mail.gmail.com> (raw)
In-Reply-To: <1410348425.3003.11.camel@thinkpad>

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

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 <info@gerd-stolpmann.de>
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
> ------------------------------------------------------------
>
>

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

  reply	other threads:[~2014-09-10 12:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10  8:56 SF Markus Elfring
2014-09-10 11:27 ` Gerd Stolpmann
2014-09-10 12:07   ` Yotam Barnoy [this message]
2014-09-10 12:26     ` Gerd Stolpmann
2014-09-10 12:37       ` Adrien Nader
2014-09-10 12:38         ` Yotam Barnoy
2014-09-10 12:41       ` Pippijn van Steenhoven
2014-09-10 12:51         ` Gerd Stolpmann
2014-09-10 12:56           ` Ben Millwood
     [not found]       ` <CAADdkeKquMWyHjQhgd2SOZYr9DaS2E+i3Ug5=xb25BK-+n16eQ@mail.gmail.com>
2014-09-10 12:44         ` Gerd Stolpmann
2014-09-10 20:56   ` SF Markus Elfring
2014-09-11  7:46     ` Francois Berenger
2014-09-11  8:10       ` SF Markus Elfring
2014-09-11  8:24         ` Francois Berenger
2014-09-11  8:33           ` SF Markus Elfring
2014-09-11  8:39             ` Frédéric Bour
2014-10-06 20:50               ` SF Markus Elfring

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='CAN6ygO=U3uN+U2iTJvbRv6a+92GO_cZYxM==Q6YGqGw1bnE6-Q@mail.gmail.com' \
    --to=yotambarnoy@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=elfring@users.sourceforge.net \
    --cc=info@gerd-stolpmann.de \
    /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).