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 SAA00159; Fri, 25 Apr 2003 18:34:07 +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 SAA32700 for ; Fri, 25 Apr 2003 18:34:05 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h3PGY5T15363 for ; Fri, 25 Apr 2003 18:34:05 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id E39915D03; Fri, 25 Apr 2003 19:34:03 +0300 (EEST) Date: Fri, 25 Apr 2003 19:34:02 +0300 Subject: Re: [Caml-list] Easy solution in OCaml? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: Siegfried Gonzi , To: Brian Hurt From: Ville-Pertti Keinonen In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 foo:01 generic:01 function-:01 compiler:01 ocaml:01 equality:01 int:01 wrote:03 inline:03 types:03 usefull:03 scheme:03 let:04 structural:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Friday, Apr 25, 2003, at 18:46 Europe/Helsinki, Brian Hurt wrote: > This is usefull for two reasons, in my experience: sometimes, it lets > the > compiler produce better code (for example, consider the function: > let foo x y = x == y > If you know that x and y will always be integers, doing: > let foo (x:int) (y:int) = x == y > allows the compiler to inline integer equals, rather than calling the > generic compare function- much faster). Actually, this is not true for your example, since you're comparing physical equality. Comparing physical equality (==, !=) is always efficient. Structural equality (=, <>) and order (>, >=, <, <=) will require calls to generic functions for unknown or indirect types. This is equivalent to eq? vs. equal? in Scheme, but there is no non-traversing middle case similar to eqv?. ------------------- 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