From: Jon Harrop <jonathandeanharrop@googlemail.com>
To: "'Alain Frisch'" <alain.frisch@lexifi.com>,
"'Nicolas Ojeda Bar'" <nojb@math.harvard.edu>
Cc: <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] reference cells
Date: Wed, 2 Feb 2011 19:38:48 -0000 [thread overview]
Message-ID: <015301cbc310$d1405b60$73c11220$@com> (raw)
In-Reply-To: <4D46FB9E.5040805@lexifi.com>
Don't you add the redundant 1.0 *. x at the end of numerical functions to
trick ocamlopt into unboxing because the mutable variable used only
internally in the function's body is heap allocated otherwise?
Cheers,
Jon.
> -----Original Message-----
> From: Alain Frisch [mailto:alain.frisch@lexifi.com]
> Sent: 31 January 2011 18:13
> To: Nicolas Ojeda Bar
> Cc: caml-list@yquem.inria.fr
> Subject: Re: [Caml-list] reference cells
>
> On 01/31/2011 05:29 PM, Nicolas Ojeda Bar wrote:
> > I am translating an imperative language into Ocaml. Right now I am
> > translating mutable variables into ref cells. Will they be optimized
> > when I compile the corresponding Ocaml program? Or will they be heap
> > allocated? If this is the case, I will have to translate my language
> > into some sort of SSA form before, and I would like to avoid that.
>
> Mutable variables which are used only internally in a function's body
> are not heap allocated.
>
> If you write:
>
> let r = ref e0 in e1
>
> and r only appears in e1 under the form:
>
> r := ...
> !r
>
> and not under a local abstraction, then the reference is kept in a
> local
> variable.
>
> You can use the -dlambda switch to the compilers and toplevel to see
> that.
>
>
> -- Alain
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
prev parent reply other threads:[~2011-02-02 19:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 16:29 Nicolas Ojeda Bar
2011-01-31 16:36 ` Michael Ekstrand
2011-01-31 16:46 ` Guillaume Yziquel
2011-02-04 11:49 ` David Baelde
2011-02-04 12:30 ` Guillaume Yziquel
2011-01-31 18:12 ` Alain Frisch
2011-02-02 19:38 ` Jon Harrop [this message]
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='015301cbc310$d1405b60$73c11220$@com' \
--to=jonathandeanharrop@googlemail.com \
--cc=alain.frisch@lexifi.com \
--cc=caml-list@yquem.inria.fr \
--cc=nojb@math.harvard.edu \
/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