Thanks for pointing out that section. I guess I'd forgotten this issue was
discussed there.

It looks like this exact approach (nil for all types) isn't listed there,
but there's a similar one that adds nil to just type variables. Please add
this one to your mental list! :)

Fair enough about the nil confusion, although perhaps the confusion stems
more from the invisible assignability of a "raw"/unconverted nil to various
types, rather than those types having a default/nil value. If Go went down
this path, perhaps the confusion could be ameliorated by changing how the
language spec introduces the idea of zero (now nil) values (by moving the
zero value [now nil] specification closer to, or within, the type section,
or something like that).

Thanks for your thoughts.

On Tue, May 31, 2022 at 6:19 PM Ian Lance Taylor <i...@golang.org> wrote:

> On Mon, May 30, 2022 at 6:39 PM Will Faught <w...@willfaught.com> wrote:
> >
> > Currently, if I understand correctly, there's no expression for the zero
> value for a type variable:
>
> Thanks for the note.  There is some discussion of this at
>
> https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#the-zero-value
> .
>
> > Why not allow nil to be used as the zero value for type variables, to
> fill this gap?
>
> We could do that.  The main concern is that "nil" is already
> overloaded, and people new to Go are frequently confused by it.  See
> the FAQ entry https://go.dev/doc/faq#nil_error .  Adding more uses of
> nil will increase the potential for confusion.
>
> Ian
>

-- 
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/CAKbcuKheQgiez30%2BBvTEP2AtZoDKzvHK_M6Kjhc1svwED8g0bQ%40mail.gmail.com.

Reply via email to