Puzzled by body assessment

I am puzzled by the following Function behavior:

 In[1]:= InlineCellInMessage=Function[expr,DisplayForm[Cell[BoxData[MakeBoxes[expr,StandardForm]],"Input"]],{HoldAllComplete}] Out[1]= Function[expr,MakeBoxes[expr,StandardForm]] 

I expected to see unexplored code inside Function in the output, as in the following case:

 In[2]:= InlineCellInMessage=Function[x,x+1+1] Out[2]= Function[x,x+1+1] 

But I get an inner cell inside the output. Why is this happening?

+3
source share
1 answer

This is the result of FrontEnd rendering. Consider:

 InlineCellInMessage = Function[expr,DisplayForm[Cell[BoxData[MakeBoxes[expr,StandardForm]],"Input"]],{HoldAllComplete}] InlineCellInMessage // InputForm 

Output:

 InputForm[Function[expr, DisplayForm[Cell[BoxData[MakeBoxes[expr, StandardForm]], "Input"]], {HoldAll.Complete}]] 

In addition, the HoldAllComplete parameter affects the future input of the function, and not the creation of the function itself. If you want Function have a HoldAllComplete , you need to:

 SetAttributes[Function, HoldAllComplete] 
+3
source

All Articles