# Function sub typing of Functors

**URL:** <https://discourse.julialang.org/t/function-sub-typing-of-functors/68658>\
**Category:** Performance\
**Tags:** functors\
**Created:** [September 23, 2021, 10:28pm UTC](https://discourse.julialang.org/t/function-sub-typing-of-functors/68658 "2021-09-23T22:28:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdlara-berkeley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdlara-berkeley/32/4096_2.png) [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Post date:** [September 23, 2021, 10:28pm UTC](https://discourse.julialang.org/t/function-sub-typing-of-functors/68658/1 "2021-09-23T22:28:55Z")

</div>

When defining a functor should the struct be subtyped from `Function`?

For instance

```julia
struct foo <: Function 
   a
   b
end

function (functor::foo)(x, y) 
    return functor.a*x + functor.b*y
end

```

or just is fine?

```julia
struct foo 
   a
   b
end

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 23, 2021, 10:55pm UTC](https://discourse.julialang.org/t/function-sub-typing-of-functors/68658/2 "2021-09-23T22:55:14Z")

</div>

No, the functor is like a closure, it is a function and the struct is a parameter, which can be of any type.
