caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Resources on OCaml's sharing
@ 2010-03-10  9:45 Matthias Puech
  2010-03-10 17:36 ` [Caml-list] " Peter Hawkins
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Puech @ 2010-03-10  9:45 UTC (permalink / raw)
  To: caml-list

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'

>>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-10 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-10  9:45 Resources on OCaml's sharing Matthias Puech
2010-03-10 17:36 ` [Caml-list] " Peter Hawkins

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