我对以下行为感到困惑Function
:
In[1]:= InlineCellInMessage=Function[expr,DisplayForm[Cell[BoxData[MakeBoxes[expr,StandardForm]],"Input"]],{HoldAllComplete}]
Out[1]= Function[expr,MakeBoxes[expr,StandardForm]]
我希望看到里面未评估的代码Function
在以下情况下的输出:
In[2]:= InlineCellInMessage=Function[x,x+1+1]
Out[2]= Function[x,x+1+1]
但我得到了输出内的内联单元格。为什么会发生这种情况?
这是前端渲染的结果。考虑:
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}]]
另外,在此使用参数HoldAllComplete
影响函数的未来输入,而不是函数本身的创建。如果你想Function
本身就拥有HoldAllComplete
你需要:
SetAttributes[Function, HoldAllComplete]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)