Anonymous types

Julia isn’t huge(*) on using super-types (or anything else) as interfaces to say what methods something has available, in contrast to static ahead of time compiled languages with static types, like Java or Haskell.
Because being a JITed language type-checking in advance isn’t possible, except as a optional “linting” step (JET.jl does do that); and being dynamic it isn’t certain to be covering all cases (so value decreased).

Mostly types are used for dispatch.
And everything else can be left to duck-typing.
So like unless you had a second Interface2 in your example, that defined x or y or foo differently, then those type constraints are not need.
and thus making Impl1 and Impl2 subtype Interface is not needed.
Similarly, having anon types implement the Interface is not needed.

(* It’s not a never, e.g. AbstractArray is a good example. which provided many methods. Particularly good as it has fast dispatches that would otherwise fallback to methods that would work on ducktyped generic iterators)

1 Like