`sqrt(0)` v `sin(0)` inconsistency

A sin overload with an integer argument is at best mostly useless, and more likely harmful. This inconsistency only really matters for literals,¹ and zero is the only integer literal that's of any real interest as an argument to sine, but sin(0) is just 0, so adding another candidate to the overload set for sin just to resolve this inconsistency doesn't have much value.

This is the ElementaryFunctions protocol in Numerics. I recommend using it. Ideally it would be part of the standard library, but SE-0246 had to be rolled back due to type checker issues. We hope to revisit it in the future, but for now these API (and more besides) are readily available in the numerics package.

Zero messengers have been shot.


¹ being able to use sin in generic code does have value, but adding an Int overload doesn't get you that. The ElementaryFunctions protocol does, which is another reason to use it.

5 Likes