Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: net.lang Subject: Re: null statements Message-ID: <3188@utcsri.UUCP> Date: Tue, 29-Jul-86 00:24:58 EDT Article-I.D.: utcsri.3188 Posted: Tue Jul 29 00:24:58 1986 Date-Received: Tue, 29-Jul-86 00:42:20 EDT References: <800015@ccvaxa> <463@opus.nbires.UUCP> <442@sunybcs.UUCP> <484@valid.UUCP> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 53 Summary: In article <484@valid.UUCP> sbs@valid.UUCP (Steven Brian McKechnie Sargent) writes: >> Fine with me! I'd rather be able to write >> while ('\n' != getchar()) nothing; >> than >> while ('\n' != getchar()) /* do nothing */ ; > >I format null-body loops so: > while (getchar() != '\n') > ; >which fixes most of the "eyeball ambiguity." > Good stuff, I plan to decide on one of these practices and follow it. C has a danger inherent in the do..while loop, some people indent them as below: do{ /* a whole lotta stuff, many lines */ } while( foo_bar(*x++) != BLETCH ); Thus making it look like the last line is a null-bodied 'while'. I ( like most ) circumvent this by writing }while(...) at the end, and making the body a compound statement whether it needs it or not ( A loose 'do' is *scary*.... could get lost in there... bolt it to a '{' ) >The null statement problem is much worse in Pascal because there is no >explicit statement termination, only separation. So > > 1 IF complicated predicate involving several dozen apparently randomly > 2 selected expressions THEN > 3 {Attempt to do nothing innocuously}; > 4 ELSE BEGIN > 5 writeln('Read the code to find out what happened here.'); > 6 i := i/0; > 7 END; > >is a lose, lose, lose. That ; character on line 3 makes Mr. Pascal very sick. >You can replace it with the sequence BEGIN END, which looks a little stoopid Isn't there a null statement ""? I.e., can't you say IF .... THEN ELSE BEGIN ... END ??? ( i.e. just delete the ; on line 3. Sorry, can't find a reference ). PS: a Pascal teaching compiler I once used could come up with the message 'semicolon is never legal before ELSE'. Neat, huh? -- "You'll need more than a Tylenol if you don't tell me where my father is!" - The Ice Pirates ---------------------------------------------------------------------- Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg