jaysome said:
[snip]
If I were designing a new language from scratch, I'd probably use ":="
for assignment and "=" for equality.
Which is what Ada uses. Having used both Ada and C extensively, I
agree with you. Making such a change would break some code, but not in
a universal way. Some like to do this:
while ((EOF != (ch = getc(f))) && ('\n' != ch)) {
while others like to do this:
ch = getc(f);
while ( (ch != EOF) && (ch != '\n') )
{
One would break, one wouldn't.
I think you missed my point. I was talking using ":=" rather than "="
for assignment, and "=" rather than "==" for equality. Based on your
examples, I think you're talking not treating assignments as
expressions, but as a kind of statement (something Ada also does).
That change, assuming we keep the "=" symbol for assignment, would
break your first example but not your second.
For the record, I would strongly oppose making either change to C.
Making assignments illegal in expressions would break a great deal of
C source code that's currently perfectly valid; changing such code, in
addition to being a waste of time, would undoubtedly introduce bugs.
Making "=" denote equality rather than comparison would *quietly*
break almost every C program in existence; it would continue to
compile, but would stop working.
As I said, these are things I'd consider doing if I were designing a
new language from scratch. (Don't worry, folks, I don't have any
plans to do so.)
<OT>
Well, that's not *quite* true. I did invent the "99" language
for
www.99-bottles-of-beer.net.
</OT>