ask about when to use pointer to a value type in argument and function return type
Now my question is that when we use pointer to value type inside structures (in composition or embedding) ?
This is my decision tree: Is the constructor/function returning the value of that value only returning pointers: yes is it an any type: yes is the value independent from the structure: yes everything else: no
Can i dm u plz ?
My question is Type mytype struct { A T } When can T should be a reference type ?
When you want one
The problem is that in language like go that has gc We dont need (i think) In c or cpp i can understand why u need but here i have no idea
same things apply in Go mostly
Even in go creating instances is costly. Zerolog for example uses an pool of builders to reduce the overhead of creating the builders.
Обсуждают сегодня