On Dec 11, 10:16 pm, konrad <
kzielin...@gmail.com> wrote:
> This is the curcial difference in an Object oriented system the
> receiver of a method would be the outer type. Gerally you would only
> see this clearly if you do try to override a method. Your overriding
> implementation will be visible to methods on the outside but will not
> be visible from methods in the contained type (which in an OO system
> would be the super class).
What you're missing is that you can embed an interface representing
the highest level struct (the "subtype" to apply the term loosely) and
call its methods. The only problem with this is that you need to know
beforehand what methods any intermediate struct is going to want to
call on the highest level struct, and all of your highest level
structs have to fully implement that interface. Really, you're not
building a class-style hierarchy. You're building a set of structs
that implement an interface with shared code.
And once you start thinking of it this way, you might start deciding
to use methods to wrap package functions, and define (sets of)
closures to embed into your types with accessor methods. Then you
realize that your inheritance hierarchy isn't really as essential as
you thought it was.