caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Streams and call-by-need
@ 2006-05-26 14:52 Christoph Bauer
  2006-05-26 15:17 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Bauer @ 2006-05-26 14:52 UTC (permalink / raw)
  To: caml-list

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 = ()

Christoph Bauer


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Streams and call-by-need
  2006-05-26 14:52 Streams and call-by-need Christoph Bauer
@ 2006-05-26 15:17 ` Nicolas Pouillard
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Pouillard @ 2006-05-26 15:17 UTC (permalink / raw)
  To: Christoph Bauer; +Cc: caml-list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-26 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-26 14:52 Streams and call-by-need Christoph Bauer
2006-05-26 15:17 ` [Caml-list] " Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).