caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: rixed@happyleptic.org
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] [Ann] Zarith
Date: Thu, 18 Aug 2011 10:49:00 +0200	[thread overview]
Message-ID: <1313657340.1825.39.camel@thinkpad> (raw)
In-Reply-To: <20110818080254.GA10854@ccellier.rd.securactive.lan>

Am Donnerstag, den 18.08.2011, 10:02 +0200 schrieb
rixed@happyleptic.org:
> > - polymorphic comparisons (=, <, >, etc) work correctly on Zarith's
> >   big integers, provided OCaml 3.12.1 or later is used.
> 
> Is there anything special in 3.12.1 to help library authors define
> specialized comparison operators ?

You can define such operators for abstract values only (i.e. on the C
side of bindings), and this is available for a long time. There is no
such feature for data structures entirely programmed in OCaml (which is
a bit self-discriminating, IMHO).

I guess the problem is that any addition of comparison operators
requires another level of indirection, and it would feel strange to
program and use. This means one could imagine with minimal modifications
of the current runtime to support something like

type 'a wrapped_value
val wrap_value : 'a comparison_operators -> 'a -> 'a wrapped_value
val unwrap_value : 'a wrapped_value -> 'a

In the machine representation, a wrapped_value would have a special tag
to signal the runtime that it carries comparison operators. Because of
this indirection, it is inconvenient to use, as the programmer of a data
structure would need to wrap and unwrap values just to override the
comparisons (basically like it is possible in C today). One idea to
improve this could be a special kind of functor that is able to add
wrap/unwrap calls to a given argument module, so the programmer would
not have to program this explicitly.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
*** Searching for new projects! Need consulting for system
*** programming in Ocaml? Gerd Stolpmann can help you.
------------------------------------------------------------


  reply	other threads:[~2011-08-18  8:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-18  7:34 Xavier Leroy
2011-08-18  8:02 ` rixed
2011-08-18  8:49   ` Gerd Stolpmann [this message]
2011-08-18  8:58   ` Gabriel Scherer
2011-08-18 10:42     ` Alain Frisch

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=1313657340.1825.39.camel@thinkpad \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=rixed@happyleptic.org \
    /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).