4 ms·
Well, in the link that you shared, Tony Hoare explains in quite some detail why having support for null pointers is not great. Additionally, a *Vec3 is more th
by simiones 5y ago
Well, in the link that you shared, Tony Hoare explains in quite some detail why having support for null pointers is not great.
Additionally, a *Vec3 is more than `Vec3` or `null`. For example, the following code will behave very differently based on whether optionalVec is Vec3 or *Vec3.
optionalVec := Vec3{0, 0, 0}
foo(optionalVec)
fmt.Printf("theVec: %+v", optionalVec)
// would print {0, 0, 0} with an Optional[Vec3] type
// will actually print {2, 0, 0} with *Vec3
...
func foo(optionalVec *Vec3) {
if optionalVec != nil {
optionalVec.x += 2 //we use a different origin
}
[...]
}