More context to extend @jakobnissen’s answer:
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.:
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 can also be used to facilitate using your new type in contexts were Foo
is used.