From: Dave Horsfall <dave(a)horsfall.org>
This will probably get me tarred and feathered, but I
have a couple of
gripes about C
Your points are not about C's semantics, and only sort of about C's syntax;
they are more formatting. In fact, it would be really easy to write something
to switch a module betweeen your preferred formatting, and 'standard' (for
the local value of 'standard') formatting.
A minor comment about your first point. I was just reading some old code of
mine, and ran across a procedure declaration of the form:
foo(string, special)
char *string, special;
Your preferred form (_without_ changing C's _formal_ syntax) that puts the
indirection level with the type has the problems that i) it would make the
declaration above potentially confusing (unless one mentally edits the line
back to 'classic' C formatting as one reads it; is 'special' a
'char', or a
'pointer to char'; the 'classic' form is quite clear about that); ii)
one can
only list a single variable per line without changing C's syntax. E.g. (in
standard C) if you want to have two pointers declared on one line one would
have to say (in standard C):
char* ptra, *ptrb;
In short, there are good reasons to associate the indirection level with the
variable (standard C), and not with the type (yours). Although I gather that
you'd probably like to change C's formal syntax, to associate the indirection
level with the type, not with the variable. So one could say:
char* ptra, ptrb;
One could no longer, though, say:
char *string, special;
One change I would have made to C, in the past, was to add valof/resultis
(from BCPL; lacking in C). That's because C macros that return values _have_
to use _only_ expressions (e.g. ((expr0) ? expr1 : expr2)), not more complex
code like 'case' (which valof/resultis would let you do). Of course, modern
compilers do optimizations that make that a lot less necessary.
The thing I would still add to C is condition handling (although I have
written assembler packages that added a very efficient one to C without
changing the C language; and JTW and someone did a less capable one entirely
in C - mine had unwind protects).
Explaining why condition handlers are a good thing I don't have the
time/energy to do right now, but I can explain it if people want to hear it.
Noel