English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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 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.

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