On 15 Apr 2003 06:25:32 +0200 Anders Johansson <andjoh@rydsbo.net> wrote:
That is what I was thinking of, yes, but it's not just in c++. In K&R C it was allowed to have things like
for (int i = 0; i < 5; i++){ fprintf(stderr, "foo\n"); int a = 3; } I don't think this was every legal in K&R and I know it is not in C89. For one, K&R never allowed the initialization of automatic variables, but as I mentioned, some compilers did. As you mention, the above code is legal in C++. I'm not sure about C99. (BTW: Reading my copy of K&R 1978 in a block, the declaration list followed by the statement list. Also, variables in a block may be initialized (I think that I may have mentioned that it was illegal in K&R. In K&R, aggregate initialization of automatic variables was illegal).
-- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9