From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA20674; Wed, 31 Jul 2002 17:05:42 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA20405; Wed, 31 Jul 2002 17:05:41 +0200 (MET DST) Received: from lobus.fungible.com (adsl-64-161-114-6.dsl.snfc21.pacbell.net [64.161.114.6]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6VF5dv02754; Wed, 31 Jul 2002 17:05:40 +0200 (MET DST) Received: by lobus.fungible.com (Postfix, from userid 1000) id C84797F66; Wed, 31 Jul 2002 08:05:36 -0700 (PDT) Date: Wed, 31 Jul 2002 07:22:07 -0700 From-Tims-Fingers: true To: caml-list@inria.fr, caml-bugs@inria.fr Subject: [Caml-list] Fix offered for "illegal stream concatenation" in Stream Message-Id: <20020731150536.C84797F66@lobus.fungible.com> From: tim@fungible.com (Tim Freeman) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 ------------------- 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