[swift-evolution] Removing enumerated?
erica at ericasadun.com
Fri Feb 3 13:12:22 CST 2017
> On Feb 3, 2017, at 10:57 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> on Thu Feb 02 2017, Chris Lattner <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> On Jan 31, 2017, at 11:16 AM, Ben Cohen via swift-evolution <swift-evolution at swift.org> wrote:
>>> As we expand (and maybe contract :) the standard library, this kind
>>> of question comes up a lot, so it is worth setting out some criteria
>>> for judging these “helper” methods. Here’s my take on such a list
>>> (warning: objectivity and subjectivity blended together in the
>> This is great perspective Ben, thank you for taking time to write this up!
>> It seems that you are leaning towards removing enumerated(). What do
>> you think about the proposal of removing enumerated but adding
>> indexed() to replace it? It would provide the same behavior for
>> common array cases, while providing more useful/defensible
>> functionality for other collections.
> indexed() is trivially composed from other library primitives:
> zip(c.indices, c)
> enumerated() only exists in the standard library, and was explicitly
> designed as it was, because what it does is not currently easy to
> write. As soon as we enable "0...", that changes.
> I'm not against having trivial helper functions in principle, but I
> don't think the Standard Library or the language is yet at the stage of
> maturity where we can see clearly which ones are important enough, and
> pay for the API surface area they add. For that reason I feel strongly
> that for the time being we should remain very conservative about adding
> such things, and only introduce them where there's real compelling
> evidence that they are a win. There is no such evidence for indexed()
> as far as I can tell.
I believe what people *want* is `indexed` over `enumerated`, and consistently for both array and array slices.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution