4 ms·
My understanding: In duck typing only the part of the structure/method set accessed is checked at run-time for compatibility, in structural typing everything is
by voidlogic 14y ago
My understanding: In duck typing only the part of the structure/method set accessed is checked at run-time for compatibility, in structural typing everything is checked at compile time (even if those checks follow loose duck-typing rules). To the programer they appear to be the same most of the time.
- rquantz 14y agoI'm not the least bit a Go programmer, but it sounds pretty different from a programmer's perspective to me. With duck typing your methods end up with conditional logic based around respond_to calls. With Go it seems like it's declarative. Whether you like that or not, you have to admit it's pretty different for the developer.
- deleted 14y ago[deleted]
- voidlogic 14y ago"Whether you like that or not, you have to admit it's pretty different for the developer" I don't really think that is true in Go.
- NateDad 14y agoYou never have to declare what fulfills an interface in Go. The fulfillment is implicit. If you define an interface with the Quack() method, anything with a Quack() method on it can be passed into a function that takes that interface, even if that object has never heard of the interface or the function. You never declare that a type "implements" an interface in the way you do for languages like C++ or Java.