Rationale for the `@pure`ity of `Rational{T}(x)`

Thanks, my question here is rather to understand why such strict restrictions you listed do not apply to the method Rational{T}(x::AbstractIrrational) exists in Base. (Rather than to discuss, as in Extending methods of pure function, how to workaround such restriction, if possible at all).

If you think Rational{T}(x::AbstractIrrational) violates the assumptions of purity, I think we should make a PR.

The reason I can think of why Rational{T} is @pure is that:

  • It rolls back the global state. Thus, executing the body of it or not does not change the semantics of the code following it.
  • The second argument p in setprecision(BigFloat, p) never hits the branch in setprecision which throws.