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
[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, 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 Archives:
Bug reports: FAQ:
Beginner's list: