https://en.wikipedia.org/wiki/Duck_typing
After reading the page I was left with the question of isn't that dynamic inheritance? The seems like dynamic runtime.
https://en.wikipedia.org/wiki/Duck_typing
After reading the page I was left with the question of isn't that dynamic inheritance? The seems like dynamic runtime.
In contrast, many languages require you to describe the shape up-front, and then constrain `foo` to implement that shape. For instance, in Rust we would have to write something like `trait Bar { fn bar(a: u32, b: 32); }`, and then say something like `foo: T where T: Bar`, before we're allowed to call the `bar` method.
Both are compile-time safe, but one requires more ceremony (but is more explicit), while the other is simpler (but you might have to guess the requirements).
Duck-typing can be implemented with static checks, and doesn't require inheritance to be involved at all.
The dynamically typed version is dynamic inheritance, or really just dynamic attribute lookup.
The statically typed version is "generic programming" with templates. See for example the way that C++ standard library sort works.