[swift-evolution] Feature proposal: Range operator with step
Dave Abrahams
dabrahams at apple.com
Mon Mar 28 18:58:45 CDT 2016
on Mon Mar 28 2016, Erica Sadun <erica-AT-ericasadun.com> wrote:
>> On Mar 28, 2016, at 3:54 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>
>>
>> on Mon Mar 28 2016, Erica Sadun <swift-evolution at swift.org> wrote:
>>
>
>>>> On Mar 28, 2016, at 3:25 PM, Dave Abrahams via swift-evolution
>>>> <swift-evolution at swift.org> wrote:
>>>>
>>>>
>>>> on Mon Mar 28 2016, Xiaodi Wu
>>>
>>>> <swift-evolution at swift.org
>>>> <mailto:swift-evolution at swift.org>>
>>>> wrote:
>>>>
>>>>> Right, Countable could refine Strideable. I'm no expert on this, but
>>>>> some cursory reading suggests that the analogous feature in C++ simply
>>>>> requires the type to have operator++ defined. Obviously, that won't
>>>>> work for Swift 3.0...
>>>>
>>>> Hmm, instead of defining a new protocol (Countable), what if we just use
>>>> “Strideable where Stride : Integer” as a constraint?
>>>
>>> I like a differentiation between continuous and discrete things
>>> although both can have ranges, membership, fences,
>>> and a way to stride through them
>>
>> Strideable where Stride : Integer expresses just exactly that. Now if I
>> could only get the type-checker to cooperate...
>
> I am ridiculously excited about what you're doing there.
:-)
> Looking forward to beautiful floating point strides if for no
> other reason than I can point out how well they work for math
> in comparison to traditional for;;loops,
How would you like to implement the FP part of this?
> so maybe people will stop burning semicolons on my lawn.
Naw, showing them a better way'll just get 'em more riled up.
> What are you feelings about disjoint and invertible intervals?
I don't know what these things are supposed to be, so it's hard to say.
> (I'll admit they currently fail the Lattner test[1],
Presumably this isn't a language change, though.
> but they appeal to my aesthetics)
>
> -- E
>
> [1] First rule of Lattner: A language change should provide a highly focused
> tweak to Swift with limited impact and a measurable benefit to developers
--
Dave
More information about the swift-evolution
mailing list