Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
Unexpected restriction in "let rec" expressions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions
Excerpts from loup.vaillant's message of Tue Feb 26 15:34:37 +0100 2008:
> 2008/2/26, Damien Doligez <damien.doligez@inria.fr>:
> > The restriction is documented in section 7.3 of the reference manual,
> >  and it's here to make recursive definitions work correctly under
> >  eager evaluation.
> 
> OK, I got it. By the way, replacing "couple" by "couple ()" does the trick:
> 
> # let loop f a =
>     let rec couple () = f (a, snd (couple ())) in
>       fst (couple ());;
>     val loop : ('a * 'b -> 'c * 'b) -> 'a -> 'c = <fun>
> 
> Now, I have yet to figure out the purpose of this so called "fixpoint
> operator" (and if the above will work at all :-).

A picture can helps...

     +---------+
  a>-|         |->c
     |    x    |
  b>-|         |->b
     +---------+

     +---------+
  a>-|         |->c
     |    y    |
 +->-|         |->-+
 |   +---------+   |
 +--------b--------+

loop x = y

Regards,

-- 
Nicolas Pouillard aka Ertai