News for hackers. Stuff that matters.
Re:Is Go Duck-Typed? by zaphar on Wednesday March 04, 2020 @07:23PM (#22489720)
In practice if your 'id() string' method returns an id as a string for the object doesn't it do what you need it to? So you actually need to care whether the intended to satisfy your contract or not?

You might care if you expect the Id string to look a particular way. But then you probably wanted to use a type other than string for the return type.

Re:Is Go Duck-Typed? by mrkeen on Saturday March 07, 2020 @11:21AM (#22512324)
> you probably wanted to use a type other than string for the return type.

That's the point. In order for (String userId) to not be confused with (String password), I wrap them with nominal types UserId and Password.

If the language looks at both UserId and Password and decides they're interchangeable because they both satisfy the contract 'contain a String', then that completely negates the point.