C bites Dog!

cottrell at nbs-vms.ARPA cottrell at nbs-vms.ARPA
Thu Aug 22 10:10:37 AEST 1985


/*
> > > ???:
> > > 		if (sv > score);   <----- note extraneous semi-colon
> > > 			score = sv;
> > Doug Gwyn:
> > This sort of thing makes me think that a few extra keywords
> > are called for programming languages like this.  E.g.
> > 	if <bool_expr> then <stmt> fi
> > 	while <bool_expr> do <stmt> od
> > Something to keep in mind when you design an Algol-like language.
> 
> ICK ICK ICK! I hate languages that do that. Ever considered using "cb" as a
> debugging tool? I have an MS-DOS version if anyone wants it...
> -- 
> 	Peter da Silva (the mad Australian werewolf)
> 		UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
> 		MCI: PDASILVA; CIS: 70216,1076

Dear Peter,

	Welcome to the `Let's Disagree with Doug' club! Unfortunately,
I am forced to agree with him here. CB (& INDENT) is A Good Thing,
but since I am such a wonderful coder (:-) I rarely use them. What they
really are useful for is importing code written by cretins. Also, I
probably disagree slightly with the output of those formatters. What
would you do, compare the output of `cb' with the original? Takes
lots of time & can be visually overlooked.

	Anyway, to get back to the point, you come to realize that in

		if <exp> then <stmt> else <stmt> fi

the parens around <exp> are unneccesary. And the `fi' makes sure that
all the elses nest with the correct `if'. The Bourne shell has the
following definitions, (which many peole dislike, but I think they're OK)

	#define	IF	if(
	#define THEN	){
	#define	ELSE	}else{
	#define	FI	}

The point is, you need at least 4 tokens (or a `one-statement' model)
to delimit the three parts of an `if' from each other and the outside.
C uses four (not counting semicolons)in the short form
(if (e) s1; else s2;) and eight in the long form
(if (e) { s1; } else { s2; }). And let's get rid of those semicolons 
too! A newline should imply one. Two statements on a line would need
an explicit one. An escaped newline would continue to the next line.
Yeah, I know, write my own language!

	jim		cottrell at nbs
*/
------



More information about the Comp.lang.c mailing list