On Fri, Feb 17, 2017 at 12:46 PM, David Sweeris <[email protected]> wrote:
> > On Feb 17, 2017, at 10:38 AM, Abe Schneider via swift-evolution < > [email protected]> wrote: > > If I read Nicolas's post correctly, I think he's more arguing for the > ability to create syntax that allows Swift to behave in a similar way > to Numpy/Matlab. While Swift already does allow you to define your own > operators, the main complaint is that he can't define the specific > operators he would like. > > > In Xcode 8.2.1, with the 8.2.1 toolchain, this works (well, it compiles… > obviously it doesn’t check for mis-matched array lengths): > infix operator .+ > func .+ <T: Integer> (lhs: [T], rhs: [T]) -> [T] { > precondition(lhs.count == rhs.count) > return zip(lhs, rhs).map { $0.0 + $0.1 } > } > print([1,2,3].+[4,5,6]) //outputs [5, 7, 9] > There's nothing, afaik, which stands in the way of that syntax today. The proposal is to extend the standard library to add syntax for a math library. The idea of having a core math library has already been mentioned on this list, to great approval, but it should come in the form of an actual library, and not a syntax only!
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
