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
optimization of sequence of and inlining
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-06-10 (19:01)
From: Charles Hymans <charles.hymans@g...>
Subject: optimization of sequence of and inlining
Let's say, I have the following code:

  let f l = succ l


  let l = f l in
  let l = succ l in
    do_something_with l

Is there a way to tell the compiler to optimize it so that it runs as fast
as this code:
  let l = (fun x -> succ (succ x)) l in
In the first case, there are two passes where succ is applied to each
elements of the list.
In the second case, there is only one pass that applies succ twice to each
element of the list.

Thank you,