On Thursday, 3 September 2015 at 18:31:59 UTC, Meta wrote:
On that note, though, the unary + operator is totally useless
in D... maybe we should get rid of that instead? (Then "=+"
will automatically be an error.)
T
Worse than useless; it doesn't even behave as you would expect.
import std.stdio;
void main()
{
auto a = -1;
writeln(+a); //Prints -1
writeln(-a); //Prints 1
}
At least unary - does something.
I like to use the unary plus *in some cases* of tabular data, to
reinforce the signess. Something like this:
auto foo = [
+1234,
-5678,
-4242,
+9999
];