sommar@enea.se (Erland Sommarskog) (12/18/88)
Alan M. Carroll (carroll@s.cs.uiuc.edu) writes: >I always thought that the 'no ; before END' part of PASCAL was one of the worst >'features' of the language. I can't count how many times I had to recompile >because I had added a statement before an END and forgotten to put a ; on >the *previous* statement. Having to remember 'put a ; at the end of a statement >*unless* it's just before an END, in which case you put it on the end of >the previous statement' is for me much harder than 'put a ; at the end of >a statement', as in C. I don't like non-local syntax changes like that. Not that I think that the Pascal approach is that fantastic, but is there a problem? You are not prohibited to put a semicolon before your END. When I was taught Pascal, and later taught my younger fellow-students, omitting semicolons before END was strongly dis- couraged. (And most people was unaware of that you could do it at all.) On the other hand, much of what you say, could well be applied to the "; ELSE" problem instead. On the talk of seprators and terminators. No language could be that strict on the terminator meaning as Cobol. The code below compiles perfectly well, but the result is hardly the expected. IF Main-condition THEN PERFORM First-common-part IF Some-condition THEN PERFORM Alternative-1 ELSE IF Some-other-condition THEN PERFORM Alternative-2 ELSE PERFORM Default-alternative END-IF PERFORM Second-common-part END-IF. What happens here if Some-condition is fulfilled is that First-common-part and Alternative-1 are performed, but nothing else. This is obvious if we realise that Cobol has no ELSE IF a la Fortran, so there is really three IF statements, not two. But then you may ask, isn't there an END-IF missing? No. END-IF is optional in Cobol. The period terminates both "IF Main..." and "IF Some-other..." in one strike. Extremely powerful, isn't it? :-) -- Erland Sommarskog ENEA Data, Stockholm sommar@enea.se "Frequently, unexpected errors are entirely unpredictable" - Digital Equipment