digitalmars.D.bugs - doc errors in std.range
- Steven Schveighoffer (32/32) May 22 2009 Just getting more familiar with ranges in D2, I saw the following errors...
Just getting more familiar with ranges in D2, I saw the following errors in the docs: isInfinite: Specifies that the range must have a static member that equals false, but it really should say that the range must have a static member *named empty* that equals false. advance: mislabel, "The pass of r into *drop* is by reference", should be advance, not drop. retreatN: similar issue as advance, example also has mislabel. SListRange: popFront,front: last sentence either reference a hidden member "input" or is a copy-paste error. ===== Couple comments I thought of, could have made another post, but... 1. advance is O(n) if slicing is not offered. However, an infinite range doesn't, and shouldn't, offer slicing. But it might be able to advance n elements in constant time if each element is well defined without a recurrence. You may want to implement some sort of skip function, which advance uses if slicing isn't available, and it can be supported. For example, an infinite range of 1 to infinity could be easily skipped n elements. However, you don't want to offer a slice function, because the result might or might not be an infinite range (depending on if the second argument to the slice is $). A stream may need a similar function. For example, skipping n bytes could be a quick operation. skip should only be defined if it can be done faster than repeatedly calling popFront. 2. Transversal, I would think, should continue to iterate over the elements that are left (if so desired). That is, given two ranges such as: [1,2,3] [4,5,6] I would think a useful range over this would result in: [1,4,2,5,3,6] -Steve
May 22 2009