Sign in or Join to comment or subscribe

2023-08-11T21:21:01Z ago


When Dave was talking about keeping things returned by functions on the stack, he mentioned Java, but in C++ there’s a thing called RVO (return value optimization which is a form copy elision) that basically does this. There it’s about locally created values while in Go it would also be about pointers to local variables but I have a feeling that it would also be possible: allocate the local variable on the caller’s stack and return the pointer to that location. Of course, this only works when the creation happens as the last operation in that function but this is exactly what’s typically done in a Go “constructor” (a New* function). I would be really interested in hearing his view on this and whether this was considered by committee.

This was a great episode, thanks.

All the best,

Player art
  0:00 / 0:00