Overloading relational operators separately; thoughts?

pineapple via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 28 13:30:20 PDT 2016


On Wednesday, 28 September 2016 at 20:16:08 UTC, Walter Bright 
wrote:
> Because there is no way to stop the former but still have 
> operator overloading.
>
> To reiterate, operator overloading exists in D to support the 
> inclusion of arithmetic library types. Any other purpose is 
> discouraged, and that includes expression templates and things 
> like << for iostreams.

This is an obsolete way of thinking about operators. Operator 
overloading exists to make the programmer's life easier, and 
limiting the ways in which a valuable tool can be used drives 
people to languages which allow them to be more expressive.

For my job I write Python. We use a database layer called 
sqlalchemy that allows us to express queries by writing, for 
example, `session.query(some_table).filter(row1 == row2)` and I 
cannot begin to express how useful this is when writing code, 
when maintaining code, and when attempting to understand code 
that someone else wrote.

The objective should never be to stop the programmer from doing 
something because you personally dislike the practice.



More information about the Digitalmars-d mailing list