[swift-evolution] [Accepted with modifications] SE-0045: Add scan, prefix(while:), drop(while:), and unfold to the stdlib
Kevin Ballard
kevin at sb.org
Fri May 6 13:41:01 CDT 2016
On Thu, May 5, 2016, at 01:39 PM, Chris Lattner via swift-evolution wrote:
>
>> On May 5, 2016, at 1:03 PM, Erica Sadun <erica at ericasadun.com> wrote:
>>
>> On May 4, 2016, at 5:50 PM, Chris Lattner via swift-evolution <swift-
>> evolution at swift.org> wrote:
>>>
>>> Proposal link:
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md
>>>
>>> Sequence.prefix(while:) & Sequence.drop(while:) - These are
>>> *accepted* as specified in revision 3 of the proposal.
>>
>> I'm still a little sad we didn't go for `prefix`/`suffix` or
>> `take`/`drop` pairs that linguistically matched.Nonetheless I'm
>> gratified these are hopping into the language. That said, I'm going
>> to put on my painters cap to consider selecting some exterior latex
>> for the feature I was most looking forward to in this proposal:
>>
>> Core team writes:
>>> unfold(_:applying:) - This addition is *rejected* by the core team
>>> as written, but deserves more discussion in the community, and
>>> potentially could be the subject of a future proposal. The core
>>> team felt that the utility of this operation is high enough to be
>>> worth including in the standard library, but could not find an
>>> acceptable name for it. “unfold” is problematic, despite its
>>> precedence in other language, because Swift calls the corresponding
>>> operation “reduce” and not “fold”. No one could get excited about
>>> “unreduce”. “iterate” was also considered, but a noun is more
>>> appropriate than an verb in this case. Given the lack of a good
>>> name, the core team preferred to reject *_to let the community
>>> discuss it more_*.
>>
>> A few thoughts:
>>
>> * I'm not sure why a noun is more appropriate than a verb. Reduce
>> isn't a noun, prefix isn't a noun, drop isn't a noun.
>
> I’m not a naming guru, but my understanding is that ‘reduce’ was
> picked because it was term of art (like map), which is what allowed
> the misuse of a verb.
>
> One idea that came out of the core team discussion was something like:
>
> sequence(from: 0) { $0 += 42 }
>
> Since it returns a sequence.
It just occurred to me that, if we follow existing naming conventions,
this function would end up returning a value of type SequenceSequence 😁.
-Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160506/78004f40/attachment.html>
More information about the swift-evolution
mailing list