# Discussion on Base.@pure usage

**URL:** <https://discourse.julialang.org/t/discussion-on-base-pure-usage/56491>\
**Category:** Performance\
**Tags:** question\
**Created:** [March 4, 2021, 6:15pm UTC](https://discourse.julialang.org/t/discussion-on-base-pure-usage/56491 "2021-03-04T18:15:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![rryi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rryi/32/9799_2.png) [@rryi](https://discourse.julialang.org/u/rryi)\
**Post date:** [March 5, 2021, 10:44am UTC](https://discourse.julialang.org/t/discussion-on-base-pure-usage/56491/3 "2021-03-05T10:44:30Z")

</div>

> [@Henrique\_Becker](#):
>
> cannot use `@pure` in such cases

Thanks for the hint. I will remove @pure annotations - it was a fruitless attempt to persuade compiler to do constant propagation, leaving them in the code could cause trouble in the long run.

@pure doc states “Double check for calls to generic functions.” - their use is discouraged but not strictly forbidden in a @pure function. I am pretty sure getindex, length and reinterpret are safe to use in my code sample, because I call them only with parameters of very basic system types.

My understanding of a pure function is “no side effects, result depends only on function parameters”. Though I expect it holds for my @pure annotated functions in normal use, I cannot guarantee it. If someone defines a type _MyTypeChangingGlobalState_ and increments a global counter in every call of _bitsizeof(MyTypeChangingGlobalState)_, it causes side effects, and if its return value is not constant, it breaks my code.

I found [this discussion](https://discourse.julialang.org/t/pure-macro/3871) clarifying dangers and benefits or @pure.

---

_[View the full topic](https://discourse.julialang.org/t/discussion-on-base-pure-usage/56491)._
