# Suggestion: Fortran-like Keyword to Assert Function is Pure

**URL:** <https://discourse.julialang.org/t/suggestion-fortran-like-keyword-to-assert-function-is-pure/63047>\
**Category:** Internals & Design\
**Created:** [June 16, 2021, 8:34pm UTC](https://discourse.julialang.org/t/suggestion-fortran-like-keyword-to-assert-function-is-pure/63047 "2021-06-16T20:34:37Z")\
**Posts on this page:** 3\
**Page:** 4

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [June 20, 2021, 4:40pm UTC](https://discourse.julialang.org/t/suggestion-fortran-like-keyword-to-assert-function-is-pure/63047/62 "2021-06-20T16:40:12Z")

</div>

> [@ParadaCarleton](#):
>
> replacing a method with a different method that dispatches on the exact same types.

this is not the only situation that can change what methods get called given the same set of arguments. A package could have a generic fallback on abstract types, then another package / user come along added a subtype of that abstract type and added a more specific method.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [June 20, 2021, 5:57pm UTC](https://discourse.julialang.org/t/suggestion-fortran-like-keyword-to-assert-function-is-pure/63047/63 "2021-06-20T17:57:30Z")

</div>

Yes, I’m aware. If you’re not overwriting the method, I’m saying that the more specific method should be ignored when called from inside a `pure` function if it’s not `pure`. This strikes me as a good thing – if a more specific method is impure while the more general method is `pure`, they’re probably doing different things and aren’t interchangeable, and function calls relying on purity can reasonably be inferred to want to use the pure method.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [June 20, 2021, 6:04pm UTC](https://discourse.julialang.org/t/suggestion-fortran-like-keyword-to-assert-function-is-pure/63047/64 "2021-06-20T18:04:08Z")

</div>

With regards to frequency, I’m saying that disallowing this – complete overwriting of `pure` methods, rather than just adding a new `impure` method to a function – would presumably not be a big burden on anyone, since it’s very rare that people want to completely overwrite a method. (Especially one that you’d think of as pure.)

Thanks for giving the example of normal overloading, though – I see now why the proposal of just defaulting to the most specific `pure` method wouldn’t work, since even introducing a new `pure` method can create impure behavior. Yeah, that’s a real problem, and I’ll have to think about it.

[Previous page](https://discourse.julialang.org/t/suggestion-fortran-like-keyword-to-assert-function-is-pure/63047.md?page=3)
