# Instantiating function from type?

**URL:** <https://discourse.julialang.org/t/instantiating-function-from-type/107532>\
**Category:** General Usage\
**Tags:** type, function\
**Created:** [December 12, 2023, 10:37pm UTC](https://discourse.julialang.org/t/instantiating-function-from-type/107532 "2023-12-12T22:37:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [December 12, 2023, 11:35pm UTC](https://discourse.julialang.org/t/instantiating-function-from-type/107532/2 "2023-12-12T23:35:29Z")

</div>

Not sure whether there exist other solutions, but what you suggest here is more or less the same as the solution provided by @Mason in this older thread:

> [@How to get a function instance from a function type?](https://discourse.julialang.org/t/how-to-get-a-function-instance-from-a-function-type/79585/2):
>
> No, because not all functions have a one-to-one relationship with their types. For instance, f = let x = 1 y -\> x + y end captures runtime data and cannot be reconstructed from it’s type alone. That said, in the case of functions which are singleton instances, you could do if isdefined(tf, :instance) ft.instance else error("This type does not have a single instance") end

---

_[View the full topic](https://discourse.julialang.org/t/instantiating-function-from-type/107532)._
