| ▲ | 9rx 4 days ago | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> This seems to be a persistent source of confusion. Why? It is the same as in C. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | simiones 4 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The point the GP was making was that the following Go snippet:
Could translate to C either as:
Or as
Depending on the content of //SNIP. However, some people think that the semantics can also match the semantics of the second version in C - when in fact the semantics of the Go code always match the first version, even when the actual implementation is the second version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | foldr 4 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
What confuses people is
vs.
They think that Go, like C, will allocate x on the stack, and that returning a pointer to the value will therefore be invalid.(Pedants: I'm aware that the official distinction in C is between automatic and non-automatic storage.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||