[swift-evolution] Proposal: Add SequenceType.first

Dave Abrahams dabrahams at apple.com
Thu Dec 31 21:27:41 CST 2015


> On Dec 31, 2015, at 4:19 PM, Kevin Ballard <kevin at sb.org> wrote:
> 
> I've submitted a proposal to the ML for BufferedSequence / BufferedGenerator as https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151228/005010.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151228/005010.html>.

Thanks.

> I kept the name "peek" for the method because, as mentioned in that email, there's plenty of precedent for it.

It’s a perfectly cromulent name for that purpose.  I just don’t think it belongs in the type name.
 
>  
> -Kevin Ballard
>  
> P.S. The plain-text version of the email is hard to read because the FastMail web interface doesn't handle rich text very well. The rich text version should be much more readable.
>  
> On Thu, Dec 31, 2015, at 02:03 PM, Dave Abrahams wrote:
>>>> I suggest you consider adding a BufferedSequence<Base: SequenceType> that has a stable first property (at least until it is iterated)
>>>  
>>> Good idea, though I'd probably call it PeekSequence because it would only buffer a single element (and BufferedSequence sounds like it's got an arbitrary-sized buffer). Perhaps more useful would be the associated PeekGenerator, because peek() is a useful thing to have when writing custom generator-using code.
>>  
>> The size of the buffer is an implementation detail, and I don’t find “peek” descriptive.
>  

-Dave

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151231/a7b3fb6b/attachment.html>


More information about the swift-evolution mailing list