Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
let rec x = lazy x
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mackenzie Straight <eizneckam@g...>
Subject: Re: [Caml-list] let rec x = lazy x
Apologies for the duplicate, I forgot to send this to the list.

On 1/11/06, Alessandro Baretta <> wrote:
> Mackenzie Straight wrote:
> > On 1/11/06, Alessandro Baretta <> wrote:
> >
> >>Strange as it may seem, it seems to work! With -rectypes enabled of course.
> >
> >
> >
> > You don't want to do this.
> I did it specifically because it is forbidden ;)

Oh well in that case... a lazy value is a block with 1 field. Before
the computation is forced, it's tagged Lazy_tag and contains a pointer
to the closure to execute. Once forced, it becomes a forwarding
pointer (Forward_tag) to the forced value. Thus, you would get a
forwarding pointer which points to itself. The GC may then replace
references to the forwarding pointer with its value.

So, what you've got with let rec x = lazy x is a forwarding pointer
that points to itself.