On 8 April 2013 16:43, Jakub Jelinek <ja...@redhat.com> wrote: > On Mon, Apr 08, 2013 at 04:29:02PM +0200, Manuel López-Ibáñez wrote: >> In fact, I would be fine with something like: >> >> pp_start_color() >> pp_stop_color() >> pp_wrap_in_color("") >> >> It is a bit more verbose, but also clearer when reading the code. And >> no need for %[colorname] or %r or -Wformat support. > > But you then need to break the code into multiple function calls, which > decreases readability. > > pp_verbatim (context->printer, > _("%s:%d:%d: [ skipping %d instantiation contexts, > " > "use -ftemplate-backtrace-limit=0 to disable ]\n"), > xloc.file, xloc.line, xloc.column, skip);
I guess "decreases readability" depends whether one knows what the extra codes mean or not. I still have to check many times what %K and %q#+T and other less common codes exactly do. I'd rather have less codes than more. And one could argue that the above call should be split, since the "%s:%d:%d:" should not be translated. That said, I would prefer that instead of expanded_location xloc; xloc = expand_location (loc); if (context->show_column) pp_verbatim (context->printer, _("%r%s:%d:%d:%R [ skipping %d instantiation contexts, " "use -ftemplate-backtrace-limit=0 to disable ]\n"), "locus", xloc.file, xloc.line, xloc.column, skip); else pp_verbatim (context->printer, _("%r%s:%d:%R [ skipping %d instantiation contexts, " "use -ftemplate-backtrace-limit=0 to disable ]\n"), "locus", xloc.file, xloc.line, skip); we had: pp_verbatim (context->printer, _("%X [ skipping %d instantiation contexts, " "use -ftemplate-backtrace-limit=0 to disable ]\n"), expand_location(loc), skip); and the pretty-printer takes care of applying color or not (or expanding column numbers or not, etc). Or without the extra %X code: pp_print_locus (context->printer, loc); pp_verbatim (context->printer, _(" [ skipping %d instantiation contexts, " "use -ftemplate-backtrace-limit=0 to disable ]\n"), skip); Or even if we don't want the pretty printer to know about ->show_column: diagnostic_print_locus (context, loc); pp_verbatim (context->printer, _(" [ skipping %d instantiation contexts, " "use -ftemplate-backtrace-limit=0 to disable ]\n"), skip); and the internal diagnostics machinery takes care of applying color or not (or expanding column numbers or not, etc). > can be right now a single call, while you would need several. Also, if you > eventually want to colorize something in say error_at, warning_at and > similar format strings. For those you really don't have the printer at Do we really want to allow that much flexibility? Then the color_dict needs to be dynamic or the caller is restricted to re-using existing colornames. I was expecting the use of color to be rather limited to a very very few well-defined concepts. I was hoping that higher-level diagnostic functions would be oblivious to the color stuff to not make the diagnostics code much more complex. Maybe I am wrong here and FE maintainers do want that flexibility. Cheers, Manuel.