[comp.lang.c] Changing language syntax

wirzenius@cc.helsinki.fi (Lars Wirzenius) (03/29/91)

In article <1991Mar28.004147.705@worf.harvard.edu>, dmm@cfa.harvard.edu (David Meleedy) writes:
> I would like to respond to the view that statements such as
> #define EQU ==
> are to be avoided.
> 
> I disagree entirely.  One of the well known conventions in C is that anything
> in all capital letters is defined in a define statement.  It is the
> responsibility of the programmer to know to look up and see what various
> defines are.

Not everything in upper case is defines, they might be typedefs or enum
values as well. But this isn't why I disagree with you, the real reason
is that not only humans and compilers read code, but other programs too,
and it isn't good to require all of them to incorporate most of a
compilers parsing phase. 

Another reason is that each time you read a program that uses defines to
change the syntax of the language, you need to learn a new language.
This is true even if you do your best to imitate Pascal, not everyone
knows Pascal and even if they do, you can't imitate it closely enough
with the C preprocessor. Besides, if you want Pascal, you know where to
find it (quoting someone, I think).

> unnecessary.  The time it takes to debug a program that has 1 equal instead of
> 2 in an if statement does not justify the minisule effort required to 
> understand that EQU is equivalent to ==.  

I very much suspect that learning all the defines (however well
documented) isn't a minuscule effort, especially if you need to do it
for every program.

> admittedly it's not perfect pascal, but it is certainly readable and
> understandable.

I happen to find the C version more readable and understandable, so I
prefer that. Of course, you're free to abuse the preprocessor in any way
you want, but that isn't going to make me look at your programs in a
more favourable way. If you don't like C, use some other language, don't
make C look a bit like it.

-- 
Lars Wirzenius    wirzenius@cc.helsinki.fi