From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7I8n7qJ008548 for ; Thu, 18 Aug 2011 10:49:07 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnIBAJ7RTE7U4367kWdsb2JhbABBhEmVFI8SFAEBAQEJCwsHFAMigUABAQUjBEASEAsaAiYCAlcZCYdpAqdXkUmBLIQMgRAEjAKMHYtr X-IronPort-AV: E=Sophos;i="4.68,244,1312149600"; d="scan'208";a="116164925" Received: from moutng.kundenserver.de ([212.227.126.187]) by mail1-smtp-roc.national.inria.fr with ESMTP; 18 Aug 2011 10:49:02 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-218-063.pools.arcor-ip.net [94.219.218.63]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MCdZW-1R3MCd3sYc-009TQl; Thu, 18 Aug 2011 10:49:02 +0200 Received: from [192.168.0.29] (dslb-084-058-001-185.pools.arcor-ip.net [84.58.1.185]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 6F580C00C7; Thu, 18 Aug 2011 10:49:01 +0200 (CEST) From: Gerd Stolpmann To: rixed@happyleptic.org Cc: caml-list In-Reply-To: <20110818080254.GA10854@ccellier.rd.securactive.lan> References: <4E4CC071.1060900@inria.fr> <20110818080254.GA10854@ccellier.rd.securactive.lan> Content-Type: text/plain; charset="UTF-8" Date: Thu, 18 Aug 2011 10:49:00 +0200 Message-ID: <1313657340.1825.39.camel@thinkpad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:UqxPHXenMLgoqWLyOyIst51j6juaMaelRE/hztUCxwx VFGlJPWqylKIrDd2gvKcM4DYKVoAezCxzdJZrtqL/TyCpNJI4d bEWLYQhZq+pNGk+oSJp9Ab8zPlWa2iLhL6hzgfppfe/yF14GHf ntVXqFc2ALJSuFQWRtXSd1usU2ZPPtpQR/0SUWUFvAsrKO4blW oyRXkn4lvG13UigHJNsXQ== Subject: Re: [Caml-list] [Ann] Zarith 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. ------------------------------------------------------------