Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-26 Thread Dave Abrahams via swift-evolution
On behalf of Dmitri Gribenko, Max Moiseev, and myself: on Thu May 19 2016, Kevin Ballard wrote: > After having given this some thought, it seems apparent that `sequence > (state:next:)` is equivalent to `AnyIterator({ ... })` where the closure > captures a single mutable variable. Yes.

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-25 Thread Dave Abrahams via swift-evolution
on Wed May 25 2016, Erica Sadun wrote: > On May 25, 2016, at 2:18 PM, Kevin Ballard via swift-evolution > wrote: > > We think the need to do a capture is icky, so the sequence form is > almost always better. > > I agree that the need for a capture is ugly. > > The design of AnySequence an

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-25 Thread Erica Sadun via swift-evolution
> On May 25, 2016, at 2:18 PM, Kevin Ballard via swift-evolution > wrote: >> We think the need to do a capture is icky, so the sequence form is >> almost always better. > > I agree that the need for a capture is ugly. >> The design of AnySequence and AnyIterator dates from a time when the >> c

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-25 Thread Kevin Ballard via swift-evolution
On Wed, May 25, 2016, at 01:08 PM, Dave Abrahams wrote: > > > > On behalf of Dmitri Gribenko, Max Moiseev, and myself: > > on Thu May 19 2016, Kevin Ballard > wrote: > > > After having given this some thought, it seems apparent that `sequence > > (state:next:)` is equivalent to `AnyIterator(

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-23 Thread Kevin Ballard via swift-evolution
On Mon, May 23, 2016, at 05:44 AM, Jeremy Pereira via swift-evolution wrote: > > > On 19 May 2016, at 23:29, Chris Lattner via swift-evolution > > wrote: > > > > > > * What is your evaluation of the proposal? > > +1 > > I think I would find myself using this in loads of places, if it was

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-23 Thread Jeremy Pereira via swift-evolution
> On 19 May 2016, at 23:29, Chris Lattner via swift-evolution > wrote: > > > * What is your evaluation of the proposal? +1 I think I would find myself using this in loads of places, if it was implemented. One question: what is the downside of making these functions `rethrows` and al

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-20 Thread David Rönnqvist via swift-evolution
* What is your evaluation of the proposal? +1. These are useful additions to the standard library. Naming the first argument `initial` (in the `T->T?` variant) is consistent with `reduce` and makes it clear (to me) that the initial value is part of the result. * Is the problem

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Kevin Ballard via swift-evolution
On Thu, May 19, 2016, at 05:59 PM, Patrick Smith wrote: > This sounds fair to me. I imagine a functional version would return > two item tuple instead of mutating, so would it be that similar to > what people expect? A functional version of `sequence(state:next:)` would indeed use the type signat

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Matthew Johnson via swift-evolution
> > * What is your evaluation of the proposal? +1. These functions are really handy. The standard library should definitely include commonly useful utilities like these. > * Is the problem being addressed significant enough to warrant a > change to Swift? Yes. It’s best to

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Erica Sadun via swift-evolution
Once you start using it, it's really hard to put it down. -- E, who will not make the obvious "for" joke > On May 19, 2016, at 7:10 PM, Patrick Smith wrote: > > I think that is a little confusing and has potential to be ‘abused’. I think > it’s more confusing that a `for(;;)` loop for instanc

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Patrick Smith via swift-evolution
I think that is a little confusing and has potential to be ‘abused’. I think it’s more confusing that a `for(;;)` loop for instance, and that got removed. I think var + AnyIterator is more explicit, and can become the canonical way to do this. Hopefully AnyIterator can be optimized to the same

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Patrick Smith via swift-evolution
This sounds fair to me. I imagine a functional version would return two item tuple instead of mutating, so would it be that similar to what people expect? > On 20 May 2016, at 10:52 AM, Kevin Ballard via swift-evolution > wrote: > > After having given this some thought, it seems apparent that

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Erica Sadun via swift-evolution
> On May 19, 2016, at 6:52 PM, Kevin Ballard via swift-evolution > wrote: > > After having given this some thought, it seems apparent that > `sequence(state:next:)` is equivalent to `AnyIterator({ ... })` where the > closure captures a single mutable variable. The microbenchmark performance

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Kevin Ballard via swift-evolution
After having given this some thought, it seems apparent that `sequence(state:next:)` is equivalent to `AnyIterator({ ... })` where the closure captures a single mutable variable. The microbenchmark performance may differ slightly, as the AnyIterator version will allocate a box on the heap to hold

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Trent Nadeau via swift-evolution
It would certainly be clearer that the state is changing on each "iteration", but I'm not sure it's worth such a long parameter label. Maybe `sequence(state:update:)`? On Thu, May 19, 2016 at 8:46 PM, Patrick Smith wrote: > Would `sequence(mutatingState:next:)` perhaps be clearer? > > > On 20 Ma

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Patrick Smith via swift-evolution
Would `sequence(mutatingState:next:)` perhaps be clearer? > On 20 May 2016, at 10:37 AM, Trent Nadeau via swift-evolution > wrote: > > Ah, yes. I apologize. The fact that state is inout, and the same instance is > always passed in confused me. Thanks for the correction. > > On Thu, May 19, 2

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Trent Nadeau via swift-evolution
Ah, yes. I apologize. The fact that state is inout, and the same instance is always passed in confused me. Thanks for the correction. On Thu, May 19, 2016 at 7:46 PM, Brent Royal-Gordon wrote: > > Also note that there's a typo in the second example: > > > > for view in sequence(initial: someView

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Brent Royal-Gordon via swift-evolution
> Also note that there's a typo in the second example: > > for view in sequence(initial: someView, next: { $0. > superview }) { > > // someView, someView.superview, someView.superview.superview, ... > > } > > > should be: > > for view in sequence(state: someView, next: { $0. > superview }

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Kevin Ballard via swift-evolution
On Thu, May 19, 2016, at 04:20 PM, Trent Nadeau via swift-evolution wrote: > Also note that there's a typo in the second example: > > for view in sequence(initial: someView, next: { $.superview }) { // > someView, someView.superview, someView.superview.superview, ... } > > should be: > > for view

Re: [swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Trent Nadeau via swift-evolution
* What is your evaluation of the proposal? +1. I've used unfold/iterate functions in Haskell and Clojure, and they are very useful. * Is the problem being addressed significant enough to warrant a change to Swift? Yes. * Does this proposal fit well with the feel and directio

[swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

2016-05-19 Thread Chris Lattner via swift-evolution
Hello Swift community, The review of "SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib" begins now and runs through May 23. This is a refinement of part of SE-0045. The proposal is available here: https://github.com/apple/swift-evolution/blob/master/proposa