From: Michel.Mauny@inria.fr (Michel Mauny)
To: hedden@eniac.seas.upenn.edu (Jerry Hedden)
Cc: caml-list@margaux
Subject: Re: Infinite Streams in Caml Light 0.5
Date: Wed, 28 Oct 92 10:23:43 MET [thread overview]
Message-ID: <9209300722.AA26987@concorde.inria.fr> (raw)
In-Reply-To: <9210271942.AA00591@eniac.seas.upenn.edu>; from "Jerry Hedden" at Oct 27, 92 2:42 pm
> There is a point concerning streams in Caml Light that is not
> dealt with in the manual. This involves the use of function
> calls in stream patterns. Such calls are not evaluated in a lazy
> manner, and can cause the system to crash when a recursive
> function is used on infinite streams. For example, the following
> function is intended to map a function over all the elements of a
> stream:
>
> let rec map_stream func = function
> [< 'x; (map_stream func) strm >] -> [< '(func x); strm >]
> | [< >] -> [< >]
> ;;
>
> However, as indicated above, if `strm' is infinite, evaluation of
> the recursive call progresses ad infinitum until "out of memory"
> occurs.
Yes, you're right: this fact should be clearly noticed in the manual.
However, this behavior of stream matching is not surprising: as
pattern-matching has a strict behavior in lazy languages,
stream-matching is also strict. One has to check completely the
left-hand part before giving control to the right-hand part of
matching rules. But I admit that it is easy to make such a mistake (I
do it quite often).
Michel Mauny
prev parent reply other threads:[~1992-10-28 9:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-10-27 19:42 Jerry Hedden
1992-10-28 9:23 ` Michel Mauny [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9209300722.AA26987@concorde.inria.fr \
--to=michel.mauny@inria.fr \
--cc=caml-list@margaux \
--cc=hedden@eniac.seas.upenn.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox