Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!ut-sally!pyramid!pesnta!valid!sbs From: sbs@valid.UUCP (Steven Brian McKechnie Sargent) Newsgroups: net.lang Subject: Re: null statements Message-ID: <484@valid.UUCP> Date: Wed, 23-Jul-86 02:09:54 EDT Article-I.D.: valid.484 Posted: Wed Jul 23 02:09:54 1986 Date-Received: Thu, 24-Jul-86 00:18:51 EDT References: <800015@ccvaxa> <463@opus.nbires.UUCP> <442@sunybcs.UUCP> Organization: Valid Logic, San Jose, CA Lines: 46 > > So to get the effect equivalent to "zero" out of the null statement, do we > > invent some sort of "positional notation" for statements?!?! > Fine with me! I'd rather be able to write > while ('\n' != getchar()) nothing; > than > while ('\n' != getchar()) /* do nothing */ ; > -- > Col. G. L. Sicherman > UU: ...{rocksvax|decvax}!sunybcs!colonel > CS: colonel@buffalo-cs > BI: csdsicher@sunyabva Only a barbarian or Obfuscated C Contest winner would champion the use of #define nothing /* do nothing */ but I figured I'd mention it anyway. I format null-body loops so: while (getchar() != '\n') ; which fixes most of the "eyeball ambiguity." 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 but gets the job done. In Berkeley Pascal we had an explicit "null" statement that did what you want with no muss & no fuss: it worked anywhere that the sequence BEGIN ... END did. I sort of like the Modula-2 convention of tagging everything with an END. It makes programs chattier than they need to be but it seems to get the point across. Actually, the Algol/UNIX Shell convention of if...endif, do...done, case...esac is best of all, because you can read the code forwards OR backwards... S.