templating opEquals/opCmp (e.g. for DSL/expression templates)

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Feb 12 11:35:28 UTC 2019


On Tuesday, 12 February 2019 at 10:37:22 UTC, Jonathan M Davis 
wrote:
> Having the meaning be different is precisely the problem. It's 
> using the syntax for something _other_ than what it's intended 
> for. It's just supposed to be a way to have user-defined types 
> emulate the operations of built-in types. Walter has mentioned 
> time and time again how he thinks that stuff like << in C++ 
> where they made the operators mean something completely 
> different than what they mean for built-in types was a big 
> mistake, and personally, I agree.

I agree using << for I/O is stupid.

> Either way, I think that Walter has made it pretty clear that 
> overloaded operators are not intended for stuff like DSLs or 
> expression templates, and if you try to alter overloaded 
> operators to make them work better for expression templates or 
> the like, I would fully expect him to veto it.

Link?

> But I guess that we'll see his response soon enough if you try 
> to push this.

The use case is e.g. building a DB query predicate where == still 
means equality not e.g. I/O, it just isn't evaluated directly. 
The fact is you can already use it for arithmetic to build e.g. 
linear algebra expression templates, and you can use == 
predicates but not != or any of the ordering comparisons is 
inconsistent arbitrary and annoying.


More information about the Digitalmars-d mailing list