# Overload function application

**URL:** <https://discourse.julialang.org/t/overload-function-application/87205>\
**Category:** General Usage\
**Created:** [September 13, 2022, 10:51am UTC](https://discourse.julialang.org/t/overload-function-application/87205 "2022-09-13T10:51:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty](https://avatars.discourse-cdn.com/v4/letter/q/4491bb/32.png) [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Post date:** [September 13, 2022, 10:51am UTC](https://discourse.julialang.org/t/overload-function-application/87205/1 "2022-09-13T10:51:23Z")

</div>

I defined a struct like this:

```julia
struct MyType
    a::Float64
end

```

The problem is that I want to use all the functions defined on Float64 on MyType without having to rewrite them all. What is the best way to do this?  
My attempt is not very elegant:

```julia
|>(a::MyType, f) = MyType(f(a.a)) 

k = MyType(3)
k |> sin # MyType(0.1411200080598672)
sin(k) # ERROR 

```

I have to use |\> always

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 13, 2022, 11:24am UTC](https://discourse.julialang.org/t/overload-function-application/87205/2 "2022-09-13T11:24:25Z")

</div>

See:

> [@Method forwarding macro](https://discourse.julialang.org/t/method-forwarding-macro/23355/8):
>
> Yes. I thought they are the same, but interestingly, upon more research it appears that [forwarding and delegation are different in their semantics](https://stackoverflow.com/a/28539643/1576462). I believe that composition is used in many places in Julia but it may be that most people just write the delegation code manually. It would be nice to have a standard macro somewhere that is versatile enough to cover many use cases.

and

> [@Forward all methods of a structure](https://discourse.julialang.org/t/forward-all-methods-of-a-structure/11783/5):
>
> I’m not quite sure I’m understanding you correctly, but it sounds like you want to define a new function for arrays, and then also extend that to a new type. It might help if you could give a broader explanation of what you’re trying to do. It’s still sounding a bit like you just want some new AbstractArray methods, in which case what you should do is define Daggered \<: AbstractArray and then simply define some methods which take an AbstractArray argument, i.e. trait(A::AbstractArray, args...…
