[swift-evolution] About the PermutationGenerator

Dave Abrahams dabrahams at apple.com
Thu Dec 31 13:03:31 CST 2015


> On Dec 31, 2015, at 9:52 AM, Erica Sadun <erica at ericasadun.com> wrote:
> 
> I'm trying to work them out, so it's still muddled.
> 
> Right now, I think SequenceType is better described as CollectionWalkType

Why do you say so?

> but that's kind of (1) a mouthful and (2) not entirely accurate. 
> 
> Moving back a step: SequenceType is defined as: "A type that can be iterated with a `for`...`in` loop." But it says nothing about whether that loop ever terminates and many stdlib sequence functions currently don't make sense (at least if they're not lazy) with respect to infinite sequences, which should probably be "StreamType" not sequences. A couple of examples:
> Here's my fib: http://swiftstub.com/189513594/ <http://swiftstub.com/189513594/>
> And here's Oisin's user-input sequence:  https://gist.github.com/oisdk/2c7ac33bf2188528842a <https://gist.github.com/oisdk/2c7ac33bf2188528842a>
> Both of these are theoretically filterable, but they aren't dropLast-able, suffix-able, properly split-able, etc.
> 
> Hopefully that's enough of a starting point to indicate where my thinking is at and what I'm trying to think through when it comes to this. — E

All you’ve descrived here is the lack of a distinct protocol for finite sequences, which doesn't indicate “muddled concepts” at all.  It's a conscious choice of protocol granularity per this posting <http://news.gmane.org/find-root.php?message_id=2A3E0C76-1C88-4752-8A70-AA64BB14223A@apple.com>   In the development of the standard library we’ve tried to keep the API surface area small and given all the factors described in that posting, the conservative choice was to not separate them.

That’s not to say I’m opposed to carving out a place for finite sequences (and as we approach ABI stability now would be the time to do it) but I’d like to clearly understand why we’re doing it, and ideally I’d like to address all of the concerns noted in the post.

> 
> 
>> On Dec 31, 2015, at 10:09 AM, Dave Abrahams <dabrahams at apple.com <mailto:dabrahams at apple.com>> wrote:
>> 
>> 
>>> On Dec 31, 2015, at 9:05 AM, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> It does seem that in Swift the concepts of collection, sequence, permutation, stream, etc are a bit muddled.
>> 
>> This is a pretty vague critique.  Do you have specifics, and suggestions that address them?
>> 
>>> 
>>> -- E
>>> 
>>> 
>>>> On Dec 31, 2015, at 6:51 AM, Tino Heth via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>>> Those are collections.  Collections can be iterated over multiple times.
>>>> Speaking of the Fibonacci-numbers:
>>>> Sure we can write an algorithm that iterates over them several times — it just won't ever finish the first iteration ;-)
>>>> (only nitpicking — I just couldn't resist)
>>>> 
>>>> Happy new year!
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> -Dave
>> 
> 

-Dave

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


More information about the swift-evolution mailing list