# Supertype in Julia

**URL:** https://discourse.julialang.org/t/supertype-in-julia/88930
**Category:** New to Julia
**Tags:** type
**Created:** [October 18, 2022, 7:50pm UTC](https://discourse.julialang.org/t/supertype-in-julia/88930 "2022-10-18T19:50:22Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [October 18, 2022, 8:48pm UTC](https://discourse.julialang.org/t/supertype-in-julia/88930/3 "2022-10-18T20:48:33Z")

</div>

More context to extend @jakobnissen’s answer:

> [@Why is it impossible to subtype a struct?](https://discourse.julialang.org/t/why-is-it-impossible-to-subtype-a-struct/19876/3):
>
> Multiple inheritance is a totally different story and could be allowed. I’ve written about why we don’t allow subtyping of concrete types before if someone wants to dig up one of my earlier posts about it. Edit: here’s a link to an old google groups conversation about it [https://groups.google.com/d/msg/julia-dev/eA4VkFAD-yQ/LNUP\_OT0zy0J](https://groups.google.com/d/msg/julia-dev/eA4VkFAD-yQ/LNUP_OT0zy0J) In particular, this paragraph from the end of my first post on the thread sums up my position fairly well still: While there are a number of practical reaso…

Nevertheless, depending on how you want to build on `Foo`, it might be possible to create other types that, without being subtypes of `Foo`, compose with it, e.g.:

```julia
struct AnotherType
   foo::Foo
   # and other things, maybe
end

bar(x::AnotherType) = bar(x.foo)

```

If there are other methods that you want to extend, you should repeat this for all of them, though, perhaps using metaprogramming to avoid repeating a lot of code.

[Conversion and promotion](https://docs.julialang.org/en/v1/manual/conversion-and-promotion/) can also be used to facilitate using your new type in contexts were `Foo` is used.

---

_[View the full topic](https://discourse.julialang.org/t/supertype-in-julia/88930)._
