From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA03726; Sat, 9 Oct 2004 20:10:35 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 UAA03706 for ; Sat, 9 Oct 2004 20:10:34 +0200 (MET DST) Received: from caduceus.jf.intel.com (fmr06.intel.com [134.134.136.7]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i99IAWLw017052; Sat, 9 Oct 2004 20:10:33 +0200 Received: from talaria.jf.intel.com (talaria.jf.intel.com [10.7.209.7]) by caduceus.jf.intel.com (8.12.9-20030918-01/8.12.9/d: major-outer.mc,v 1.15 2004/01/30 18:16:28 root Exp $) with ESMTP id i99I9tul023591; Sat, 9 Oct 2004 18:09:55 GMT Received: from orsmsxvs041.jf.intel.com (orsmsxvs041.jf.intel.com [192.168.65.54]) by talaria.jf.intel.com (8.12.9-20030918-01/8.12.9/d: major-inner.mc,v 1.11 2004/07/29 22:51:53 root Exp $) with SMTP id i99I1PPh004738; Sat, 9 Oct 2004 18:01:43 GMT Received: from orsmsx332.amr.corp.intel.com ([192.168.65.60]) by orsmsxvs041.jf.intel.com (SAVSMTP 3.1.2.35) with SMTP id M2004100911103002101 ; Sat, 09 Oct 2004 11:10:30 -0700 Received: from orsmsx407.amr.corp.intel.com ([192.168.65.50]) by orsmsx332.amr.corp.intel.com with Microsoft SMTPSVC(6.0.3790.0); Sat, 9 Oct 2004 11:10:30 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Are you sure the new "=" of 3.08 is good ? Date: Sat, 9 Oct 2004 11:10:30 -0700 Message-ID: <012676D607FCF54E986746512C22CE7D0FE7BE@orsmsx407> Thread-Topic: [Caml-list] Are you sure the new "=" of 3.08 is good ? Thread-Index: AcSt3ktRJ/ry+aWLSk2jheN8Q3A2ZAASwr9w From: "Harrison, John R" To: "Xavier Leroy" Cc: "caml-list" X-OriginalArrivalTime: 09 Oct 2004 18:10:30.0871 (UTC) FILETIME=[43461670:01C4AE2B] X-Scanned-By: MIMEDefang 2.31 (www . roaringpenguin . com / mimedefang) X-Miltered: at nez-perce with ID 41682998.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 johnh:01 pervasives:01 damien:01 hash-consing:01 recursion:01 lambdas:01 equality:01 equality:01 behaviour:01 behaviour:01 shallow:02 comparison:02 comparison:02 types:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk | As I said in an earlier post, you can do |=20 | let (=3D?) x y =3D (Pervasives.compare x y =3D 0) |=20 | and use =3D? instead of =3D in places where you need the "early stop" | behaviour. OK. I wanted to be sure this was a recommended solution, not just something that happens to work at the moment. | Of course, if the speed of equality is critical, you can also define | your own comparison functions for the types of interest, or even (as | Damien suggested) implement hash-consing. In fact, the key function is an alpha-conversion test on name-carrying lambda-terms. Since it's almost always expected to succeed with full equality after a shallow comparison, I now do an equality test first to get the early-out behaviour. I can just change it to put an "=3D=3D" into the main recursion when it hasn't gone through any lambdas. John. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners