On Tue, Mar 19, 2024 at 11:44 AM Daniel Lepage <dplep...@gmail.com> wrote:

> I'm not proposing that *any* value be made nillable, I'm proposing the
> explicit syntax
>
> var x uint8 | nil
>
> that would create a nillable uint8. A variable of type `byte` would still
> only take up one byte; a variable of type `byte | nil` would be larger.
> Existing code, which obviously doesn't use the `| nil` syntax because it
> doesn't exist yet, would be completely unaffected by this change.
>

Any such proposal would have to specify how this interacts with types that
are already nillable. Consider

var p *int | nil
p = nil

Does this make p "unset"? Does it set p to *int(nil)? How can subsequent
code distinguish between the cases where p is unset and p has the value
*int(nil)?

Also, given

var a any | nil

are there  _three_ different ways in which a can be nil (a is unset,
any(nil), or, say, *int(nil))? People are already confused by having two
different ways for interface values to be nil.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAADvV_vWZD6cmNY%2BFX4aU-_XRYNBHBgnRCoNyn_21DOz-9zVnQ%40mail.gmail.com.

Reply via email to