Wanted: Format character for source code literal
Bastiaan Veelo
Bastiaan at Veelo.net
Sat May 1 17:01:52 UTC 2021
On Friday, 30 April 2021 at 07:10:38 UTC, Berni44 wrote:
> I plan to add an extension to `std.format`, namely a new format
> character with the meaning of producing a source code literal.
Would `%q` work? In reference to [token
strings](https://dlang.org/spec/lex.html#token_strings ):
```
enum a = <something>;
enum b = mixin(format!"%q"(a));
enum c = mixin(q{<something>});
static assert(a == b && is(typeof(a) == typeof(b)));
static assert(c == b && is(typeof(c) == typeof(b)));
```
— Bastiaan.
More information about the Digitalmars-d
mailing list