Version française
Home     About     Download     Resources     Contact us    
Browse thread
Implementation of lazy_t
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mauricio Fernandez <mfp@a...>
Subject: Re: [Caml-list] Implementation of lazy_t
On Mon, Nov 10, 2008 at 05:31:15PM +0100, Florian Lorenzen wrote:
> Hello,
> 
> I would like to know how lazy datatype constructors are implemented in
> OCaml. A look into the documentation of the Lazy module revealed that
> the compiler uses a built-in type constructor lazy_t for this
> purpose. Unfortunately, I could not find any information on lazy_t on
> the web. My question is how lazy datatypes are handled internally
> (without having to read the compiler's source code). Especially, if
> lazy_t implements call-by-need in the sense that once evaluated
> objects are not evaluated again (by means of sharing) or if it
> implements call-by-name like one can do by inserting 0-ary lambda
> abstractions in the constructor to suspend evaluation and applying
> them to force evaluation?
> 
> Is there any documentation on the internals available or can someone
> shine some light on this?

See stdlib/camlinternalLazy.ml --- force takes but 6 lines of code.

-- 
Mauricio Fernandez  -   http://eigenclass.org