Discussion

Sign in or Join to comment or subscribe

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

Hi,

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,
Greg

2024-02-10T20:15:26Z ago

When David brought up the strangeness of slice append you missed a giant opportunity to get him to describe what that was to people listening, his insight there would have been a tremendously interesting take on it. Too bad that moment is lost.

Player art
  0:00 / 0:00