When a function returns multiple values in go, what's the memory representation of those multiple values when returned?
-
4What do you mean by 'memory representation'?Grzegorz Żur– Grzegorz Żur2018-01-13 20:15:21 +00:00Commented Jan 13, 2018 at 20:15
-
@GrzegorzŻur this is actually a good question, asking about how are multiple values represented in memory - stored in registers, or on stack, or allocate memory on heap,...kravemir– kravemir2020-08-13 11:08:31 +00:00Commented Aug 13, 2020 at 11:08
Add a comment
|
1 Answer
What it sounds like you're looking for is the stack frame design of Go. I'm not going into the details here, but you may find it helpful to read about it here.
In general the compiler can place multiple returns on the out space for the function call. Think an array as a result. The compiler then knows how to access the space on the stack for the subsequent caller.