I plan to add an extension to
std.format, namely a new format character with the meaning of producing a source code literal. Or more formally, the following snippet should work for every type this extension will support:
enum a = <something>; enum b = mixin(format!"%S"(a)); static assert(a == b && is(typeof(a) == typeof(b)));
(Please note, that even for floats
a == b should hold for all values, but NaNs; I plan to use RYU for this.)
The big question is now, which character to use. I thought of
%S like source code literal. Andrei suggested
%D like D literal. Both ideas have the disadvantage of using uppercase letters, which would break the of uppercase letters meaning that the output uses uppercase instead of lowercase (i.e. 1E10 instead of 1e10).
A first idea of a lowercase literal might be
%l but this might easily be confused with
%1 (both don't exist); and also
l is used in C's
long which we luckily don't need here. Anyway I fear confusion.
What do you think? Which letter would be best?