Operator overloading and loop fusion

Travis Boucher boucher.travis at gmail.com
Thu Nov 5 12:27:39 PST 2009


div0 wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Andrei Alexandrescu wrote:
>> I wanted to discuss operator overloading a little bit. A good starting
>> point is Don's proposal
>>
>> http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7
>>
> 
> Just read it and I hate it.
> 
> Nobody is smart enough to think of all the possible uses for operator
> overloading and make a decision as to whether they are valid or worth while.
> 
> D's fucktarded ('scuse me, but it really sucks) operator overloading is
> the *one* and only respect where C++ still rules D.
> 
> Just because you (for certain values of you) deal with numbers doesn't
> make the relationship between <, > >= etc cast in stone and semi quoting
> an early paper by 'Bjarne Stroustrup' doesn't give any credence to the
> argument; he was wrong then and so is Don now.
> 
> (and btw, does Bjarne still feel operator abuse is a bad idea?)
> 
> boost::spirit and boost::Xpressive are 2 for instances, which make
> incredibly good use of operator abuse to achieve seriously useful
> functionality.
> 
> I think the main problem is calling these functions 'operators'.
> 
> Rather step back and call them 'infix function notation'.
> Stop imagining the objects they operate on as numbers and then you can
> do some really funky things.
> 
> D needs more operators not less and operators defined globally;
> so I can finish porting boost::spirit properly.
> 
> - --
> My enormous talent is exceeded only by my outrageous laziness.
> http://www.ssTk.co.uk
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iD8DBQFK82sMT9LetA9XoXwRAjXxAJ40jHoQqal1l6/vpV3lNlEJwT+AKgCgtOWG
> QWQpTFfEH80eqxm5TpvU0xU=
> =/62J
> -----END PGP SIGNATURE-----

One of D's strongest points is it's discouragement of 'funky things'. 
Operators like compare are designed for things like sorting, and doing 
funky things with them (for example, modifying the internal state of an 
object) should be something that is discouraged.

Keep operators logical, and use other language features such as 
delegates if you want to do 'funky things'.




More information about the Digitalmars-d mailing list