# Quick question : generated functions and later defined functions

**URL:** <https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812>\
**Category:** General Usage\
**Created:** [November 6, 2019, 11:42pm UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812 "2019-11-06T23:42:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [November 6, 2019, 11:42pm UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812/1 "2019-11-06T23:42:18Z")

</div>

Hi,

Here,[Metaprogramming · The Julia Language](https://docs.julialang.org/en/v1/manual/metaprogramming/#Generated-functions-1),  
it says **" generated function _cannot_ call any method that was not defined prior to the _definition_ of the generated function itself."**

Is there a way to go beyond this? like including the later defined methods in the dispatch without using them in the generated expression.

Is this related to world age problem? And if so why Base.invokelast doesn’t work.

Thanks

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 6, 2019, 11:52pm UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812/2 "2019-11-06T23:52:58Z")

</div>

This package: [https://github.com/NHDaly/StagedFunctions.jl](https://github.com/NHDaly/StagedFunctions.jl) is trying to get around that restriction.

---

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [November 6, 2019, 11:57pm UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812/3 "2019-11-06T23:57:17Z")

</div>

How is it trying to that? Do you know, GitHub page doesn’t have much info.  
Thanks

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [November 12, 2019, 5:13am UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812/4 "2019-11-12T05:13:27Z")

</div>

You write an abstract interpreter that itself is pure, but can return an total description of both the result and the methods needed to derive it.

---

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [November 12, 2019, 5:44am UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812/5 "2019-11-12T05:44:31Z")

</div>

so basically, what if I apply Core.\_apply\_pure , it should solve my problem? Huh?

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [November 12, 2019, 6:08am UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812/6 "2019-11-12T06:08:01Z")

</div>

That can never be right as that function isn’t valid to use (outside of the compiler itself), but I can’t speak to the quality of any particular implementation. I’m just saying what you would need to implement.
