# Forward all function calls on ::MyType to another wrapped field

**URL:** <https://discourse.julialang.org/t/forward-all-function-calls-on-mytype-to-another-wrapped-field/105750>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 3, 2023, 11:50am UTC](https://discourse.julialang.org/t/forward-all-function-calls-on-mytype-to-another-wrapped-field/105750 "2023-11-03T11:50:48Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![pablosanjose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablosanjose/32/7006_2.png) [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Post date:** [November 3, 2023, 3:02pm UTC](https://discourse.julialang.org/t/forward-all-function-calls-on-mytype-to-another-wrapped-field/105750/16 "2023-11-03T15:02:30Z")

</div>

Well, if we just forward the wrapped field to `f`, we are simply inheriting the behavior of `A`, not implementing arbitrary new behavior (we would get a MethodError if `f(::A, ...)` is not defined).

However, your comment indeed suggests that `(f::Function)(b::B, args...) = ...` is probably not the correct implementation of behavior inheritance. It should probably be done differently, not through a “abstract Function method”, but something like [`@forward` from MacroTools.jl](https://discourse.julialang.org/t/method-forwarding-macro/23355), but that could somehow work for any function. So

```julia
@forward B.a

```

would have the restricted effect of forwarding `f(b::B, args...)` to `f(b.a, args...)` for any function `f`

---

_[View the full topic](https://discourse.julialang.org/t/forward-all-function-calls-on-mytype-to-another-wrapped-field/105750)._
