4 ms·
What you're describing is structural typing, and it doesn't have to be dynamic. Look at OCaml and its object model to see an example of a statically typed syste
by int_19h 7y ago
What you're describing is structural typing, and it doesn't have to be dynamic. Look at OCaml and its object model to see an example of a statically typed system with automatic type inference, that nevertheless checks all these things at compile-time. Which is to say, you can write:
let frob something = something#run ...
and it will enforce the fact that whatever is passed to frob, it must have a method named "run", and it must have the requisite number of arguments and their types.
The types are still there, though. They're just types like, "some object with method "run" with ...".