No household is perfect

Walter Bright newshound2 at digitalmars.com
Tue Dec 3 12:06:50 PST 2013


On 12/3/2013 4:41 AM, Russel Winder wrote:
> Yes.
>
> 	a + b
>
> could be set union, logic and, string concatenation. The + is just a
> message to the LHS object, it determines what to do. This is the whole
> basis for DSLs.

Using operator overloading to create a DSL is just wrong. Part of the design of 
operator overloading in D is to deliberately frustrate such attempts.

+ should mean addition, not union, concatenation, etc. Overloading is there to 
support addition on user defined types, not to invent new meanings for it.

Embedded DSLs should be visually distinct, and D provides the ability for that 
with string mixins and CTFE.


Part of my opinion for this comes from C++ regexes done using expression 
templates. It's cute and clever, but it's madness. For one, any sort of errors 
coming out of it if a mistake is made are awesomely incomprehensible. For 
another, there's no clue in the source code when one has slipped into DSL-land, 
and suddenly * doesn't mean pointer dereference, it means "0 or more".

Utter madness.


More information about the Digitalmars-d mailing list