Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!gaynor From: gaynor@topaz.RUTGERS.EDU (Silver) Newsgroups: net.lang Subject: Re: compound statements Message-ID: <5312@topaz.RUTGERS.EDU> Date: Thu, 10-Jul-86 20:14:44 EDT Article-I.D.: topaz.5312 Posted: Thu Jul 10 20:14:44 1986 Date-Received: Sat, 12-Jul-86 03:08:36 EDT References: <5303@topaz.RUTGERS.EDU> <2322@umcp-cs.UUCP> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 78 [ If there is a line-eater, give me a sign!! ] [ See, I told you there was no li In article <2322@umcp-cs.UUCP], mangoe@umcp-cs.UUCP (Charley Wingate) writes: ] Silver writes: ] [....] ] ] What gives rise to ambiguity is the null statement. Consider a ] ] language that allows null statements, and an arbitrary statement as a ] ] (sub-)program body. In the following, example, to which procedure ] ] would the 'writestring' be bound? ] ] ] ===== example ===== ] ] # I consider the 'program' keyword to be unnecessary. # ] ] procedure example (output - text) ] ] ] ] procedure this ] ] ] ] procedure that ] ] ] ] # the code in question # ] ] writestring (output, "What procedure calls this statement?") ] ] =================== ] ] ] Recall how Pascal resolves 'else' clause ambiguities. Simply bind it ] ] to the nearest unclosed 'if-then' (not 'if-then-else') statement. ] ] That convention is applicable here. If the definition of the language ] ] stated that a statement is bound to the nearest unclosed procedure, ] ] then no ambiguity results. The 'writestring' statement is bound to ] ] 'that', a null-statement to 'this' and 'test'. ] ] Well, ACCCKK PTHT. What if you have TWO statements? Which belongs to whom? ] ] Program X(output); ] ] Procedure Y; { Begin } ] ] Writeln("A"); ] ] { End; } { Begin } ] ] Writeln ("b"); Y; ] ] { End. } ] ] Now, with all the begin-end constructs eliminated, how do you tell which ] statements belong to which procedure? ] ] (Obviously, the "begins" are all superfluous. The "ends" aren't, though.) ] ] C. Wingate It's not how do you tell which STATEMENTS belong to which procedure, but which STATEMENT. If you want to have more than one statement for the body of your (sub-)program, there MUST be some form of grouping (ie terminator, delimiters). I think therein lies the source of your confusion. I am not proposing that the groupers be thrown out, only excluded when they're not necessary and there's no loss in clarity. So, in your example, Writeln("A") would be bound to Procedure Y, Writeln ("b") to Program X, and the code after that would probably then generate some 'end of program expected' error. To bind both the Writeln ("b") and the call to Y to Program X, they must be grouped somehow (the second commented-out begin-end pair would do nicely). [ This appears to have been intended to be Pascal, which uses the ] [ single quote to delimit text constants. Flame on you! :-) ] _ /| \`o_O' ( ) Aachk! Phft! U Disclaimer: The opinions and/or information and/or code expressed here were generated by this characature, stolen from Dave Rasmussen, to which I have taken the liberty of adding ears. So don't look to me for a disclaimer! Silver {...!topaz!gaynor}