caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Streams.from
@ 2002-12-09 19:04 Nick Grey
  2002-12-09 22:14 ` Jean-Christophe Filliatre
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Grey @ 2002-12-09 19:04 UTC (permalink / raw)
  To: caml-list

Hi,

When a stream is created using Stream.from, is the function f garunteed
to be called with the stream count parameter 0, 1, 2, ...

I would say that it is, but the current documentation doesn't seem to
discount the possibility that the function would say, be called twice
with the same parameter, or with parameters out of sequence.  (I can
think of no reason why this would actually happen, I'm just saying the
docs don't discount it.)

The reason that I ask is because it is sometimes useful to pass to from
a function which simply returns the next value in the stream, without
referring to the stream count.  (E.g. because the value can't actually
be computed from the stream count, but comes from some internal state.)
In this case, if the function were to be called repeatedly with the same
parameter, or with the parameters out of sequence, bad things would
happen.

I know this is a bit (very? :-) ) pedantic, I'm just slightly uneasy writing code
that makes an assumption about the way a module works.  (After all, the
point of modular programming is that one should not make assumptions
other than those given in the interface/docs.)

Possibly remedies would be to tighten up the documentation of
Stream.from, or to add another version of from which doesn't take the
stream count as a parameter.

Suggestion for change in documentation:

Add at end:
f is called exactly once for each stream element created, and a stream
element is never created until all preceding elements have been created.

Regards,
N
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-12-10 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-09 19:04 [Caml-list] Streams.from Nick Grey
2002-12-09 22:14 ` Jean-Christophe Filliatre
2002-12-09 23:54   ` Remi VANICAT
2002-12-10  0:00   ` Nick Grey
2002-12-10 12:29   ` Daniel de Rauglaudre

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).