Re: [swift-users] Need better name, want to hide generator

2015-12-20 Thread Janosch Hildebrand via swift-users
Hi Erica, Just a quick side note with regards to: > Dmitri adds: "You can use AnySequence and AnyGenerator, but they come at a > cost of dynamic dispatch for every call. In this case, if you want this > component to be suitable for performance-critical code, I would suggest to > avoid them

Re: [swift-users] Need better name, want to hide generator

2015-12-20 Thread Donnacha Oisín Kidney via swift-users
I was under the impression that the biggest speed bump for AnyGenerator was that it was a class, rather than a struct? All of the generators on the standard library non-“Any” sequences are structs, for instance. > On 20 Dec 2015, at 16:07, Janosch Hildebrand via swift-users >

Re: [swift-users] Need better name, want to hide generator

2015-12-20 Thread Janosch Hildebrand via swift-users
Oh, absolutely. It's just that the compiler is able to optimize through that under the right circumstances. When the generator is constructed, wrapped with anyGenerator() and used in the same module, the compiler can in theory inline everything and get rid of any boxes and dynamic dispatch,

Re: [swift-users] Need better name, want to hide generator

2015-12-19 Thread Erica Sadun via swift-users
Here's what I ended up with. (The use-case for this ended up being light-weight game tile placement, not image processing or anything. ) func cartesianProduct(s1: S1, _ s2: S2) -> AnySequence<(S1.Generator.Element, S2.Generator.Element)> { let items = s1.lazy.flatMap({ item1 in

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Jacob Bandes-Storch via swift-users
Oops, of course I meant product(...) ! Jacob On Fri, Dec 18, 2015 at 1:45 PM, Jacob Bandes-Storch wrote: > 1. Maybe ProductGenerator? > 2. Use AnyGenerator<(T, U)>? > > I'd love to see something like this in stdlib: > > func product(s1: S1, s2: S2) -> >

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Jacob Bandes-Storch via swift-users
1. Maybe ProductGenerator? 2. Use AnyGenerator<(T, U)>? I'd love to see something like this in stdlib: func product(s1: S1, s2: S2) -> ProductSequence { ... } where ProductSequence.Generator.Element is (T, U). So your example could

[swift-users] Need better name, want to hide generator

2015-12-18 Thread Erica Sadun via swift-users
Source: http://swiftstub.com/788132715 Two questions: 1. Can anyone recommended a better name than Cartesian? 2D doesn't work for the compiler and I'm looking for something that doesn't seem "floating-point"-y 2. Is there a way to internalize the generator and

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Erica Sadun via swift-users
At a minimum, this gives me http://swiftstub.com/60017598 But I remember reading *somewhere* (can't remember) that we were supposed to avoid AnyGenerator/AnySequence and they were on the way out. Am I out of my mind? -- E > On Dec 18, 2015, at 2:47 PM, Jacob

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Dmitri Gribenko via swift-users
On Fri, Dec 18, 2015 at 1:22 PM, Erica Sadun via swift-users < swift-users@swift.org> wrote: > 2. Is there a way to internalize the generator and not make it public? I'd > ideally like to hide all details except the fact that this is a sequence of > (Int, Int) > You can use AnySequence and

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Rob Mayoff via swift-users
> > 1. Can anyone recommended a better name than Cartesian? 2D doesn't work > for the compiler and I'm looking for something that doesn't seem > "floating-point"-y > "AllPairs" seems self-explanatory. "CrossJoin" should be intuitive to anyone familiar with relational databases. "product" sounds