I was surprised that you can't apply & to any value. I thought it was gut an ordinary operator and it would ensure that the value it was applied to would be put onto the heap.
s := S{}
sp := &s // Works
_ = sp
_ = &S{} // Works
i := int32(1)
ip := &i // Works!
_ = ip
_ = &int32(1) // Doesn't work!
It seems odd that you can't apply & to a function's return value. I think the best approach would be making & work in basically any scenario. For example the following also doesn't currently work.
&(int32(1) + int32(1))
It seems like it should be possible to "desugar" &X to `_tmp = X; &_tmp` and solve this weirdness.
It seems odd that you can't apply & to a function's return value. I think the best approach would be making & work in basically any scenario. For example the following also doesn't currently work.
It seems like it should be possible to "desugar" &X to `_tmp = X; &_tmp` and solve this weirdness.