Operator overloading

aarti_pl aarti at interia.pl
Tue Dec 23 12:02:11 PST 2008

Andrei Alexandrescu pisze:
 > We're trying to make that work. D is due for an operator overhaul.
 > Andrei

Is there any chance that we get possibility to overload "raw operators", 
like in C++? I think that they may coexist with currently defined 
operator overloads with simple semantic rules, which will not allow them 
to work together at the same time.

I know that they may obfuscate code, but they are extremely useful when 
defining in D domain specific languages. For example I try to make SQL 
expressions work as D expressions:

string query = "SELECT * FROM a WHERE id=5;";
Query query = Select(a).Where(Equals(id, 5));

* "id" is D object in second expression

This translation is quite awful and unreadable. It would be so much 
better to get:

Query query = Select(a).Where(id == 5);

With implicit casts there will be perfect environment, to define DSL-s 
*in* D and *not* using unsafe strings.

Marcin Kuszczak

More information about the Digitalmars-d mailing list