Hacker News new | ask | show | jobs
by raverbashing 4236 days ago
Like duck typing?
1 comments

I suspect this is like duck typing with some verification before compilation : the compiler checks that the object sent as parameter implements the correct interface.
It's called structural typing.
So, compile-time duck typing.
So, wikipedia says (http://en.wikipedia.org/wiki/Duck_typing#Structural_type_sys...):

"Duck typing is similar to but distinct from structural typing. Structural typing is a static typing system that determines type compatibility and equivalence by a type's structure, whereas duck typing is dynamic and determines type compatibility by only that part of a type's structure that is accessed during run time."

So it sounds like "duck typing" is defined in terms of run-time semantics. I guess you might be able to have genuine "compile-time duck typing" in a dependently typed language, which could be a good reason to preserve the distinction.

Otherwise, yes, they are certainly similar.

In the same Formula 1 is performance go-karting.
No, structural typing. It has a name already.