No household is perfect

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Dec 4 07:27:40 PST 2013


On Wed, Dec 04, 2013 at 08:44:17AM +0100, Jacob Carlborg wrote:
> On 2013-12-03 21:06, Walter Bright wrote:
> 
> >Embedded DSLs should be visually distinct, and D provides the ability
> >for that with string mixins and CTFE.
> 
> The point of DSL's are to make a languages that work optimal and
> look appropriate for the given domain. Not necessarily make it
> distinct from standard D.
[...]

Of course, it's not the *point* of DSLs to be distinct from the host
language, but it's a good idea for it to be. Operator overloading that
turns + and * into something completely unlike their usual meanings
violates the principle of least surprise. A CTFE-string containing + and
* interpreted differently is better, because the syntax itself reminds
you that something unlike normal D syntax is happening.

	// (D) It's clear * and + means something different:
	auto m = input.match(ctRegex!`^a+b*c`);

	// (C++) What on earth might this mean?!
	sregex r = (s1= +_w) >> ' ' >> (s2= +_w) >> '!';


T

-- 
Computers aren't intelligent; they only think they are.


More information about the Digitalmars-d mailing list