<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">On 4 Feb 2016, at 01:08, David Turnbull &lt;<a href="mailto:dturnbull@gmail.com">dturnbull@gmail.com</a>&gt; wrote:<br><br></span></font></div><blockquote type="cite"><div dir="ltr"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">Here's how you could use a collection as a predicate. The&nbsp;OnSwitchesIndex&nbsp;is opaque to anything outside the file. There's no way to iterate&nbsp;OnSwitches&nbsp;with &nbsp;0 ..&lt;count. Thinking that arrays and sequences are counting up from 0 by 1 is missing the entire point of these protocols.</span></font></div></blockquote></div><div><br></div><div>No matter the index, since .count represents the number of elements in the collection, it should never be negative.</div><div><br></div><div>An EveryOtherElementOfReverseOfArray implementation could have a startIndex of 4 and endIndex of 0, and wouldn't be iterable with a simple range, yet I'd still expect the count to be positive. Types without integer indexes are no exception.</div><div><br></div><div><br></div><div>For cases such as CGSize: from memory, I have no idea how CGSize would handle negatives. Would it ignore the sign, crash on creation, or simply allow them?</div><div><br></div><div><br></div><div>According to the CGGeometry reference:</div><div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">A&nbsp;<code class="code-voice" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">CGSize</code>&nbsp;structure is sometimes used to represent a distance vector, rather than a physical size. As a vector, its values can be negative. To normalize a&nbsp;<code class="code-voice" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;"><a href="https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/tdef/CGRect" data-renderer-version="2" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">CGRect</a></code>&nbsp;structure so that its size is represented by positive values, call the&nbsp;<code class="code-voice" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;"><a href="https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectStandardize" data-renderer-version="2" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; text-decoration: none;">CGRectStandardize</a></code>&nbsp;function.</span></div><div><br></div><div><br></div><div>CGSize represents vectors <i>and</i> sizes? And an explicit â€˜normalisation’ (a non-negative safety check) must be performed to work with CGSize as a size? This sounds awfully like a lack of type safety.</div><div><br></div><div>So based on CGSize's use as a vector, it would have to remain unchanged. Using naturals elsewhere in the frameworks would serve to make it much more obvious negative checks should be performed working with this and similar types. This example just serves to emphasise how important making this distinction is.</div><div><br><div>From James F</div></div></body></html>