caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matthias Puech <puech@cs.unibo.it>
To: caml-list@inria.fr
Subject: Resources on OCaml's sharing
Date: Wed, 10 Mar 2010 10:45:40 +0100	[thread overview]
Message-ID: <4B976A44.9040807@cs.unibo.it> (raw)

Dear Camlists,

Does anyone know of a description of the sharing mechanism inside
Ocaml's heap (I guess)? I'm interested in any kind material, from a
formal account in a paper (even not directly related to Caml), to an
informal description and tips of usage, anything that could fill in my
shameful ignorance on that matter. Particularly, I'm trying to understand:
- where architecturally it takes place in the compiler,
- how it is an approximation from the perfect case of maximal sharing
(hash-consing I guess), i.e. what's the algorithm
- when can I safely state that a = b implies a == b.
- how is it that the function below is "smarter" than List.map? What do
we gain, what do we loose?

I understand sharing is part of ML's folklore and I didn't find any
resource on it, but maybe I missed something...

Thank you all in advance,
	-m

<<

let rec list_smartmap f l = match l with
    [] -> l
  | h::tl ->
      let h' = f h and tl' = list_smartmap f tl in
	if h'==h && tl'==tl then l
	else h'::tl'

>>


             reply	other threads:[~2010-03-10  9:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10  9:45 Matthias Puech [this message]
2010-03-10 17:36 ` [Caml-list] " Peter Hawkins

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=4B976A44.9040807@cs.unibo.it \
    --to=puech@cs.unibo.it \
    --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;
as well as URLs for NNTP newsgroup(s).