Browse thread
Why + vs +. but "fake" parametric polymorphism for <
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Carlos Pita <cpitadev@y...> |
| Subject: | Re: [Caml-list] Why + vs +. but "fake" parametric polymorphism for < |
> Well, to reiterate Jacques warning, annotating the arguments and then > calling a function which is polymorphic won't magically cause the > polymorphic function to use the non-polymorphic comparisons. > let max a b = if a > b then a else b in print_int (max 2 3);; Ok, I understand. By inspection of code generated for the snippet above one sees that albeit the max function is in fact inlined the compiler won't optimize the comparison for ints. What is to be concluded here, if any? Is the moral of the story that when inlining the compiler won't try further optimizations beyond almost verbatim copy of code for the inlined fragment, which was once and for all generated in isolation without attending to specific contexts of use? So, if this is the case, following the tutorial and your remarks the best bet is to specify types for the arguments when defining a function so the compiler get the chance to optimize it locally. Cheers, Carlos. __________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas