[Bf-committers] Compiler error with MSVC6 on SG_Tree.cpp

Douglas Toltzman bf-committers@blender.org
Mon, 17 May 2004 22:08:52 -0400 (EDT)

On Mon, 17 May 2004, Stephen Swaney wrote:

> Douglas Toltzman wrote:
> > 
> > Of course you are correct, but in my 12 years of professional C++
> > development, I've found that there is no really good reason to declare a
> > variable in a for loop, and it is known to make trouble with some
> > compilers.  
> Interesting.  With a similar amount of experience, I have exactly
> the opposite opinion.  There is no reason to expand the scope
> of a variable beyond where it is used.  This is one of the
> known differences between C and C++.

Ahh, but I worked with the standards committee on C and C++, and this is
an area of the standard that was not implemented consistantly.  It is a
fringe case that can easily be avoided.
> > Also, the assignment syntax of "<type> <name>(<value>)" is, in
> > some compilers troublesome.  Is there really a good reason to use syntax
> > that is only going to make trouble for some people, if there is no benefit
> > in execution speed or legibility?
> Actually, this is initialization rather than assignment and can
> be the only way to set const and reference members of classes.

But in the case we were dealing with, it was a simple type; a pointer, to
be precise.  No constructor calls would ever be made for a pointer
> But let's not turn this into a language-lawyering funboard discussion.

With this, I agree.
> Having supported multi-platform apps under various compilers,
> I am not insensitve to the problems.  However, rather than
> hearing people grump about someone writing standard C++,
> I would expect the users of broken implementations to be
> cheerfully raising their hands and saying "Why, yes, I
> would be happy to port the code to my brain-dead compiler."

With this, I disagree.  The syntax changes required to be cross platform
are trivial and harmless.  Preprocessor pragmas would just add noise.

It seems to me that one of our goals should be to make the codebase
portable.  As long as function, efficiency, or maintainability are not
harmed, what can it hurt?  I agree that tight scoping is always good, but
you won't convince me that a counter variable named "x" needs to be scoped
to the loop in which it is used.  It's a trivial argument for breaking
compiler compatibility.  I hate Microsoft compilers, but I can still see
the value in using portable syntax wherever possible.

This will be my last post on this point.  I would simply ask coders to use
common sense when exploiting esoteric features of C++.

Thanks to everyone for the new features and fixes.  Although I've been
unable to make any contributions to the codebase, I have a good idea of
what you guys are up against, and I really appreciate your efforts.  I'd
also like to add, that I believe programming is an art, as much as it is a
science.  A well crafted piece of code is a thing of beauty, as well as a
feat of engineering.  You're all artists to me, and I have a great deal of
respect for what you are doing.

Douglas Toltzman
"If you must preach, preach tolerance."