Am Donnerstag, den 18.08.2011, 10:02 +0200 schrieb
[email protected]:
> > - 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    [email protected]
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.
------------------------------------------------------------


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to