4 ms·
I suspect this is like duck typing with some verification before compilation : the compiler checks that the object sent as parameter implements the correct inte
by LBarret 12y ago
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.
- diroussel 12y agoIt's called structural typing.
- kaoD 12y agoSo, compile-time duck typing.
- tel 12y agoIn the same Formula 1 is performance go-karting.
- coldtea 12y agoNo, structural typing. It has a name already.
- dllthomas 12y agoSo, wikipedia says (http://en.wikipedia.org/wiki/Duck_typing#Structural_type_systems 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.