English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2007-10-04 (21:36)
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