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: compound statements Message-ID: <5281@topaz.RUTGERS.EDU> Date: Sat, 5-Jul-86 00:43:22 EDT Article-I.D.: topaz.5281 Posted: Sat Jul 5 00:43:22 1986 Date-Received: Sat, 5-Jul-86 08:48:06 EDT Organization: Rutgers Univ., New Brunswick, N.J. Lines: 71 [SysAdms - for a real laugh, temporarily replace the normal] [contents of curses.h with strings resembling "$@%^&#!#!!!"] In many languages, the body of a program or subprogram consists of a compound statement. This seems like an arbitrary restriction, and is quite annoying at times. Often the action of a program or subprogam is expressable as a single statement, and I would never otherwise enclose a single statement within a compound statement. For example, consider the following piece of pseudo code (feel free to flame my pseudo, as long as it's followed with ' > /dev/null') (fellow posters - when giving examples via code, try to produce something non-trivial; it makes reading the article more interesting): equal-trees (tree t1, t2) returns boolean if t1 = null then equal-trees <- (t1 = t2) else if t2 = null then equal-trees <- false else equal-trees <- (t1 (data) = t2 (data)) and equal-trees (t1 (left), t2 (left)) and equal-trees (t1 (right), t2 (right)) endif endif Now why should a compiler want to force someone to embed such pretty code :-) within a pair of curly braces, or a begin-end pair, or what- have-you? Certainly it's no big deal to recognize the statement, as compilers are so often forced to recognize statements that they've become quite good at it. If the code were any longer, one could argue that it's done to increase readability by imposing delimeters. That's not the case here (albeit ~borderline). Regardless, a comment or two would suffice anyway. If the code were any longer, one could argue that it's done as a built-in error check. But, the recent trends in programming place emphasis on modular code; hence, people are writing more, smaller procedures. And to top it all off, many of the same languages that impose this restriction allow as clauses of structured statements a single statement of any type, which contradicts any justification for requiring the body of a program or subprogram to be a compound statement! What I mean is, if it's required that the bodies of programs and subprograms be a compound statement, it would only be natural that the same hold true for "if"'s "then" and "else" clauses, and loop bodies, and "case"/"switch"'s clauses, and... AND!... ARGHH! Whew! It's over. I don't know what came over me, it all just seemed to come in a single rush of uninhibited frustration! _ /| \`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}