Version française
Home     About     Download     Resources     Contact us    
Browse thread
How important are circular lists/recursive objects?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: rossberg@p...
Subject: Re: [Caml-list] Re: How important are circular lists/recursive objects?
skaller <skaller@users.sourceforge.net> wrote:
>
> Other than use of a function closure
> to create a box, let/in bindings cannot create cycles because
> non-functional values have to be constructed from existing
> already initialised values.
>
> So apart from functional closures, FPLs can't have cycles

That's solely a question of the semantics of their fixpoint operator.
Ocaml certainly supports "let rec xs = 1::xs". And just for perspecive,
the following is the canonical definition of the (infinite) list of
Fibonacci numbers in Haskell:

  fibs = 1:1:zipWith (+) fibs (tail fibs)


> Note that stuff like:
>
> 	let rec x= (1,x)
>
> is not generally allowed: in functional terms it is ill-defined,

It is disallowed in OCaml because it has a cyclic type, not because it is
a cyclic value. Try with "ocaml -rectypes".

- Andreas