Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Krishnaswami, Neel" <neelk@cswcasa.com>
To: "'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: [Caml-list] Are multiple return values optimized?
Date: Wed, 18 Jul 2001 20:07:01 -0400	[thread overview]
Message-ID: <200107190007.UAA20121@zcars0mt.> (raw)

Hello,

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
OCaml

  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
neelk@cswcasa.com
-------------------
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

-------------------
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


             reply	other threads:[~2001-07-19  0:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-19  0:07 Krishnaswami, Neel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-07-16 20:33 Krishnaswami, Neel
2001-07-20 15:37 ` Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200107190007.UAA20121@zcars0mt. \
    --to=neelk@cswcasa.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox