Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Easy solution in OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ville-Pertti Keinonen <will@e...>
Subject: Re: [Caml-list] Easy solution in OCaml?

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