It’s common to wonder, “Why
just scopes and argument lists? Why not return values?” It seems at first
that it would make sense to also decorate the return value with the internal
function name. Then you could overload on return
values, as
well:
This works fine when the compiler can
unequivocally determine the meaning from the context, as in int x =
f( );. However, in C you’ve always been able to call a
function and ignore the return value (that is, you can
call the function for its side effects). How can the compiler distinguish
which call is meant in this case? Possibly worse is the difficulty the reader
has in knowing which function call is meant. Overloading solely on return value
is a bit too subtle, and thus isn’t allowed in
C++.