From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id C73CFBC84 for ; Thu, 24 Mar 2005 20:41:36 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2OJfaVP013075 for ; Thu, 24 Mar 2005 20:41:36 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA16083 for ; Thu, 24 Mar 2005 20:41:36 +0100 (MET) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2OJfP7R013049 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 24 Mar 2005 20:41:35 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1DEYCh-0002tp-00 for ; Thu, 24 Mar 2005 19:41:15 +0000 Date: Thu, 24 Mar 2005 19:41:15 +0000 Cc: Ocaml Subject: Re: [Caml-list] Pervasives.compare output type Message-ID: <20050324194115.GB9518@furbychan.cocan.org> References: <42430B3B.60408@barettadeit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42430B3B.60408@barettadeit.com> User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at nez-perce with ID 424317F0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 424317E5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 pervasives:01 baretta:01 pervasives:01 intuitively:01 integers:01 subtraction:01 non-zero:01 iterating:01 notepad:01 wrote:01 strings:01 strings:01 define:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Thu, Mar 24, 2005 at 07:47:23PM +0100, Alex Baretta wrote: > Pervasives.compare currently returns an int. Intuitively it would be > more appropriate for it to return a union type such as the following. > > type comparison_result = Less | Equals | Greater > > What are the reasons behind the present design choice? Wouldn't it be for speed? You could define Pervasives.compare over integers just as a subtraction. For strings, you can write a loop which looks character-by-character over the strings, subtracting one character from another, and if the result is non-zero, return that result directly (else keep iterating). Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com