caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] compiler storage choice optimization?
@ 2001-06-02  1:49 Charles Martin
  0 siblings, 0 replies; only message in thread
From: Charles Martin @ 2001-06-02  1:49 UTC (permalink / raw)
  To: caml-list

Here's a simple version of the code that sparks my question:

type t = { mutable value : float }
let double x = { value = x.value *. x.value }
let double_in_place x =
  let x' = double x in
  x.value <- x'.value

When I ocamlopt this code, double_in_place inlines the call to double,
but nevertheless x' gets allocated in the heap.  I was hoping that the
compiler might choose stack allocation instead.

The motivation is to be able to write side-effecting in-place
operations primarily in terms of side-effect-free functions.

Although collecting the youngest generation is very fast, stack
allocation should still be faster, and in numerically intense code
having this kind of storage optimization might allow me to have my
functional cake and eat it quickly, too.

So I guess my question is, is this kind of optimization in the cards?

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-06-02  1:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-02  1:49 [Caml-list] compiler storage choice optimization? Charles Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).