Is it possible to somehow refer to the value I am returning from a function? An example explains better:
CFTypeRef foo()
{
CFTypeRef valueRef = NULL;
bar(&valueRef); // fills valueRef with some data
return valueRef;
}
I thought it would be nice to rewrite this as:
CFTypeRef foo()
{
bar(&__retvalue);
}
Where of course __retvalue would be some magical token. Does this make sense? Is it possible to do that? If not, why?
a) It makes sense. b) There is no such magic token. c) The “If not, why”? question is just bizarre … Why isn’t there such a magic token? Because the language designers never thought of it or, thinking of it, didn’t think it was a good thing to add to the language. (Someone mentioned that the return value is usually held in a register but that’s irrelevant; the compiler could generate code to load that register from an in-memory variable, exactly as happens in your current foo).