Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: variables in 'let rec'
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Max Skaller <maxs@i...>
Subject: Re: variables in 'let rec'
Damien Doligez wrote:
> 
> >From: Max Skaller <maxs@in.ot.com.au>
> >
> >Alternatively, you can just use
> >
> >       let rec x' () = ...
> >       and ...
> >       let x = x()
> >
> >in lieu of what you really wanted: (that is,
> >there is a workaround).
> 
> But that doesn't work for "let rec x = 1 :: x", which is the most
> interesting feature of O'Caml's recursive value definitions.

	It doesn't?

	let rec x'() = 1 :: x()'
	let x = x'()

Seems to work fine. Of course, this will loop forever in an eager
language: the result is an infinite list of 1s.

-- 
John (Max) Skaller at OTT [Open Telecommications Ltd]
mailto:maxs@in.ot.com.au      -- at work
mailto:skaller@maxtal.com.au  -- at home