[swift-evolution] [Proposal] Conventionalizing stride semantics
erica at ericasadun.com
Tue Mar 1 14:29:39 CST 2016
On Mar 1, 2016, at 12:25 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> To clarify, I am not troubled that stride(to:by:) as it is now doesn't
> pick up the sign. The point is that, if renamed to
> stride(towards:by:), the English meaning of "towards" implies that it
> would pick up the sign. It is a critique of the suggested renaming,
> not a critique of the algorithm being renamed.
Summarizing: "Using `towards` suggests that the by value picks up the vector direction and
can be misleading.
2. but no solution is going to be ideal.
3. alternatives: approaching, movingTowards, advancedTowards. Included in the latest
revision of the proposal.
My big issues are "this thing says it goes through and it doesn't, this thing says it goes to and it doesn't".
So long as those are fixed reasonably well, I am happy, even without the naming being perfect.
> I must misunderstand what it is you tweaked. You still write that the
> other proposal doesn't remove the need for manual epsilon adjustment?
In order to separate this into two proposals, I had to make sure they weren't depending on each other.
So this proposal *only* addresses the semantic mismatch I described 4 lines up.
Manual epsilon adjustment is simply a floating point thing, and is discussed at length in the
other proposal (Again, keep refreshing gist.github because both are works in progress.)
>> [first...last] subsumes [from...through]. You might call this a..>b
> I understand that you believe this makes the behavior of "through"
> more sensible. I could even agree. But do we need this third stride
> style, whatever it's called? Essentially, my question is: besides the
> issue of epsilon adjustments, when have you encountered a case in your
> code where you've needed to stride beyond the end point?
First, I renamed it with the two options a...>b, a..>=b and a..=>b to suggest "reach or greater".
Second, yes, and I added a big new section on canonical use cases.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution