On Sun, Jan 06, 2008 at 05:11:01PM -0800, SJS wrote:
Then again, putting all the variable declarations at the top of the
method/function gives you much of what you want.
function name( args ... ) {
LongArduousType foo;
. . .
foo = new LongArduousType(...);
This is considered bad style in most modern languages. In fact, it is
forbidden in some. The idea isn't to move the initialization up to the
top, but to move the variable declaration down to where it is first
assigned. You don't ever declare variables without giving them their
initial value.
C# is kind of enough to consider use before initialization to be a static
compilation error. Most other languages just consider it a warning.
I still think something like:
auto foo = new LongArduousType(...);
is much cleaner.
Dave
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg