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
[Caml-list] interesting array efficiency observations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-12 (22:57)
From: Christophe TROESTLER <Christophe.Troestler@u...>
Subject: Re: [Caml-list] interesting array efficiency observations
On Mon, 10 May 2004, briand@aracnet.com wrote:
>    let f a x y = 1 + a.{x,y}
> has a polymorphic type (int, 'a, 'b) Bigarray.Array2.t -> int -> int -> int
> and compiles down to a library function call.
> let the_a = Bigarray.Array2.create Bigarray.float64 Bigarray.c_layout 5 5;;
>   f the_a 1 2
> Why would the_a be treated polymorphically ??

The function [f] _could_ be specialized when applied to a monomorphic
type.  However, when do you do that: when you define the function (but
then you end up compiling [f] for all combinations of 'a and 'b...) or
when the function is applied (a kind of function inlining)?

The first solution is not that nice (unnecessary increase of code
size) but I have a question for the second:

    Is it possible that [f] be inlined and then specialized or the
    compiler does not do that?  This question also holds for,
    e.g. [min (f x) (g x)], may [min] be inlined and then specialized
    if it is known for example that [f x] and [g x] are [int]?


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners