Proposal: Database Engine for D

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 4 01:44:35 PST 2016


On 1/1/2016 3:33 AM, Russel Winder via Digitalmars-d wrote:
> Or alternative 4, fix D so that proper operator definition can be
> achieved.

The way D's operator overloading is designed is not a mistake. It's limitations 
are a feature, not a bug. It was deliberately set up to:

1. Make doing C++ style iostreams hard.

2. Prevent clever use of operator overloading and expression templates to create 
languages that look like D, but are NOT.

3. Work well when using operator overloading to implement arithmetic types.

For example, I've seen operator overloading used in C++ to turn it into a 
sort-of regex language. The failures of it are:

1. Sort-of because C++ operator precedence and prefix/postfix grammar is 
different than that of regex, so it can't be emulated correctly.

2. It is visually indistinguishable from C++ code. You simply cannot look at a 
piece of code and tell it is regex with utterly different meaning, rather than 
the usual meanings.

3. Any error messages from misuse are utterly and totally incomprehensible, 
because the compiler is designed to compile C++ and gives C++ messages, not 
regex messages.

4. C++ ETs are legendary in their tendency to consume all the memory in the 
computer and take incredibly long to compile. Most fail when the expressions 
exceed a rather small level of complexity because of this.

My not-so-humble opinion is these sorts of DSLs are technical demonstrations, 
but not useful nor desirable tools.

***************************************
So, what does D do?

    http://dlang.org/phobos/std_regex.html

D enables CTFE to write a PROPER compile time regex language, with correct regex 
grammar, correct regex tokens, regex-specific error messages, etc. And it works 
great! It's not a hack, compromise, or workaround. It's a real, embedded DSL. 
And it's faster than any other regex engine on the market.


More information about the Digitalmars-d mailing list