That's why we have immutable variables. They force you to think what to
put in the variables. A lot of cases like the one above would be solved
if if-then-else was an functional expression instead of a void returning
statement. C/C++/D has the ternary ?: but the syntax is obfuscated.

Object p = if (m) {
  ...
  foo;
} else {
  ...
  bar;
}

instead of

Object p;
if (m) {
  ...
  p = foo;
} else {
  ...
  p = bar;
}

There are even cases where the former can be const. The latter one has to
be mutable in any case.

Not related to this but i have to share.
Try compiling this in C/C++.

int i = i + 5; // something like this.

This compiles with no warning, no error, nothing...
I have absolutely no idea how this thing survived so long.

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to