> Is this not literally the distinction between an interface and an implementation?
No. e.g. Java interfaces are just as nominal as classes.
> But are test mocks and stubs not literally the prime use case for interfaces at the syntax level?
Also no. If your language has structural interfaces it is often preferred to inheritance as a tool for polymorphism. Even in C++ where templates are not the easiest tool to wield it's often still preferable to inheritance for many reasons.
What? No. The author has a Duck, which has a quack() method. The quack() method is, presumably, identified by its name, argument types, and return type. Even in a language with purely nominal typing, you would make a Quacker interface, which is the set of things that quack() -> None, and then have both Duck and all of its test stubs be Quackers.
This is very literally how people who write in languages without structural types do test stubs (and often dependency injection, and other mechanisms that need to select from among several implementations of something).
Alright, I guess I don't know what you mean by "prime use case" then. Yes, you can use interfaces to make test doubles. No, that's not the historically motivating factor behind their inclusion in languages.
Like, we all know about the expression problem and how interfaces are hard to modify after the fact...
But are test mocks and stubs not literally the prime use case for interfaces at the syntax level?