Re: [Ocaml-reins-devel] possible bugs in iterators
Status: Beta
Brought to you by:
mfurr
From: Michael F. <fu...@cs...> - 2007-11-07 02:08:47
|
On Mon, 5 Nov 2007, Ashish Agarwal wrote: > Hi. Please consider following code: [snip] > which prints out > 1 2 3 4 Oops! > What is the semantics of Traverse_While? I was expecting the iterator to > stop at 3. Indeed, this is the intended semantics. > The iterator seems to go one element extra. Trying with m = 0 prints the > value 1 even though the predicate given to Traverse_While is never > satisfied. > > Also, leave m = 3, and remove 2 from the list. Then we get Exception: > Failure "get_value". > Alternatively, leave the list as shown above and set m = 7. I was expecting > same error again, but there is no Failure this time. Hmm... sorry about that. I must admit I haven't actually tested the While iterator as much as I should. I wasn't sure if I liked the way the cursor interface was setup, so I've actually been planning on revisiting this entire part of the library. I'm currently insanely busy working on a paper, but I'll look at this next week when I should (finally) have some time to get back to hacking on reins. Thanks for your email. -m P.S. If you have any suggestions about how to improve the way the iterators or cursors are presented, I would love to hear them. I have only 1 or 2 usage scenerios in my head and I'm not sure how other people might like to use these. |