> On Nov 22, 2016, at 03:04, Tino Heth via swift-users
> wrote:
>
> Hi Rick,
>
> as evolution is somewhat paused, swift-users seems to gain more traction ;-)
>
> Imho the most natural would be
> extension Array {
> …
> }
>
> I hope to see this addition included when
> On 23 Nov 2016, at 01:50, Hooman Mehr via swift-users
> wrote:
>
> For example, this reduces the six variants of sum to two:
>
> public protocol ContiguousBufferedArray: RandomAccessCollection {
>
> func withUnsafeBufferPointer(_ body:
>
That seems to work well, thanks!
> On Nov 22, 2016, at 16:59 , Hooman Mehr wrote:
>
> By the way, even without new Swift 3.1 feature, this works, providing
> optimized sum function for all three types:
>
> extension ContiguousBufferedArray where Iterator.Element == Double {
>
By the way, even without new Swift 3.1 feature, this works, providing optimized
sum function for all three types:
extension ContiguousBufferedArray where Iterator.Element == Double {
func sum() -> Double {
var result = Double()
withUnsafeBufferPointer {
Thanks! It's all very educational, at the least.
Obviously the ideal would be for LLVM to recognize and optimize (there are many
ways to write the sum of an array), but this is cool.
> On Nov 22, 2016, at 16:50 , Hooman Mehr wrote:
>
> For example, this reduces the six
> On Nov 22, 2016, at 03:39 , Adrian Zubarev
> wrote:
>
> It’s already fixed for Swift 3.1.
>
> Here is the change log.
Cool. I wonder when it will appear in a shipping Xcode.
So, dumb question: how do you know that "Element" is the name of the thing you
> On Nov 22, 2016, at 03:04 , Tino Heth <2...@gmx.de> wrote:
>
> Hi Rick,
>
> as evolution is somewhat paused, swift-users seems to gain more traction ;-)
>
> Imho the most natural would be
> extension Array {
> …
> }
>
> I hope to see this addition included when the topic is discussed again.
It is good to know that
extension Array where Element == Double { }
will work pretty soon with Swift 3.1.
Back to reduce(0,+):
If we get specialized instance for a reduce(0,+), so that it is known that “+”
is a (Double, Double)->Double function, LLVM’s auto-vectorization should be
able to
Hi Rick,
as evolution is somewhat paused, swift-users seems to gain more traction ;-)
Imho the most natural would be
extension Array {
…
}
I hope to see this addition included when the topic is discussed again.
- Tino
___
swift-users mailing list
This is not possible in Swift 3.0. Swift 4.0 will improve things with
conditional conformances.
For now, the best solution is using global functions instead of extending types
or protocols.
For example you can do this now:
extension Array where Element: FloatingPoint {
func sum() ->
10 matches
Mail list logo