Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.c Subject: Re: Boolean Operators Slighted in C Message-ID: <857@ttrdc.UUCP> Date: Tue, 6-May-86 05:55:39 EDT Article-I.D.: ttrdc.857 Posted: Tue May 6 05:55:39 1986 Date-Received: Thu, 8-May-86 21:23:07 EDT References: <838@ihwpt.UUCP> <778@bentley.UUCP> <12329@ucla-cs.ARPA> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 50 In article <12329@ucla-cs.ARPA>, jimc@ucla-cs.ARPA (Jim Carter) writes: >I think it's useful! As written, of course, it's semantically invalid, >but what you really mean is "v <= e" (sic) or, to demonstrate where it's >really useful, > array[horrendous] [subscript] [list] <= bigexpr; > rather than > if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr; >Now "<=" already means something else so this syntax is not acceptable. >How about "v < = e" with a mandatory blank? This is atrocious human >engineering but at least is parseable. Anybody have any better ideas? >-- >James F. Carter (213) 206-1306 >UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024 >UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc ARPA:jimc@locus.UCLA.EDU First, one could use the preprocessor to help: #define UPMAX(i,j) if ((i) < (j)) (i) = (j) ... UPMAX(array[h][s][l],bigexpr); While the output of cpp would look real messy, comp would handle this just fine. Of course, you lose (as with any macro which uses an argument more than once) if the arguments have side effects such as ++ (but that isn't the case here, right?). Or if you know that the optimizer is not smart enough to catch this and will evaluate the entire array[h][s][l] including subscripts twice (as well as bigexpr), you can force temp variables: FOO array[I][J][K]; ... FOO *atmp; FOO btmp; ... atmp = &(array[h][s][l]); btmp = bigexpr; UPMAX(*atmp,btmp); As for the lousy human engineering in requiring extra blanks in certain expressions, don't we have that already in C, e.g.: a = b/*c; /* did this mean divide b by *c, or to start a comment? */ ; a=*b; /* compiler complains about "ambiguous assignment" here */ -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, vax135}!ttrdc!levy