Re: [go-nuts] zero value for generic types?

2022-04-20 Thread Arthur Comte
Actually, even with proper error handling, I still need to return a value. In some functions I can just return a variable that was defined in the function, but that is not always available. In those cases, the only solution I've found is to use `*new(E)`, which seems plain terrible. Is there an alt

[go-nuts] zero value for generic types?

2022-04-20 Thread Arthur Comte
Hi! I was trying the following code, but it does not compile. How can I check if a generic value is its zero value. More broadly, can you explain where this issue comes from? ```go type MemoryRepository[E identifiable.Identifiable] struct { elements []E } func (repo MemoryRepository[E]) Find(I

[go-nuts] Why does Go not have intrinsic functions?

2022-04-07 Thread Arthur Comte
Intrinsic functions (functions that compile down to one hardware instruction) are common in (relatively) low-level languages. Go even supports embed ASM (though a weird flavour of it) Can someone explain why we do not have an intrinsic function package? This seems like it would greatly ease the