top | item 32770436

(no title)

37ef_ced3 | 3 years 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?

discuss

order

bilinguliar|3 years ago

In 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.