News for hackers. Stuff that matters.
Re:The Next Step for Generics by ummonk on Wednesday June 17, 2020 @03:28AM (#23548784)
The Option type there isn't type safe. E.g. https://play.golang.org/p/CiQLf4yWhCO doesn't throw a type error for the Get function even though I've omitted the null check.
Re:The Next Step for Generics by Mawr on Wednesday June 17, 2020 @03:16PM (#23555508)
Sorry, but that's just ridiculous. Obviously the language can't prevent you from defining your Option type incorrectly. The point is that it's not possible to misuse it.
Re:The Next Step for Generics by ummonk on Wednesday June 17, 2020 @07:54PM (#23558251)
Okay let me rephrase. The type checker doesn't make sure you've checked the value of ok e.g. you can do this: https://play.golang.org/p/x18Rh2iwd2E

Go constantly requires boiler-plate checks for errors, null values etc. without the type checker helping ensure you've checked for an error or null value.