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
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: 2004-11-30 (20:30)
From: Ritesh Kumar <ritesh@c...>
Subject: Strange observation on polymorphic '<'
I saw this on the site
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.

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