|> Alan Balmer wrote:
|> > On Thu, 27 May 2004 04:36:24 +0100, C# Learner <
[email protected]>
|> > wrote:
|> [...]
|> > Forgive me if I'm wrong, but my impression is that you don't have
|> > a deep enough understanding of the C language, and indeed of
|> > programming languages in general, to appreciate the reasons for
|> > the syntax features you're commenting on.
|> I believe that I appreciate the reasons for these features. What I'm
|> saying is that I think that there are better (in terms of allowing
|> the user of the language to write readable code) alternatives that
|> could have been implemented instead.
|> > Take your original example of eliminating the deli meters around
|> > the conditional in an if statement. Think about what this would
|> > mean for compound conditions. Combine that with the Python-style
|> > blocking and then think about an if statement which tests for
|> > several conditions, requiring more than one line to write.
|> a) Valid C syntax:
|> if (foo &&
|> bar) {
|> foobar();
|> }
|> b) Similar code to the above but using my suggested syntax changes:
|> if foo &&
|> bar:
|> foobar();
|> Why wouldn't (b) be feasible here?
|> Everything from 'if' to ':' is considered the condition.
Even if there is a ?: operator in the conditional expression?
|> After the newline after ':', whitespace is required to form a code
|> block.
Let's see, you want to overload on whitespace?
|> > As you study and understand the language, you'll find that it's
|> > all nicely consistent, and that there are good reasons for most of
|> > the features which seem odd to you.
|> The only way in which they seem odd to me is that they make code
|> much less readable than it could be, in my opinion.
Things like C's declaration syntax make code less readable. But you
didn't mention that. The preprocessor can be really effective in making
code less readable too, but you didn't mention that either. And of
course, all those funny characters really made code less readable back
in the days when I had to work with an ISO 646 terminal -- in the German
variant.
But you seem to be attacking areas where C basically has no serious
problems. I personally prefer something like:
if expr then
stmt_list
else
stmt_list
endif
but the alternative used by C is pretty acceptable too. (And my
preference may have been conditioned by the ISO 646 terminals above.
Things like:
if ( expr ) ä
stmt_list
ü else ä
stmt_list
ü
are not particularly readable.)
|> Okay, if you don't agree with the 'if'..':' idea, then how about
|> changing the parentheses required for test conditions for a
|> different pair of characters? An ideal pair would be a pair that
|> isn't used elsewhere in the language, for readability's sake.
|> > One of the characteristics of C is terseness, and extra parens
|> > aren't required by the language for no reason.
|> My point is that a different construct could be substituted in each
|> case.
|> > Also, think about the fact that language inventors and
|> > implementers are, by and large, a pretty bright bunch. In general,
|> > they probably have more and wider experience in the field than you
|> > do, and some of them might even be as smart ;-)
Let's not get carried away. Language designers don't work in a vacuum,
and C is like it is for a variety of historical reasons.
|> So those who invented C's syntax are necessarily brighter than those
|> who invented, say, Python's syntax?
They were certainly working in a different context. I don't know
Python, so I can't say, but from the little you've shown, my impression
is that it is something that works well for quick hacks, but doesn't
scale well.
|> > Those features which have passed through to modern languages have
|> > done so for a reason.
|> I honestly wonder what that reason is.
They work.