osd7@homxa.UUCP (Orlando Sotomayor-Diaz) (04/10/85)
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c> mod.std.c Digest Tue, 9 Apr 85 Volume 5 : Issue 3 Today's Topics: #else JUNK The '%' operator != "modulo" for signed numbers ---------------------------------------------------------------------- Date: Tue, 9 Apr 85 19:52:01 EST From: seismo!elsie!ado Subject: #else JUNK To: std-c@cbosgd.ATT.UUCP A colleague of mine recently noted their sadness with the (November, 1984) draft standard's outlawing of source such as #ifdef VERBOSE printf("Hello, world.\n"); #endif VERBOSE which, according to the draft, must have its last line changed to (for example) #endif /* VERBOSE */ to be legal. Such code is now successfully dealt with on many systems. Folks may want to discuss the wisdom of outlawing stuff after #else's and #endif's (and other preprocessor directives) in mod.std.c. To me, this outlawing raises a more general issue--is the standard committee's charge to "not break existing code" too stringent? In this case, for example, code would be broken--and yet the brokenness would be discovered the first time an attempt was made to compile the source using a compiler that strictly implemented the standard. If the compiler produced diagnostics, you might even learn where and how the code was broken. Similarly, while the draft standard potentially breaks source such as mktemp("/tmp/#tempXXXXXX") the brokenness of the source can be detected the first time a program made from it is run (and the given call executed) in an environment where strings are put in read-only memory. Perhaps rather than seeking to "not break existing code" the committee might seek to "not undetectably break existing code". (Given its actions, perhaps the committee is already doing this. :-)) The extra freedom might make for a more valuable standard. -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX and Elsie are Digital Equipment and Borden trademarks ------------------------------ Date: Mon, 8 Apr 85 11:44:35 est From: ihnp4!encore!ptw (P. Tucker Withington) Subject: The '%' operator != "modulo" for signed numbers To: std-c@cbosgd.ATT.UUCP The % operator is called the "mod" operator in C, but it does not compute modulus for signed numbers in any C implementation I know of. When I really want mod, I have to write (assuming b is unsigned): a%b>0?a%b:a%b+b Would it break anything to really define % as mod? o.o --tucker ~ ------------------------------ End of mod.std.c Digest - Tue, 9 Apr 85 22:57:06 EST ****************************** USENET -> posting only through cbosgd!std-c. ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C) In all cases, you may also reply to the author(s) above.