Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!gatech!bbn!bbn.com!jgrace From: jgrace@bbn.com (Joe Grace) Newsgroups: comp.lang.c++ Subject: Re: scope of FOR Summary: Fix for() scope bug. Keywords: C++ for Message-ID: <44623@bbn.COM> Date: 22 Aug 89 19:17:31 GMT References: <1807@hcr.UUCP> <9803@alice.UUCP> Sender: news@bbn.COM Reply-To: jgrace@BBN.COM (Joe Grace) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 30 Wait a minute. Why not *start* fixing it? Perhaps, by outputting a warning when code is found which depends on using for() variables outside the for() body, and claiming that that feature is not guaranteed to be supported in the next version? Duplicate declarations of the same variable within for() loops would be assumed to be *different* variables. Or by providing a tool to process files into analogous code but with the improper variable declarations moved ahead of the for() loop? [This method wouldn't necessarily work where for() loops are build out of several macros (at least not without undue complexity to the tool).] The first method would allow much code to continue working and yet make such code "obsolete". The second method would just fix things up front without too much trouble to the customer. Either fix would make for() loop declarations much more generally useable in macros and make for() loop declarations analogous to function header parameter definitions. Also, the fix would remove the ambiguity about where the body is in a for() loop without braces (i.e., no "new" scope) --- now the new scope would be the for() header itself. = Joe = Joe Grace ARPA: jgrace@bbn.com UUCP: {harvard,husc6,decvax,etc.}!bbn!jgrace #include