null [re: spec#]

so so at so.do
Sun Nov 7 18:06:07 PST 2010


> 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/


More information about the Digitalmars-d mailing list