* let rec x = lazy x
@ 2006-01-11 9:50 Alessandro Baretta
2006-01-11 9:55 ` [Caml-list] " Mackenzie Straight
0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Baretta @ 2006-01-11 9:50 UTC (permalink / raw)
To: Ocaml
Strange as it may seem, it seems to work! With -rectypes enabled of course.
Obviously, forcing x does not produce anything sensible, but it does produce
something. Am I justified in believing that the result is a long chain of
lazy-blocks, the last one containing a Stack_overflow exception?
Alex
--
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL
tel. +39 02 370 111 55
fax. +39 02 370 111 54
Our technology:
The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>
The FreerP Project
<http://www.freerp.org/>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] let rec x = lazy x
2006-01-11 9:50 let rec x = lazy x Alessandro Baretta
@ 2006-01-11 9:55 ` Mackenzie Straight
2006-01-11 10:04 ` Alessandro Baretta
0 siblings, 1 reply; 4+ messages in thread
From: Mackenzie Straight @ 2006-01-11 9:55 UTC (permalink / raw)
To: Alessandro Baretta; +Cc: Ocaml
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.
>
> Obviously, forcing x does not produce anything sensible, but it does produce
> something. Am I justified in believing that the result is a long chain of
> lazy-blocks, the last one containing a Stack_overflow exception?
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html
You don't want to do this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] let rec x = lazy x
2006-01-11 9:55 ` [Caml-list] " Mackenzie Straight
@ 2006-01-11 10:04 ` Alessandro Baretta
2006-01-11 10:20 ` Mackenzie Straight
0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Baretta @ 2006-01-11 10:04 UTC (permalink / raw)
To: Mackenzie Straight; +Cc: Ocaml
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 ;)
Alex
--
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL
tel. +39 02 370 111 55
fax. +39 02 370 111 54
Our technology:
The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>
The FreerP Project
<http://www.freerp.org/>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] let rec x = lazy x
2006-01-11 10:04 ` Alessandro Baretta
@ 2006-01-11 10:20 ` Mackenzie Straight
0 siblings, 0 replies; 4+ messages in thread
From: Mackenzie Straight @ 2006-01-11 10:20 UTC (permalink / raw)
To: Alessandro Baretta; +Cc: Ocaml
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-01-11 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-11 9:50 let rec x = lazy x Alessandro Baretta
2006-01-11 9:55 ` [Caml-list] " Mackenzie Straight
2006-01-11 10:04 ` Alessandro Baretta
2006-01-11 10:20 ` Mackenzie Straight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox