https://issues.dlang.org/show_bug.cgi?id=14593
Artem Borisovskiy <kolo...@bk.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kolo...@bk.ru --- Comment #5 from Artem Borisovskiy <kolo...@bk.ru> --- (In reply to Martin Nowak from comment #4) > The worst with string arguments is that they can't use variables from the > calling scope. Let's admit it: string mixins are just slightly better preprocessor macros. They sometimes save time, indeed, but there is no D IDE sufficiently smart to expand and semantically analyse them, they're hard to debug, compiler messages don't help much (because we can't see the actual generated code), and code generation for mixins looks messy most of the time, since it usually is just string concatenation. Even if we decide to use format() for prettier string generation, we will immediately have another problem to solve - how to generate code, which itself uses formatting. We can escape %'s, but it looks just as messy as regular expressions in double-quoted strings, and it's too easy to forget to do that. Another problem is parsing a DSL: we can't count on tokenized strings, since there's no way to enforce their usage on the call site, therefore we must even tokenize DSL by hand. AST macros are the only robust _and_ convenient way to generate arbitrary code, and since we don't have them, we should invent other ways, instead of sticking string mixins everywhere and turning our pretty D code into something looking even worse than C preprocessor magic: at least, in C you don't need to concatenate anything most of the time. I'm not sure whether it should be done with operator overloading, but I like your DB query example, it looks intuitive and clean. (In reply to Walter Bright from comment #1) > Using expression templates to implement DSL's makes code really hard to > understand and debug. There are better ways. So do string mixins. What are the other ways? It would be great to have a DSL with maximum assistance from the compiler, i.e. with type checking and minimum boilerplate. How to implement an inline assembler without using string mixins or poking the compiler's guts, for example? We should do better than 40-year old Scheme, otherwise the terrorists (syntactic ones) have won. --