extension Array where Element:CanDoMath {
// instead of this style:
func sum_outside() -> Element {
var result = 0
let p = self.pointerToStorage // your "get the pointer" method, I think it was just `p`, too?
for i in 0..<count {
result += p[i]
}
return result
}
// how does this compare (in -unchecked mode, at least)?
func sum_inside() -> Element {
return self.withUnsafeBufferPointer() {
var result = 0
for v in $0 {
result += v
}
return result
}
}
}
Going the `sum_inside` route for bulk operations makes it easier to remain idiomatic, keep COW around (assuming you want it), benefit from `var/let`, and so on. The only obvious concerns are (a) relative overhead--did you ever benchmark that?--and (b) alignment.
Similarly, the degree to which market advocates, themselves, exhibit skepticism about the market mechanism vis-a-vis their own intellectual products is so immense, in fact, that the idea that ideas achieving widespread adoption within the marketplace of ideas do, indeed, have vastly greater value than those with inferior adoption is simply met with comparably-inarticulate derision.