Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix offered for "illegal stream concatenation" in Stream #3492

Closed
vicuna opened this issue Jul 31, 2002 · 1 comment
Closed

Fix offered for "illegal stream concatenation" in Stream #3492

vicuna opened this issue Jul 31, 2002 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 31, 2002

Original bug ID: 1284
Reporter: administrator
Status: closed (set by @damiendoligez on 2012-01-25T14:50:20Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.11.0
Category: ~DO NOT USE (was: OCaml general)
Related to: #5644
Parent of: #3497

Bug description

The documentation in Stream.mli says:

Warning: these functions create streams with fast access; it is illegal
to mix them with streams built with [[< >]]; would raise [Failure]
when accessing such mixed streams.

As an example of this, the following code fails:

open Stream;;
npeek 20 (iapp (of_string "as") (icons 'z' (of_list ['d'; 'f'])));;

(This is an artificial example. The actual example that motivated me
has since been replaced by a workaround, so I don't have it
conveniently available.)

The resolution of bug 235 at

http://caml.inria.fr/bin/caml-bugs/not%20a%20bug?id=235;user=guest;selectid=235

reaffirms that this behavior is considered acceptable, but it doesn't make
sense to regard throwing an exception as better than computing a useful result.
I found it frustrating that the compiler wouldn't help me predict when a stream
operation would fail with the "illegal stream concatenation" error, so I
rewrote stream.ml so all streams are valid inputs to all stream operations that
take streams as arguments.

I plugged it into the ocaml source from anonymous CVS and the compiler
was able to bootstrap fine. It also passes a fairly thorough unit
test that's in the comments at the end, and it has reasonable
performance according to the benchmark at the end of the test cases.

Is there any interest in incorporating this changed code into OCAML?

The revised .ml file is at

http://www.fungible.com/stream_fixed.ml

and the .mli file (which is identical to the old version, except for a few
comments) is at

http://www.fungible.com/stream_fixed.mli

As indicated by the header at the beginning of stream_fixed.ml, I'm happy to
assign copyright on the rewritten file to INRIA if it gets incorporated into
OCAML.

--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78

@vicuna
Copy link
Author

vicuna commented Jan 25, 2012

Comment author: @damiendoligez

This restriction was removed in 3.11.0 and the example now works (tested in 3.12.1). I am updating the documentation (stream.mli) by removing the paragraph in question.

Problem fixed in 3.11.0 (commit 8893), documentation fixed in trunk (3.13.0) (commit 12077).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant