It seems like an obvious thought to me to add overloads for operators for types such as SCNMatrix4
and SCNVector3
, but Apple seem to have chosen to use static global functions (such as SCNMatrix4Mult
). While operators such as matrix multiplication and vector addition are trivial to add, I am wondering:
- Is there any reason to avoid such overloads in Swift?
- Is there any canonical library for such overloads? I found these:
- Is there anything more to an implementation than the following?
Example implementation:
func * (left: SCNMatrix4, right: SCNMatrix4) -> SCNMatrix4 {
return SCNMatrix4Mult(left, right)
}
func + (left: SCNVector3, right: SCNVector3) -> SCNVector3 {
return SCNVector3Make(left.x + right.x, left.y + right.y, left.z + right.z)
}