Returning large structs by value

I understand that zig encourages to not pass *const parameters to functions, but does the same apply for returning structs? If I don´t modify the object, might the compiler generate something equivalent to returning a const reference in c++?

Let me clarify: returning a large struct that is backed up in memory somewhere, so that returning a pointer instead would be ok!

You’ll be interested in this:

and also this:

1 Like