[swift-evolution] [Proposal] More lenient subscript methods over Collections
Luis Henrique B. Sousa
lshsousa at gmail.com
Fri May 13 09:20:01 CDT 2016
Alright, so as you are also okay with `clamping` I will update the proposal
with it. :-)
- Luis
On Fri, May 13, 2016 at 3:00 PM, Vladimir.S <svabox at gmail.com> wrote:
> Personally I don't feel like `flat` is better. Especially if there is
> `clamping` in Range for the same purpose. Then we should not re-invent the
> wheel.
>
> On 13.05.2016 16:09, Luis Henrique B. Sousa wrote:
>
>> Perhaps another word that could fit in the first case
>> (truncate/bounded/within/clamping) is `flat`. Along the same lines of the
>> `flatMap` which returns only non-nil values, here we have an empty array
>> instead of nil when the range doesn't apply at all.
>>
>> let array = [1,2,3]
>>
>> array[flat: 0..<10] // [1,2,3]
>> array[checking: 0..<10] // nil
>>
>> I'm still not sure if `clamping` is the right word. What do you think?
>>
>> - Luis
>>
>> On Thu, May 12, 2016 at 7:25 AM, Brent Royal-Gordon <
>> brent at architechies.com
>> <mailto:brent at architechies.com>> wrote:
>>
>> > It sounds good, thanks for you suggestions @Vladimir, @Patrick and
>> @Brent.
>> >
>> > I've just updated the proposal:
>> >
>> https://github.com/luish/swift-evolution/blob/more-lenient-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md#detailed-design
>> >
>> > - Luis
>>
>> Hmm. If you're going with `checking` for one of them, perhaps the
>> other
>> should be `clamping` (for the analogous method on `Range`, which you
>> might want to use in the implementation of that subscript). That would
>> create a nicely matched pair:
>>
>> array[checking: 0..<10]
>> array[clamping: 0..<10]
>>
>> --
>> Brent Royal-Gordon
>> Architechies
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160513/63db5b36/attachment.html>
More information about the swift-evolution
mailing list