Qqwy/elixir-rational

Depend on operators from `Numbers` rather than defining all of them in here

Closed this issue · 1 comments

Qqwy commented

Instead of defining all operators inside Ratio, depend on the definitions created by Numbers, to reduce API surface duplication.

To be backwards compatible, the operators in this module should delegate to those. (note that since they are macros, this delegation needs to be handled manually and with some care)

Qqwy commented

Also note that extra care needs to be taken with /: When passed two integers, Numbers will return a float, while Ratio will return a rational number.
For backwards compatibility, that one should not dispatch to Numbers.
Maybe for a version 3.x it makes sense to remove this functionality (or hide it behind another compile-time flag?), because it can be considered counter-intuitive.