English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2008-11-10 (17:12)
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