yank unary '+'?
Michiel Helvensteijn
m.helvensteijn.remove at gmail.com
Tue Dec 8 14:09:19 PST 2009
Andrei Alexandrescu wrote:
>> "I can't imagine a use for it and removing it makes the language
>> simpler."
>
> I disagree
(...)
> I was mostly talking about overloading operator +. Operator + has a long
> history of being available for overloading in C++, which we can use to
> our advantage. It has been used to emulate DSLs, but I think we have
> much better means to define DSLs in D than to redefine all operators to
> mean some convention-chosen things.
Ok, so it's: "I can imagine only one use for it -- but I think we have a
better way to do that -- and removing it will make the language simpler."
How is that a better reason?
I'll ask you again, because I'm really curious. Why would you remove unary
plus?
* I can't imagine it would make the compiler simpler to any significant
degree. If the compiler is well written, unary plus will simply occupy a
standard spot in a couple of lists (parser, op-function-names, ...). I
doubt removing it would even make a dent in the complexity of the code.
* Assuming for the moment that the D language and the D compiler are
different things (which they aren't), would it make the language simpler?
It would probably only confuse programmers who expect the natural
counterpart to unary minus to be present. As for documentation, again, it's
a matter of a single spot in a list somewhere.
* It doesn't, as far as I can see, take up syntax-space that might be
occupied by another more useful feature.
* There are even known use-cases. Though for a simple, expected, symmetric
feature such as this one, that wouldn't even be a requirement for me.
(Note that I'm not especially interested in the unary plus operator per se.
I'm just using it as a convenient case-study. I'm more curious about your
opinion on why language features should be adopted/tossed/kept.)
Best regards,
--
Michiel Helvensteijn
More information about the Digitalmars-d
mailing list