News for hackers. Stuff that matters.
Re:Is Go Duck-Typed? by tgv on Wednesday March 04, 2020 @03:27PM (#22487672)
Wouldn't that make any language with reflection Duck-typed? That would suggest Wikipedia's definition is not very useful.
Re:Is Go Duck-Typed? by loopz on Wednesday March 04, 2020 @03:34PM (#22487748)
Fair question!

"Duck typing" can be implicit, if you can call quack() on this() without error, you (the programmer) assume it's a Duck. The language may make it explicit (loosely structural typed like in golang, or other variations), or implicit (like in ruby). There are varying degrees, but you should be able to have a collection of the "Ducks" and be able to invoke quack() on them all.

Can't really say I see the connection with reflection. If quack() fails, you can get an error, either at runtime or compile-time. So no reflection required, though using reflection you may avoid errors dynamically.

Structural Typing as a concept is much better defined though.

Re:Is Go Duck-Typed? by abhorrence on Wednesday March 04, 2020 @04:26PM (#22488320)
Reflection isn’t required, but with sufficient reflection a language could essentially be extended to include duck typing.
Re:Is Go Duck-Typed? by lmm on Wednesday March 04, 2020 @07:16PM (#22489656)
No more than any language with casts is untyped. Reflection lets you avoid the type system and program in a duck-typed way, but unless the language uses reflection for normal values and functions then I wouldn't call the language duck typed as a whole.