[swift-evolution] Operator implementation inside struct/class body

Jessy Catterwaul mr.jessy at gmail.com
Tue Feb 9 05:27:53 CST 2016


> That said, I’m finding it hard to think of examples that really need to be in the global scope, as your example seems to me like it still makes the most sense to be placed within the Matrix2x2 type like so:
> 
> 	func * (vector:Vector2) -> Vector2 { // self is matrix2x2 }
> 
> Since the left hand side is still the focal point of this operator. The only case I could think of that might still require a global operator would be one that can handle arguments of type Any.

Good point! I haven’t been exposed to that approach or thought of it. That might be the best way to handle things, even when operators are allowed to take more than one operand without resorting to passing them in as a tuple like we must now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160209/a7b925de/attachment.html>


More information about the swift-evolution mailing list