Hi,
I wonder if it's possible to convert D language code into a
string at compile time? C/C++ preprocessor has this feature
built-in: `#` preprocessing operator allows converting a macro
argument into a string constant. See the following code snippet
for example:
```cplusplus
#define ASSERT(EXPR) some_function((EXPR), #EXPR)
// Elsewhere in the code:
void some_function(bool const condition, char const* const expr) {
if (!condition) {
printf("Assertion failed for: %s\n", expr);
}
}
// Usage:
ASSERT(a == b); // Will print "Assertion failed for: a == b"
```
I could imagine a mixin-based solution in D:
```d
// Usage:
ASSERT!"a == b";
```
But it seems a bit alien to me. First of all, it kind of
stringly-typed one. Secondly, neither IDEs nor advanced text
editors are able to figure out that the string contains actual D
code, and so neither syntax highlighting nor code assistance work
with this approach.
BR,
--
Oleksii