Re: [swift-users] withoutActuallyEscaping example question

2017-03-27 Thread Dave Abrahams via swift-users
on Mon Mar 27 2017, Jordan Rose wrote: >> On Mar 26, 2017, at 01:14, Slava Pestov via swift-users >> wrote: >> >> Hi Ray, >> >> There are two overloads of filter() available on ‘array.lazy’; the > >> version that takes an escaping closure and returns a >> LazyFilterCollection, and the versio

Re: [swift-users] withoutActuallyEscaping example question

2017-03-27 Thread Jordan Rose via swift-users
> On Mar 26, 2017, at 01:14, Slava Pestov via swift-users > wrote: > > Hi Ray, > > There are two overloads of filter() available on ‘array.lazy’; the version > that takes an escaping closure and returns a LazyFilterCollection, and the > version that takes a non-escaping closure and returns [

Re: [swift-users] withoutActuallyEscaping example question

2017-03-26 Thread Ray Fix via swift-users
Wow. Thanks for the explanation! I didn’t realize I was toggling between different overloads but that makes sense now. Thanks again, Ray PS: It is sort of a strange example in the first place (being lazy and then immediately eager.) I don’t think it is a use case that is compelling enough to

Re: [swift-users] withoutActuallyEscaping example question

2017-03-26 Thread Slava Pestov via swift-users
Here’s another fun one: the following type checks despite the literal closure; we’ve constrained the return type of filter() to [Int], and not LazyFilterCollection, so again the type checker picks the overload that takes the non-escaping closure: func myFilter(array: [Int], predicate: (Int) ->

Re: [swift-users] withoutActuallyEscaping example question

2017-03-26 Thread Slava Pestov via swift-users
Hi Ray, There are two overloads of filter() available on ‘array.lazy’; the version that takes an escaping closure and returns a LazyFilterCollection, and the version that takes a non-escaping closure and returns [Int]. In the first example, we pick the LazyFilterCollection-returning overload,