Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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 Archives:
Bug reports: FAQ:
Beginner's list: