Re: Revistiing using return value as reference
I think the only way to really say what influenced the C++ reference
would be to ask the designer himself.
I'm pretty sure this is explained in his "evolution" book, although I
don't have that book. You might also look in Bjarne's FAQ. I'm not
sure, but there's a good chance it's covered there too.
Hypothesizing that lang X or
lang Y which had a concept of 'pointer' or 'reference' as the main
motivation for the C++ reference is overlooking the 800 lb. gorilla
(who happens to have almost the same name except for those two plus
signs) and is by anyone's account a *huge* influence. How can a
servant be greater than his master?
Presumably you're talking about C.
The main motivation for C++ references was to support operator
overloading and more generally implementing types and functions on a par
with built-in types and functions.
As Doug McIlroy stated, quoted by Bjarne in TCPPPL, 'These types are not
"abstract"; they are as real as int and float' (e.g. associative array).
Now we use references more to avoid notational clutter and to express
the not-null assumption/requirement -- as so often happens, things
that are useful get used in other ways than originally conceived.
And for that reason we now see weaknesses in the original specification,
e.g., while references made it possible to make new types that behaved
like other built-in types, there's no corresponding mechanism to make
something behave like a reference, e.g. wrt. covariant function results.
Cheers, & hth.,
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
Q: What is the most annoying thing on usenet and in e-mail?