Overloading relational operators separately; thoughts?
Minty Fresh via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 28 12:52:52 PDT 2016
On Wednesday, 28 September 2016 at 04:02:59 UTC, Walter Bright
wrote:
> The use of them to create DSLs (a technique called "expression
> templates" in C++) is discouraged in D, for several reasons.
> The recommended way to create DSLs in D is to parse strings
> using CTFE.
I don't really come from a C++ background. Actually, I have a
strong distaste for the language. Professionally, I word with
Ruby.
Again, string DSLs face a number of issues. A few that come to
mind are:
1. A parser + code generator must be implemented, which is a
lot of additional work.
2. The quality and precision of error messages degrades.
3. You loose the ability to perform actions like making
declarations within the context of the DSL (ie. assigning a
commonly re-used expression to a variable), unless your DSL is
turing complete.
> An excellent example of that is the std.regex package.
You know, if someone had managed to implement a regex DSL using
operator overloading, something must have gone _terribly_ wrong.
Regex is traditionally done in strings, lest the language
supports regex literals.
More information about the Digitalmars-d
mailing list