On Dec 16, 09 07:21, Jesse Phillips wrote:
lws Wrote:
On 2009-11-19 15:46:57 -0800, Bill Baxter<wbax...@gmail.com> said:
On Wed, Nov 18, 2009 at 8:33 PM, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
I am thinking that representing operators by their exact token
representation is a principled approach because it allows for unambiguous
mapping,
There used to be an argument floating around that using 'opAdd" was
better than "op+" because the former encourages people to only
overload the method to do things that resemble addition. Whereas op+
says I'm just a symbol, do whatever you want with me.
I never really bought into it... but it was what I was told years ago
when I complained that opSub opMul etc were harder to remember than
need be. :-)
I guess D will have to change it's story now.
--bb
The reason Walter provided me when I asked ~9 years ago was that "T
operator+(T)" causes unnecessary headaches when parsing. opAdd does
not produce these complications when parsing function declarations.
T opBinary(string op)(T) also does not produce the same headaches.
-SC
There is a page for the rational which I thought gave the OP's explination:
http://digitalmars.com/d/2.0/rationale.html
However it does have this nice little gem:
"__ keywords should indicate a proprietary language extension, not a basic part of
the language."
Which makes you wonder why D has __traits, __gshared... or are those not basic
parts of the language? :)
__gshared was deliberately named to discourage its use iirc.