Version française
Home     About     Download     Resources     Contact us    
Browse thread
Streams and call-by-need
[ 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] Streams and call-by-need
On 5/26/06, Christoph Bauer <christoph.bauer@lms-gmbh.de> wrote:
> Hi,
>
> do streams support call-by-need? This looks like call-by-name:
>
> #  let s = [< '(print_endline "a"); '(print_endline "b") >]
>   ;;
> val s : unit Stream.t = <abstr>
> # let t = [< s; s >]
>   ;;
> val t : unit Stream.t = <abstr>
> # Stream.next t;;
> a
> - : unit = ()
> # Stream.next t;;
> b
> - : unit = ()
> # Stream.next t;;
> a
> - : unit = ()
> # Stream.next t;;
> b
> - : unit = ()
>

Since your stream elements make function calls they are boxed in
functions taking unit.
Thus calls are delayed, but that's not real lazy values, the function
call is always done.

-- 
Nicolas Pouillard