Browse thread
let rec x = lazy x
-
Alessandro Baretta
-
Mackenzie Straight
-
Alessandro Baretta
- Mackenzie Straight
-
Alessandro Baretta
-
Mackenzie Straight
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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 <a.baretta@barettadeit.com> wrote: > Mackenzie Straight wrote: > > On 1/11/06, Alessandro Baretta <a.baretta@barettadeit.com> wrote: > > > >>Strange as it may seem, it seems to work! With -rectypes enabled of course. > > > > http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html > > > > 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.