Andrei Alexandrescu wrote: > Michiel Helvensteijn wrote: >> Andrei Alexandrescu wrote: >> >>> Is there any good use of unary +? >> >> I think it's just good symmetry. It makes a programming language just a >> little bit more elegant. Plus, you keep the 0.01% of programmers that use >> it happy. >> >> What will removing it gain you? > > Sancta simplicitas.
Removing unary '+' does not simplify the language, but complicates it. In math, '+' and '-' are partners. Syntactically, in every context where '-' can be used, '+' can also be used. Keeping this symmetry is the easiest, simplest thing to do. Yes, it's easy to remember that while '-' works both as a binary and an unary operator, '+' is always binary. But should one have to? The omission of unary '+' would be dead weight in the language, reserving a symbol that can never be used for any purpose other than adding unary '+' back in. -- Rainer Deyke - [email protected]
