Re:Golang generics proposal has been accepted
by andreygrehov on Thursday February 11, 2021 @01:12PM
(#26105067)
What do you mean by implicit nullability? Go doesn't have it. A pointer can be nil, which is obvious, but a regular string or int, or even a struct type cannot be nil (unless it's a pointer).
[ Parent
| on HN ]
Re:Golang generics proposal has been accepted
by dragonwriter on Thursday February 11, 2021 @01:14PM
(#26105091)
> A pointer can be nil, which is obvious
It's certainly common, but of the things which would be useful to be able to constrain only to allow explicit and non-default nillability, pointers are pretty high on the list.
Re:Golang generics proposal has been accepted
by andreygrehov on Thursday February 11, 2021 @01:25PM
(#26105231)
What would be a better design?
Re:Golang generics proposal has been accepted
by dragonwriter on Thursday February 11, 2021 @02:36PM
(#26106063)
Statically requiring a (the default case) non-nillable pointer to be assigned to a non-nil value (presumably, ultimately as a result of an operation that fails if it can't allocate, or one that either fails or returns a non-nil pointer when passed a nillable pointer) before being used?
The same thing as is done for any other non-nullable value in static type systems.