[swift-evolution] Feature proposal: Range operator with step
dknothe314 at me.com
Thu Mar 24 09:24:49 CDT 2016
Well I would love to be able to create and use my own keywords / alphanumeric operators.
Depending on the type of code you are writing, these may be more or less helpful. The same is true for the 'step' keyword - maybe most people won't ever use it - but I think there should certainly be a possiblity, be it a concrete keyword built into the language or the possibility to create my own ones.
> Am 24.03.2016 um 12:41 schrieb Haravikk <swift-evolution at haravikk.me>:
>> 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