# Method forwarding macro

**URL:** <https://discourse.julialang.org/t/method-forwarding-macro/23355>\
**Category:** General Usage\
**Created:** [April 20, 2019, 6:21pm UTC](https://discourse.julialang.org/t/method-forwarding-macro/23355 "2019-04-20T18:21:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [April 21, 2019, 1:35pm UTC](https://discourse.julialang.org/t/method-forwarding-macro/23355/5 "2019-04-21T13:35:58Z")

</div>

This also seems related to the feature proposal by @cscherrer that I implemented for [Reduce.jl](https://github.com/chakravala/Reduce.jl)

> [@Type constraints in Distributions and StatsFuns](https://discourse.julialang.org/t/type-constraints-in-distributions-and-statsfuns/22663/12):
>
> Alright, so I went ahead and [implemented](https://github.com/chakravala/Reduce.jl/commit/33f234cbc9560142b57f7bf95a8041dd0f91152f) the requested feature, which works on master branch julia\> Reduce.@subtype FakeReal \<: Real julia\> FakeReal(R"x+1") + FakeReal(R"y") y + 1 + x the implementation looks like this at the moment macro subtype(x) x.head ≠ :\<: && throw(error("$x is not a subtype expression")) name = x.args[1] Expr(:struct,false,x,Expr(:block,Expr(:(::), :r, :RExpr))) |\> eval @eval begin export $name show(io::IO, r::$name) = show(io,r.r) …

He also wanted a wrapper type which dispatches

Personally, I dont like to depend on MacroTools, and prefer writing custom code transformations.

---

_[View the full topic](https://discourse.julialang.org/t/method-forwarding-macro/23355)._
