It would be nice to know why someone downvoted this. Self-answered questions are not frowned upon; in fact, they are explicitly encouraged.
–
Oleksandr R.Nov 26 '12 at 15:28

1

I wrote the answer to this question before in a related question I asked (Is it possible to print expressions in reverse order?). But given what I read, I thought it deserves to be in a proper question/answer format. Anyway I'm not competing for rep, just want to share this utility that I think is very useful.
–
faysouNov 26 '12 at 15:42

I think it's good to note here that the built-in debugger can show the names and values of variables.
–
SzabolcsFeb 5 '13 at 17:16

Yes but sometimes you want to have the variables available for a step by step debugging in the frontend, and this utility is useful for this.
–
faysouFeb 5 '13 at 17:18

The Print output using \$ShowIt = True allows to use it in the front end if you change its style to Input.

\$ReverseIt = True allows to Print the result of Print in a reverse order as asked in this question.

The Message if you switch it on using On[Debug::ShowIt] prints a Mathematica message and would stop the code if you used a message breakpoint in Mathematica or Wolfram Workbench.

\$SowIt = True allows to store what would be printed with Print in a symbol.

To see the list of keys defined in the debugSymbol containing the results extracted from a program you can use the function Keys.

\$ConsoleIt = True allows to output what would be output with Print but in the Messages console accessible in the menu Window>Messages.

\$GroupIt prints expressions in groups of two cells, for example x as title, and x=2; as expression.

The System` context of ShowIt and ShowItList allows to use them in the Private` context of other packages without having to define the package in which these functions are defined (in BeginPackage, see here for more info on the organisation of packages).

ShowIt is not shown inside another ShowIt.

You can define a tag when calling ShowIt, and restrict which tags let ShowIt output things using for example \$ShowItTagPattern.

All in all ShowIt and the functions around it show a lot of different aspects of advanced evaluation in Mathematica that could be interesting to a lot of people.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.