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

**URL:** <https://discourse.julialang.org/t/rationale-for-the-pure-ity-of-rational-t-x/18872>\
**Category:** General Usage\
**Created:** [December 20, 2018, 11:23pm UTC](https://discourse.julialang.org/t/rationale-for-the-pure-ity-of-rational-t-x/18872 "2018-12-20T23:23:26Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [December 21, 2018, 2:57am UTC](https://discourse.julialang.org/t/rationale-for-the-pure-ity-of-rational-t-x/18872/10 "2018-12-21T02:57:29Z")

</div>

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](https://discourse.julialang.org/t/extending-methods-of-pure-function/18852), 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 `throw`s.

---

_[View the full topic](https://discourse.julialang.org/t/rationale-for-the-pure-ity-of-rational-t-x/18872)._
