C bites / programming style
Reid Spencer
reid at unitek.uucp
Thu Sep 12 08:17:23 AEST 1985
In article <1370 at brl-tgr.ARPA> DHowell.ES at XEROX.ARPA writes:
>Personally, I don't really like the {} braces of C, nor the "begin..end"
>of Pascal and its relatives. This is one thing that Ada has going for
>it with its "if..then..endif" style.
>
>I like to use these definitions:
>
>#define IF if(
>#define THEN ){
>#define ELSE }else{
>#define ENDIF }
>
>Then I can write
>
>...
>IF condition THEN
> statement_1
>ELSE
> statement_2
>ENDIF
>...
>
>Which I think is much cleaner than anything using braces or begin..end.
>(Gee, I should write my own language)
>
>Dan <DHowell.ES at Xerox.ARPA>
>
>Disclaimer: I'm having a hard time finding anyone who has my opinions
>besides me.
Hey, don't get so down on yourself. I'm in favour of what you have
suggested. How about the following:
#define cycle for(;;) {
#define endcycle }
#define then {
#define otherwise } else {
#define elseif } else if
#define endif }
#define exitwhen(exp) if (exp) break;
#define exitunless(exp) if (!(exp)) break;
We can then write
cycle
exitwhen(cond1)
if (cond2) then
stuff1
elseif (cond3) then
stuff2
otherwise
stuff3
endif
endcycle
More information about the Comp.lang.c
mailing list