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

Xiaodi Wu xiaodi.wu at gmail.com
Wed Apr 6 16:01:17 CDT 2016


On Wed, Apr 6, 2016 at 3:28 PM, Dave Abrahams via swift-evolution
<swift-evolution at swift.org> wrote:
> You if you need to represent `<..` intervals in scientific computing,
> that's a pretty compelling argument for supporting them.
>
>> I'd like to be able to represent any of those as
>> Intervals-which-are-now-Ranges. It makes sense to do so because the
>> things I want to do with them, such as clamping and testing if some
>> value is contained, are exactly what Intervals-now-Ranges provide.
>> Looking around, it seems many other languages provide only what Swift
>> currently does, but Perl does provide `..`, `..^`, `^..`, and `^..^`
>> (which, brought over to Swift, would be `...`, `..<`, `<..`, and
>> `<.<`).
>
> Do we need fully-open ranges too?

I haven't encountered a need for open ranges, but I would expect that
other applications in scientific computing could make use of them.
I rather like Pyry's suggestions below. These would represent an
expansive fleshing out of ranges. They really start pulling their
weight for floating point bounds; of course, I'd wager that ... and
..< would still be the most used by far.


More information about the swift-evolution mailing list