From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_SECURITYSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 52E3CBB84 for ; Mon, 10 Nov 2008 18:12:31 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArICAPP5F0nVBJXyaGdsb2JhbACBdpIuDQgNBxAEtlCDWA X-IronPort-AV: E=Sophos;i="4.33,576,1220220000"; d="scan'208";a="17072801" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Nov 2008 18:12:31 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id mAAHCUUk030857 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 10 Nov 2008 18:12:31 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArICAPP5F0nVBJXyaGdsb2JhbACBdpIuDQgNBxAEtlCDWA X-IronPort-AV: E=Sophos;i="4.33,576,1220220000"; d="scan'208";a="17072800" Received: from outmailhost.telefonica.net (HELO ctsmtpout2.frontal.correo) ([213.4.149.242]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Nov 2008 18:12:30 +0100 Received: from NANA.localdomain (88.0.114.92) by ctsmtpout2.frontal.correo (7.2.056.6) (authenticated as ferferse$telefonica.net) id 491026DA000CC8BD for caml-list@inria.fr; Mon, 10 Nov 2008 18:12:30 +0100 Received: from mfp by NANA.localdomain with local (Exim 4.69) (envelope-from ) id 1KzaJR-00065r-7h for caml-list@inria.fr; Mon, 10 Nov 2008 18:12:29 +0100 Date: Mon, 10 Nov 2008 18:12:29 +0100 From: Mauricio Fernandez To: caml-list@inria.fr Subject: Re: [Caml-list] Implementation of lazy_t Message-ID: <20081110171229.GC803@NANA.localdomain> Mail-Followup-To: caml-list@inria.fr References: <491861D3.8020709@tu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <491861D3.8020709@tu-berlin.de> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Miltered: at discorde with ID 49186B7E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0100,:01 datatype:01 constructors:01 ocaml:01 compiler:01 datatypes:01 implements:01 implements:01 inserting:01 lambda:01 stdlib:01 10,:98 wrote:01 caml-list:01 constructor:01 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