[llvm-dev] RFC: General purpose type-safe formatting library

Aaron Ballman via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 12 13:10:49 PDT 2016


On Wed, Oct 12, 2016 at 3:23 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:
>
> On Oct 12, 2016, at 12:08 PM, Zachary Turner <zturner at google.com> wrote:
>
> I thought I did.  :)  Passing format strings between functions is very
> useful.  For example, imagine wanting to write a function like
> printRange(const char *Fmt, std::vector<int> Items);
>
>
> I’m not sure I understand your example?
> Do you mean you want the range to be in the format? If so Why? I would
> rather write something like:
>
> printRange(“{per_elts_fmt}”, /* separator */ “, ", begin, end);
>
> This isn't possible if your format string MUST be a string literal
>
>
> I haven’t seen a convincing example yet to support this. I may miss the
> obvious, but you haven’t shown it either.

Internationalization is often one common reason for a format string to
not be a string literal. I could see us wanting to translate our
diagnostic messages, for instance.

~Aaron


More information about the llvm-dev mailing list