[Accepted with Modifications] SE-0246: Generic Math Functions

(Xiaodi Wu) #21

Huh. Why did we make this change? Ah, you mean ElementaryFunctions.

1 Like
(Antoine Cœur) #22

Talking about naming, I would have preferred squareRoot over sqrt. With an IDE like Xcode, tapping s-q-r-t would still allow auto-completion to the readable form of squareRoot.

With those old C names like sqrt, you can't tell if it's a mutable or non-mutable function, and you wouldn't know how to name the counterpart. Are we going to have a formSqrt for instance as a mutable version of the same function?

(Steve Canon) #23

For free functions, there are no mutating variants, so this isn't an issue. For the implementation hooks (statics), there is again no way to have a mutating version. I.e., these new operations appear either as sqrt(x) or Float.sqrt(x). There's no way either of those can be mutating, so no confusion is possible.

Even the existing method x.formSquareRoot( ) was probably ill-considered because it doesn't offer any efficiency wins, but everyone was quite gung-ho about testing out the edges of the naming conventions at that point. It's a vestigial curiosity now that we might deprecate at some future point.

1 Like