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-12-03 (07:25)
From: Ritesh Kumar <ritesh@c...>
Subject: Re: [Caml-list] Strange observation on polymorphic '<'
Oh sure... but I was of the mind that if you had a polymorphic function 
which on certain types have extremely small (one instruction) size (as 
is the case with the '>' operator) then it makes sense to inline that 
function at a point where it is invoked with that type.
For eg. given the code
let max a b = if a>b then a else b;;
print_int (max 2 3);;
Separate compilation means that the function max should use the C call 
(for the toplevel module). However, the invocation of max 2 3 shouldn't 
use a direct call to the function in the same module as the invocation 
is in the same module (i.e. there is opportunity to optimize it based 
on the known invocation types). Secondly, does separate compilation 
make that strong a sense in case of native compilation for OcaML ... 
most probably not because it anyways generates a standalone executable?

P.S. Sorry Damien for the duplicate...
What you see is an illusion... well protected, well cherished only by 

On Dec 1, 2004, at 6:17 PM, Damien Doligez wrote:

> On 30 Nov 2004, at 21:30, Ritesh Kumar wrote:
>> 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.
> You are missing this: because of separate compilation the compiler has 
> no
> way to know whether the function will only be used on integers in your
> program.  When it compiles the function, it doesn't know what it will
> be used for.
> -- Damien
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs