1

When a function returns multiple values in go, what's the memory representation of those multiple values when returned?

2
  • 4
    What do you mean by 'memory representation'? Commented 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,... Commented Aug 13, 2020 at 11:08

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.