Version française
Home     About     Download     Resources     Contact us    
Browse thread
Strange observation on polymorphic '<'
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ritesh Kumar <ritesh@c...>
Subject: Strange observation on polymorphic '<'
Hi,
I saw this on the site http://merjis.com/developers/ocaml_tutorial/ch11
The author says that even if the types of a function (let max a b = if 
a>b then a else b)which internally uses the '>' operator are known (by 
type inference) and are found to be ints, the ocamlopt compiler still 
calls the generic 'greaterthan' function written in C to compare them. 
This seems rather an over kill when a simple comparison instruction 
could have done the job. Am I missing something here? Let us assume 
that the function which internally uses the '<' operator is used only 
in the context of integers inside the program.

Ritesh
--
What you see is an illusion... well protected, well cherished only by 
you.