5 ms·
Are you seriously suggesting that the language should not have notation for allocating zeroed primitive types and receiving the address of the allocation? va
by 37ef_ced3 4y ago
Are you seriously suggesting that the language should not have notation for allocating zeroed primitive types and receiving the address of the allocation?
var (
p1 = new(int)
p2 = new(*int)
p3 = new(**int)
p4 = new(complex64)
p5 = new(complex128)
)
I feel like you must be joking. Should we say
var (
c complex128
p = &c
)
every time?
- bilinguliar 4y agoIn five years, I needed to do the latter only once or twice because a library I was using demanded a pointer to a primitive. Forgive my arrogance, but why does one need a pointer to a zero-value primitive in Go? I sincerely believe there is a use case for it, but I never needed this.
- deleted 4y ago[deleted]