# 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\
**Page:** 2

<div class="post-metadata">

**Author:** ![Deduction42](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deduction42/32/9206_2.png) [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Post date:** [February 7, 2025, 6:51pm UTC](https://discourse.julialang.org/t/forward-all-function-calls-on-mytype-to-another-wrapped-field/105750/21 "2025-02-07T18:51:50Z")

</div>

This problem is coming up in my own library. I’m trying to implement a simple TimeRecord object, which simply adds a unix timestamp to a value:

```julia
struct TimeRecord{T}
    t :: Float64
    v :: T
end

```

A lot of times, I would simply want to do an operation on the value and pass it back and re-add the timestamp

```julia
f(x::TimeRecord) = TimeRecord(x.t, f(x.v))

```

In other cases for an operator for two time records, I’d want to use the following check to ensure the timestamps are equal

```julia
op(x::TimeRecord,y::TimeRecord) = x.t != y.t ? error("Timestamps must mach") : TimeRecord(x.t, op(x.v, y.v))

```

It just comes to a point where all I want would be something where I can say “If this function “f(x)” doesn’t have a method defined for TimeRecord{T} but has a method for T, then use TimeRecord(x.t, f(x.v))”. If this is a bad idea, at least having formal interfaces I can iterate over in a macro would help.

[Previous page](https://discourse.julialang.org/t/forward-all-function-calls-on-mytype-to-another-wrapped-field/105750.md?page=1)
