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] Are multiple return values optimized?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-07-16 (20:30)
From: Krishnaswami, Neel <neelk@c...>
Subject: [Caml-list] Are multiple return values optimized?

Are multiple return values optimized to avoid heap-allocation 
like curried functions are? In Scheme and Lisp, I'm used to an 
expression like

  (define foo
    (lambda () (values 1 2 3)))

  (call-with-values foo
     (lambda (x y z) (+ x y z))

evaluating without doing any heap-allocation. Will the analgous

  let foo() = (1, 2, 3)
  let x, y, z = foo()
  in x + y + z

also pass values on the stack or will a tuple be heap-allocated?
Simple experiments with ocamlopt -S suggest the latter, but it's
possible that there are optimized cases that I don't know how 
to write. 

Neel Krishnaswami
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr