Convert FrontEnd Expressions

As I said, there are several types of expressions in Mathematica that are automatically parsed by FrontEnd.

For example, if we evaluate HoldComplete[Rotate[Style[expr, Red], 0.5]] , we see that FrontEnd does not display the original expression:

Screen shot

Can this behavior be controlled by FrontEnd?

And is it possible to get a complete list of expressions that are automatically processed by FrontEnd?


EDIT

We can see MakeBoxes calls when using Print :

 On[MakeBoxes]; Print[ HoldComplete@Rotate ["text", Pi/2]] 

But copying in hard copy while copying gives a modified expression: HoldComplete[Rotate["text", 1.5707963267948966]] . This shows that Print does not HoldComplete .

When creating Cell output, calls to MakeBoxes should also appear. Is there any way to see them?

+7
source share
4 answers

I found a post from John Fultz with a pretty clear explanation of how graphical functions work:

In version 6, the kernel has absolutely no involvement in creating the rendered image. The steps taken when displaying a graph in version 6 are very similar to those used to display non-graphical output. It works as follows:

1) The expression is evaluated and ultimately produces something with head Graphics[] or Graphics3D[] .

2) The resulting expression is passed through MakeBoxes . MakeBoxes has a set of rules that turns a graphic expression into an input field, which the front end is used to represent the graphic. For example.

 In[9]:= MakeBoxes[Graphics[{Point[{0, 0}]}], StandardForm] 
 Out[9]= GraphicsBox[{PointBox[{0, 0}]}] 

Inside, we call it a “set," an expression. It may be a little strange thinking of graphics as “typing”, but it is fundamentally the same operation that occurs for typing typesetting (which has worked this way for 11 years), so I will use this term.

3) The received set expression is sent via MathLink to the front end.

4) The front analyzes the set of expressions and creates internal objects that usually have a one-to-one correspondence between the expression for the set.

5) The front part makes the inner objects.

This means that the conversion is performed in the kernel by calling MakeBoxes .

This call can be intercepted using high-level code:

 list = {}; MakeBoxes[expr_, form_] /; (AppendTo[list, HoldComplete[expr]]; True) := Null; HoldComplete[Rotate[Style[expr, Red], 0.5]] ClearAll[MakeBoxes]; list 

Here is what we get as a conclusion:

screenshot

You can see that MakeBoxes does not HoldAllComplete attribute.

The list of characters that are automatically converted before sending to FrontEnd can be obtained from FormatValues :

 In[1]:= list = Select[Names["*"], ToExpression[#, InputForm, Function[symbol, Length[ FormatValues@symbol ] > 0, HoldAll]] &]; list // Length During evaluation of In[1]:= General::readp: Symbol I is read-protected. >> Out[2]= 162 
+6
source

There are two aspects to what you testify. First, transcribing an expression entered into boxes and rendering these fields using Front-End. By default, the output is set using StandardForm, which has a set rule for rendering graphics and geometric transformations. If you use InputForm, such a rule does not exist. You can control which form is used through Preferences-> Evaluation.

You can convince yourself that HoldComplete did the right thing by using InputForm or FullForm on the input or using the InputForm mapping in the output cell.

enter image description here

EDIT Using OutputForm:

In [13]: = OutputForm [%]

Out [13] // OutputForm = HoldComplete [Rotate [expr, 0.5]]

As for your question about a complete list of characters, it includes graphics, geometric operations, and possibly others, but I don't know the complete list.

+5
source

Not quite the answer, but in the "Settings"> "Evaluation" section there are options "Use text fields when converting (input | output) to set types".

If you check them, then using Cell> Convert To ...> StandardForm, etc. a rotation [..] will be displayed instead of a visually rotated result.

+2
source

Recently, John Fultz answered a question about converting TableForm expressions to a “set”, and it’s worth bringing it here, since it strengthens (although partially contradicts) the general explanation given in my previous answer :

ToBoxes returns exactly what the kernel sends to the front end unchanged (except, in the general case, it is possible to be different for evaluating semantics and side effects, but this is not a question in your example).

The problem is that the front end has two different specifications for specifying the parameters of the GridBox ... one of which relates to version 3, and the other, wider version 6. The front end understands both sets of options, but canonizes everything that gets version 6 options .

GridBox is the only box that has such an optional change of options, and it was necessary to support the new functionality that we added in v6. But the front end will continue to understand the old options for a serious long time (probably forever), since the old options appear not only in certain cells, but in outdated laptop files.

ToBoxes[] of TableForm creates obsolete options because it was not necessary to update the TableForm set after some time ( ToBoxes[] of Grid , on the other hand, uses modern options). Conversion is performed by the front end. You can rely on the front end to do the conversion for you, or you could figure out how the options for the card yourself.

So, in this case, the final stage of the expression conversion is done by FrontEnd.

+1
source

All Articles