3 ms·
It is strong, static, and structural. But structural typing is effectively compile-time duck typing, so it is understandable that some might confuse it with dyn
by 9rx 2y ago
It is strong, static, and structural. But structural typing is effectively compile-time duck typing, so it is understandable that some might confuse it with dynamic typing.
- masklinn 2y agoGgp is not talking about structural typing, but about sync.Pool type erasing (it takes `any` values, and returns `any` values). So you can put (and will retrieve) random garbage from it.
- 9rx 2y ago> Ggp is not talking about structural typing, Okay... but the reply was to the parent who questioned if the typing is static. It is by way of structural typing. The compiler enforces that the ducks, so to speak, are compatible. But as an empty interface has no constraints, all types are compatible. Whatever some other comment was talking about is irrelevant. > but about sync.Pool type erasing The type isn't erased...? p := sync.Pool{New: func() interface{} { return 1 }} fmt.Printf("%T", p.Get()) // Prints: int > So you can put (and will retrieve) random garbage from it. And you think that makes it dynamically typed? It does not.