News for hackers. Stuff that matters.
Re:Things Go needs more than generics by tsimionescu on Monday October 04, 2021 @05:06AM (#28744632)
Yes, but still a and b are non-nil. My point was that Go is not like Java, where literally all non-primitive types are nullable.
Re:Things Go needs more than generics by maleldil on Monday October 04, 2021 @07:39AM (#28745421)
What if I want to pass a pointer into the function (maybe I want to mutate the object), but I want that pointer to be non-nil?

You make it seem like value types solve this problem, but they don't. C also has the same thing you're talking about, but it still has nullability problems.

I think other comments are not even asking for anything complex. Something akin to C++'s references (which cannot be null) would already be a step forward.

Re:Things Go needs more than generics by welder on Monday October 04, 2021 @11:02AM (#28747607)
I was only talking about pointers and interfaces, not primitive types. Yes A and B can't be nil, but I was only talking about C. Pointers (C) are what cause crashes in Go programs when using them without checking if they're nil first.