Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-30 Thread Kevin Ballard via swift-evolution
On Wed, Dec 30, 2015, at 02:27 PM, plx via swift-evolution wrote: > >> On that note, core language team, anyone know offhand why >> SequenceType has a bunch of extension methods that aren't part of the >> protocol? For example, contains(_ predicate:). The only real reason I >> can think of is to sh

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-30 Thread plx via swift-evolution
> On Dec 30, 2015, at 3:39 PM, Kevin Ballard via swift-evolution > wrote: > > Refactoring like that can always be done later; introducing infinite > sequences now shouldn't make it any harder to refactor the protocols. If > anything, it will provide more practical experience with how infinite

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-30 Thread Kevin Ballard via swift-evolution
Refactoring like that can always be done later; introducing infinite sequences now shouldn't make it any harder to refactor the protocols. If anything, it will provide more practical experience with how infinite sequences interact with the current protocol hierarchy that would help guide the design

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-30 Thread plx via swift-evolution
> On Dec 29, 2015, at 6:38 PM, Dave Abrahams wrote: > > >> On Dec 29, 2015, at 3:39 PM, plx via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >>> >>> On Dec 29, 2015, at 1:17 PM, Kevin Ballard via swift-evolution >>> mailto:swift-evolution@swift.org>> wrote: >>> >>> On Tu

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Kevin Ballard via swift-evolution
On Tue, Dec 29, 2015, at 10:12 PM, Andrew Bennett wrote: > Hi Kevin, > > The issue I was seeing was because AnySequence uses the protocol > extension on SequenceType for its implementations of > filter/suffix/prefix etc. So I don't think it's taking into account > any implementations of those on th

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Andrew Bennett via swift-evolution
Hi Kevin, The issue I was seeing was because AnySequence uses the protocol extension on SequenceType for its implementations of filter/suffix/prefix etc. So I don't think it's taking into account any implementations of those on the base sequence's type. The problem basically comes down to this:

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Developer via swift-evolution
I think we have to make some things clear. Unfortunately, I used the word stream when I meant cycle, they are very different things from an implementer's perspective. A stream is a generalized version of a cycle, where the latter admits infinite sequences of any kind or mix of data (say, the

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Craig Cruden via swift-evolution
I have never tried to implement a “stream” in Swift, so I am not sure if there is an easy way to do it…. but I don’t see a collection of type stream as I have in Scala. http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Stream

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Kevin Ballard via swift-evolution
On Tue, Dec 29, 2015, at 04:11 PM, Dave Abrahams wrote: > > > On Dec 27, 2015, at 11:20 PM, Kevin Ballard via swift-evolution > > wrote: > > > > ## Introduction > > > > Add a new property `cycle` to CollectionType that returns an infinite > > SequenceType that yields the elements of the colle

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Dave Abrahams via swift-evolution
> On Dec 29, 2015, at 4:29 PM, Craig Cruden wrote: > >> Could you define what you mean by “stream support?” Whatever it is, I doubt >> simply adding an infinitely-repeating sequence type is enough to get you >> there. > > > I can guess — but it is only a guess. > > A function defines an

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Dave Abrahams via swift-evolution
> On Dec 29, 2015, at 3:39 PM, plx via swift-evolution > wrote: > >> >> On Dec 29, 2015, at 1:17 PM, Kevin Ballard via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> On Tue, Dec 29, 2015, at 08:14 AM, plx via swift-evolution wrote: >>> Personally I’d say this should be a

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Craig Cruden via swift-evolution
> Could you define what you mean by “stream support?” Whatever it is, I doubt > simply adding an infinitely-repeating sequence type is enough to get you > there. I can guess — but it is only a guess. A function defines an infinite “set” of values (like the digits of pi). A stream is just

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Dave Abrahams via swift-evolution
> On Dec 27, 2015, at 11:35 PM, Developer via swift-evolution > wrote: > > +1. Stream support is long overdue. Could you define what you mean by “stream support?” Whatever it is, I doubt simply adding an infinitely-repeating sequence type is enough to get you there. -Dave

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Dave Abrahams via swift-evolution
> On Dec 27, 2015, at 11:20 PM, Kevin Ballard via swift-evolution > wrote: > > ## Introduction > > Add a new property `cycle` to CollectionType that returns an infinite > SequenceType that yields the elements of the collection in a loop. The name should give an explicit indication that the r

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Kevin Ballard via swift-evolution
On Tue, Dec 29, 2015, at 03:39 PM, plx via swift-evolution wrote: > >> On Dec 29, 2015, at 1:17 PM, Kevin Ballard via swift-evolution > evolut...@swift.org> wrote: >> >> On Tue, Dec 29, 2015, at 08:14 AM, plx via swift-evolution wrote: >>> Personally I’d say this should be a -1 for standard-library

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread plx via swift-evolution
> On Dec 29, 2015, at 1:17 PM, Kevin Ballard via swift-evolution > wrote: > > On Tue, Dec 29, 2015, at 08:14 AM, plx via swift-evolution wrote: >> Personally I’d say this should be a -1 for standard-library inclusion. >> >> Swift’s not really built to handle infinite sequences right now; until

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Kevin Ballard via swift-evolution
On Tue, Dec 29, 2015, at 08:14 AM, plx via swift-evolution wrote: > Personally I’d say this should be a -1 for standard-library inclusion. > > Swift’s not really built to handle infinite sequences right now; until they > are handed better by the standard library convenience methods for creating

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Kevin Ballard via swift-evolution
On Tue, Dec 29, 2015, at 02:27 AM, Andrew Bennett wrote: > +1 looks good, I had a go at implementing it and I think it may > require changes not discussed in the proposal. > > You've covered the potential issues fairly well, to be a little more > explicit these are the issues I've found: >> 1) Lazy

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread plx via swift-evolution
Personally I’d say this should be a -1 for standard-library inclusion. Swift’s not really built to handle infinite sequences right now; until they are handed better by the standard library convenience methods for creating them shouldn’t be in the standard library. You’d also want to call `fatal

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-29 Thread Andrew Bennett via swift-evolution
+1 looks good, I had a go at implementing it and I think it may require changes not discussed in the proposal. You've covered the potential issues fairly well, to be a little more explicit these are the issues I've found: 1) LazySequenceType's property array cannot be defined without an infinite

Re: [swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-27 Thread Developer via swift-evolution
+1. Stream support is long overdue. ~Robert Widmann 2015/12/28 2:20、Kevin Ballard via swift-evolution のメッセージ: > ## Introduction > > Add a new property `cycle` to CollectionType that returns an infinite > SequenceType that yields the elements of the collection in a loop. > > ## Motivation >

[swift-evolution] Proposal: CollectionType.cycle property for an infinite sequence

2015-12-27 Thread Kevin Ballard via swift-evolution
## Introduction Add a new property `cycle` to CollectionType that returns an infinite SequenceType that yields the elements of the collection in a loop. ## Motivation It's sometimes useful to be able to have an infinite sequence. For example, `CollectionOfOne(x).cycle` could be used to have an