# Why Trace[] shows some internal warnings on a standard Plot command in V9?

For fun, I like to use Trace with option TraceInternal->True to see if I figure how some of the commands work internally.

I just noticed something strange. In Version 9, I got lots of what seem like error messages that I do not get in Version 8. This example below is using Plot (I have not tried many other commands, will do that later).

Consider the most basic plot. See the difference in Trace between V8 and V9:

   Trace[Print@Plot[Sin[x], {x, -Pi, Pi}], TraceInternal -> True]


ofcourse, the command works just fine at the end in V9, and one gets the plot.

So these messages do not affect the final result, and hence, from a user point of view, one can argue that they should not matter as long as the final result is the same. They could be some internal trace messages that are left there in final build or such?

I am just curious, that is all, if someone might know what they could mean, since they do indicate some sort of an error condition, yet final plot is just fine.

-
The QuantityForm seems to suggest that the errors result from some pre- or postprocessing for the new Quantity and unit support. That more and more seems like a woefully unfinished product. –  Jens Dec 17 '12 at 20:00
No need to use TraceInternal –  Rojo Dec 17 '12 at 20:13

QuantityForm (and some other formatting functions) issues messages at typesetting instead of evaluation, and Trace is generating output that is in an unevaluated state, which QuantityForm isn't expecting.

Here's a couple of similar examples:

Trace[Block[{form = "LongForm"}, QuantityForm[Quantity[1, "Meters"], form]]]
Trace[Block[{digits = 3}, NumberForm[N[Pi], digits]]]


To be clear, these messages are still coming from the kernel, but during the construction of boxes for the frontend.

In[]:= ToBoxes[NumberForm[N[Pi], digits]];5

NumberForm::iprf: Formatting specification digits should be a positive
integer or a pair of positive integers.

Out[]= 5


and that the messages generally won't appear if the output is suppressed:

In[]:= NumberForm[N[Pi], digits];5

Out[]= 5


It also means that the messages can be hard to suppress

In[]:= Quiet[NumberForm[N[Pi], digits]]

NumberForm::iprf: Formatting specification digits should be a positive
integer or a pair of positive integers.

Out[]//NumberForm= 3.14159


since Quiet goes away once its arguments have finished evaluating, but the problematic form is still present and will still issue messages when formatted.

-
The messages generated by these functions go through the kernel or are generated entirely by the FrontEnd and the kernel is not aware about them? –  Alexey Popkov Jan 9 '13 at 9:54
@AlexeyPopkov They're from the kernel. I updated my answer to explain it a bit better, I hope. –  Brett Champion Jan 9 '13 at 15:03
Thank you. It was not clear for me that the term "at typesetting" should be read as "in the kernel during the construction of boxes for the frontend". Does typesetting also always means literal calling ToBoxes? –  Alexey Popkov Jan 9 '13 at 17:52