# Creating the instance of a function type

**URL:** <https://discourse.julialang.org/t/creating-the-instance-of-a-function-type/122355>\
**Category:** General Usage\
**Tags:** functions\
**Created:** [November 6, 2024, 8:25pm UTC](https://discourse.julialang.org/t/creating-the-instance-of-a-function-type/122355 "2024-11-06T20:25:48Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![raminammour](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raminammour/32/13572_2.png) [@raminammour](https://discourse.julialang.org/u/raminammour)\
**Post date:** [November 7, 2024, 3:53pm UTC](https://discourse.julialang.org/t/creating-the-instance-of-a-function-type/122355/14 "2024-11-07T15:53:41Z")

</div>

I will link [Jameson’s important comment](https://discourse.julialang.org/t/is-there-a-way-to-get-f-from-typeof-f/18818/12) from that thread, and emphasize below:

> [@Is there a way to get f from typeof(f)?](https://discourse.julialang.org/t/is-there-a-way-to-get-f-from-typeof-f/18818/12):
>
> Most of the “solutions” presented here are wrong: **you should never need to access “.instance”. This is an internal API and not stable. The correct way to do this is to store the actual function object itself, and always refer to it by value and don’t try to do this in the type-domain.** Adopting the original example, we get the much-shortened:
> 
> ```julia
> julia> struct MyStruct{F}
> f::F
> end
> 
> julia> ExtractFun(s::MyStruct) = s.f
> 
> ```

What is wrong with the solution he presented, where you store the function in the struct and access it by value as above, why does it need to be done in the type domain?

---

_[View the full topic](https://discourse.julialang.org/t/creating-the-instance-of-a-function-type/122355)._
