Is Go Duck-Typed?
bionic.fullstory.com
Is Go Duck-Typed?
1–10 of 89 posts
Re: Is Go Duck-Typed?
#2Re: Is Go Duck-Typed?
#3Re: Is Go Duck-Typed?
#4Re: Is Go Duck-Typed?
#5This is called Structural Typing[0] and is in contrast to Nominal Typing[1] (e.g. Java). 0: https://en.wikipedia.org/wiki/Structural_type_system 1: https://en.wikipedia.org/wiki/Nominal_type_system
Re: Is Go Duck-Typed?
#6Re: Is Go Duck-Typed?
#7How frequent are problems where classes unintentionally use an interface due to identical signatures? Seems likely to happen in theory if so many interfaces have few functions.
Re: Is Go Duck-Typed?
#8This is called Structural Typing[0] and is in contrast to Nominal Typing[1] (e.g. Java). 0: https://en.wikipedia.org/wiki/Structural_type_system 1: https://en.wikipedia.org/wiki/Nominal_type_system
Interestingly, python has included structural subtyping in 3.8[1] as part of the typing module.
Re: Is Go Duck-Typed?
#9I like the histogram showing how much more frequent interfaces with just one or two methods are. How frequent are problems where classes unintentionally use an interface due to identical signatures? Seems likely to happen in theory if so many interfaces have few functions.
func InsertFoo(*sqlx.DB, Foo) (int64, error)
are very unlikely to be unintentionally implemented.Re: Is Go Duck-Typed?
#10I like to call it Quack typing as interfaces are based on behavior and not attributes.