expression templates

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Mar 30 13:34:47 PDT 2011


On 30.03.2011 2:14, so wrote:
> On Tue, 29 Mar 2011 22:56:10 +0300, dsimcha <dsimcha at yahoo.com> wrote:
>
> Occasionally i encounter this argument that operator overloading is 
> bad thing when it is abused.
> I don't overload operators offensively myself, i use dot(vec, vec) 
> cross(vec, vec) for example because there is not a suitable operator 
> and these names suits much better.
>
> On the other hand i am not against languages being flexible, quite 
> contrary i don't call it a language if it is not.
> OO is an impressive tool and we need tools like this for better 
> libraries. You can't change a language for a long time but you can 
> update a library in very short period of time.
>
> vec add(a, b) { return a.x - b.x }
> vec operator+(a, b) { return a.x - b.x }
>
> Is there a difference?

The second one plays havoc with parsing :)  It's not that it's such a 
big problem but ..
BTW when does + denotes a difference?

-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list