Proposal: Database Engine for D

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 4 10:25:11 PST 2016


On Mon, 2016-01-04 at 01:44 -0800, Walter Bright via Digitalmars-d
wrote:
> 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.

What is the problem with having the << and >> operators do input
output. Very object-oriented. 

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

But it would be D. Boost.Sprint code may look like EBNF, but it is C++.

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

It is important that this works. But it should be possible to create an
operator algebra for any type: arithmetic types are a very small subset
of types used in computing.

> 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.

I avoid regular expressions except when editing using ed, sed, or
emacs, so I cannot properly comment on the above. However I find
Boost.Sprint a very sensible way of using compile-time meta-object
protocols. You write a grammar in EBNF in the source code, and the
compiler writes the parser. Excellent use of internal DSL. And type
safe.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20160104/033549a0/attachment.sig>


More information about the Digitalmars-d mailing list