caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nick Grey <nickgrey0112@farrand.net>
To: caml-list@inria.fr
Subject: [Caml-list] Streams.from
Date: Mon, 9 Dec 2002 19:04:48 +0000	[thread overview]
Message-ID: <20021209190448.GB24560@farrand.net> (raw)

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


             reply	other threads:[~2002-12-09 21:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-09 19:04 Nick Grey [this message]
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

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=20021209190448.GB24560@farrand.net \
    --to=nickgrey0112@farrand.net \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).