it's weird how easy it is to contact this guy. you would think the creator of c++ would be too busy for answering e-mail personally.
anyway, here's my email conversation: (sorry for doubting you, dean)
my original message to him:
his response:hello
i've been thinking about the development of c. on a small scale, in mostly
integer programs, the x86 assembly program and its equivalent c program match
each other closely. for instance:
test.c:
int main() {
int x;
x = 1;
return x+3;
}
test.asm:
enter 0,0
xor eax,eax
add eax,3
leave
ret
this is not the best example, but demonstrates the close link of c operators
to assembly commands. other examples:
dest += src; and add dest,src
++dest; and inc dest;
C++ differs from this line of thinking. for instance, the scanf function must
take in variables with reference operators attached to them. the scanf
function then uses that address to return values back. c++ introduces the
ability to use the same variables through other child functions without the
need for reference operators.
void example(int& x);
this makes a potential scanf in c++ more elegant to use, and to create. my
point is that this seemingly easy to implement idea is neglected in C but
added in C++ on the basis of its relationship to the equivalent assembly
language commands.
what do you think? thank you for your time.
--(name withheld from you guys, my name goes here)
my response:>Delivered-To: [email protected]
>X-Authentication-Warning: mail-red.research.att.com: postfixfilter set sender
to [email protected] using -f
>Date: Tue, 03 Sep 2002 00:46:40 -0400
>From: g s <[email protected]>
>To: <[email protected]>
>Subject: x86 assembly, c, and c++
>Mime-Version: 1.0
>X-Spam-Status: No, hits=0.0 required=5.0 tests= version=2.20
>X-Spam-Level:
>Content-Transfer-Encoding: 8bit
>X-MIME-Autoconverted: from quoted-printable to 8bit by day.research.att.com id
g834knE01062
>
>hello
>i've been thinking about the development of c. on a small scale, in mostly
>integer programs, the x86 assembly program and its equivalent c program match
>each other closely. for instance:
>
>test.c:
>int main() {
> int x;
> x = 1;
>
> return x+3;
>}
>
>test.asm:
>enter 0,0
>xor eax,eax
>add eax,3
>leave
>ret
>
>
>this is not the best example, but demonstrates the close link of c operators
>to assembly commands. other examples:
>dest += src; and add dest,src
>++dest; and inc dest;
>
>C++ differs from this line of thinking.
Not really. The code generated for individual C++ constructs are as predictable
as that generated from C constructs.
>for instance, the scanf function must
>take in variables with reference operators attached to them. the scanf
>function then uses that address to return values back. c++ introduces the
>ability to use the same variables through other child functions without the
>need for reference operators.
>
>void example(int& x);
>
>this makes a potential scanf in c++ more elegant to use, and to create. my
>point is that this seemingly easy to implement idea is neglected in C but
>added in C++ on the basis of its relationship to the equivalent assembly
>language commands.
>
>what do you think? thank you for your time.
Remember that access through a reference will involve exactly the same machine
operations as access through a pointer for equivalent uses.
>--(name withheld)
>
- Bjarne
Bjarne Stroustrup, http://www.research.att.com/~bsAnd his response to that:>>for instance, the scanf function must
>>take in variables with reference operators attached to them. the scanf
>>function then uses that address to return values back. c++ introduces >the
>>ability to use the same variables through other child functions without
>the
>>need for reference operators.
>>
>>void example(int& x);
>>
>>this makes a potential scanf in c++ more elegant to use, and to create. my
>>point is that this seemingly easy to implement idea is neglected in C but
>>added in C++ on the basis of its relationship to the equivalent assembly
>>language commands.
>>
>>what do you think? thank you for your time.
>
>Remember that access through a reference will involve exactly the same
>machine
>operations as access through a pointer for equivalent uses.
why wasn't this syntax included in standard c? in the development of c++ was
this idea just some additional syntactic sugar, or was it put there for a
greater purpose? (by greater purpose i mean does it contribute to c++'s other
major improvements?)
--(name withheld)
>Delivered-To: [email protected]
>X-Authentication-Warning: mail-pink.research.att.com: postfixfilter set sender
to [email protected] using -f
>Date: Tue, 03 Sep 2002 18:07:54 -0400
>From: g s <[email protected]>
>To: Bjarne Stroustrup <[email protected]>
>Subject: Re: [Re: x86 assembly, c, and c++]
>Mime-Version: 1.0
>X-Spam-Status: No, hits=0.0 required=5.0 tests= version=2.20
>X-Spam-Level:
>Content-Transfer-Encoding: 8bit
>X-MIME-Autoconverted: from quoted-printable to 8bit by day.research.att.com id
g841uWE10188
>
>
>>>for instance, the scanf function must
>>>take in variables with reference operators attached to them. the scanf
>>>function then uses that address to return values back. c++ introduces >the
>>>ability to use the same variables through other child functions without
>>the
>>>need for reference operators.
>>>
>>>void example(int& x);
>>>
>>>this makes a potential scanf in c++ more elegant to use, and to create. my
>>>point is that this seemingly easy to implement idea is neglected in C but
>>>added in C++ on the basis of its relationship to the equivalent assembly
>>>language commands.
>>>
>>>what do you think? thank you for your time.
>>
>>Remember that access through a reference will involve exactly the same
>>machine
>>operations as access through a pointer for equivalent uses.
>
>why wasn't this syntax included in standard c? in the development of c++ was
>this idea just some additional syntactic sugar, or was it put there for a
>greater purpose? (by greater purpose i mean does it contribute to c++'s other
>major improvements?)
The key need that led to the introduction of references in C++ was the need to
provide efficient implementation of overloading. If a and b are matrices, you
want a+b to pass pointers/references to a and b to the addition operator - not
copying the large objects, and requiring explicit use of address-of would
distract from conventional notation (i.e. &a+&b is unacceptably ugly).
For more information, see "The Design and Evolution of C++"
>--(name withheld)
>
- Bjarne
Bjarne Stroustrup, http://www.research.att.com/~bs