swift-numerics
swift-numerics copied to clipboard
Unicode operators
Since Swift supports Unicode in identifiers, it is possible to improve the appearance of the code by adding aliases for operators, such as: × ⋅ ÷ ∶ (RATIO) - (MINUS SIGN), etc.
What do you think of it?
I think it would be perfectly fine for a developer who prefers this spelling to create a third-party library to vend these operators. However, Swift has standardized on a certain spelling for operators. This issue has already been discussed on Swift Evolution in the past and I don't see how the design of existing standard library operations would fall into the scope of Swift Numerics.
Basically what Xiaodi said.
The one place where I might consider a novel operator in the medium-term future would be around matrix multiplication (where we have a very real need to have a symbol for both the composition of linear maps--normal matrix multiply--and the Hadamard--or elementwise--product). Even there, though, the most obvious and precedented solution is *
and .*
, so I'm relatively unlikely to look to unicode unless there's a truly great option.
I'm marking this wontfix for the medium term. It's something we might consider in the far-off future.
I agree that we should stick to ASCII operators for the foreseeable future. However, just as a point of reference, I have been using a number of √
operators in my personal code, to write things like this:
let a = √2
let b = 1/√2
let c = -√2
let d = √-c
let e = 2√3
let f = (1+√5)/2
…and I also have:
typealias ℂ = Complex<Double>
I would be open to a "cute operators" module at some future point; they really do make reading some code much nicer.