[swift-evolution] Feature proposal: Range operator with step

Haravikk swift-evolution at haravikk.me
Thu Mar 24 06:41:49 CDT 2016


> On 24 Mar 2016, at 08:54, David Knothe <dknothe314 at me.com> wrote:
> 
> I do not think an operator like ..+ is intuitive nor will it make code easier to read or write.

While I agree that ..+ isn’t the nicest operator choice, there may be other possibilities. It would be interesting if we could use regular letters as operators, as you could actually just declare your by or step keyword yourself in that way, but it could be specific to strideable ranges, though it may not be worth the chaos of everyone then declaring custom keywords everywhere.

Personally I don’t see the issue of requiring parenthesis to use (1 ..< 10).by(2), ultimately we’re still just iterating over a sequence, all we want is control over how a range’s sequence is generated, rather than it just using a stride of 1. A keyword is certainly prettier, but I think it’s better that developers know that there’s nothing new going on here, and that it’s still just a regular sequence like any other, rather than introducing a new structure that looks sort of like a new form of loop, but really isn’t.


More information about the swift-evolution mailing list