Thanks. I think these are more complicated and less consistent, since they
require adding syntax for `_`, but I can see a similar motivation.
On Sun, Jun 5, 2022 at 9:44 PM Nigel Tao wrote:
> On Tue, May 31, 2022 at 1:39 AM Will Faught wrote:
>
>> Why not allow nil to be used as the zero value
On Tue, May 31, 2022 at 1:39 AM Will Faught wrote:
> Why not allow nil to be used as the zero value for type variables, to fill
> this gap?
>
> return nil // == V(nil)
>
See also:
https://github.com/golang/go/issues/35966
https://github.com/golang/go/issues/19642
--
You received this message
This is increasingly off-topic (I don't have anything to add to the
on-topic stuff itself), but.
On Thu, Jun 2, 2022 at 11:03 AM Brian Candler wrote:
> I wonder then why slice wasn't defined the same way - i.e. the zero value
> of a slice could have been "empty slice". Today, empty slice and
On Wednesday, 1 June 2022 at 08:49:50 UTC+1 axel.wa...@googlemail.com wrote:
> Where confusion might arise is in the operations on nil. It's already
>> weird that nil slices and zero-length slices are distinguishable:
>> https://go.dev/play/p/6MVECg4onAk
>>
>> We'd then end up in the same
On Wed, Jun 1, 2022 at 9:05 AM Brian Candler wrote:
> On Wednesday, 1 June 2022 at 02:19:43 UTC+1 Ian Lance Taylor wrote:
>
>> 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
On Wednesday, 1 June 2022 at 02:19:43 UTC+1 Ian Lance Taylor wrote:
> 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
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
On Mon, May 30, 2022 at 6:39 PM Will Faught 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
Right, I discussed that:
Currently, if I understand correctly, the only way to do this is to declare
> a variable, and return that:
> var zeroValue V
> return zeroValue
On Mon, May 30, 2022 at 7:33 PM Bruno Albuquerque wrote:
> This should work on your example:
>
> var zeroValue V
>
> On Mon,
This should work on your example:
var zeroValue V
On Mon, May 30, 2022, 6:39 PM Will Faught wrote:
> Hello, fellow Gophers!
>
> Currently, if I understand correctly, there's no expression for the zero
> value for a type variable:
>
> type Map[K comparable, V any] struct {
> ks []K
> vs
Hello, fellow Gophers!
Currently, if I understand correctly, there's no expression for the zero
value for a type variable:
type Map[K comparable, V any] struct {
ks []K
vs []V
}
func (m Map[K, V]) Get(k K) V {
for i, k2 := range m.ks {
if k2 == k {
return m.vs[i]
11 matches
Mail list logo