Bug introduced in V10 and partially fixed in V11.1.1
TLDR
Various of expressions which have fancy typeset form or are designed as UI elements won't survive ToExpression @* ToBoxes round-trip. And they should.
Examples
InterpolatingFunction(new)MakeExpression[#, StandardForm] & @ ToBoxes @ Interpolation[ {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}} ] // ShallowErrorBox[ErrorBox[TagBox[<<5>>]]]ToExpression::esntx: Could not parse TagBox[<<1>>] as input.
InputFieldToExpression @ ToBoxes @ InputField[Dynamic[x]]$FailedToExpression::notstrbox: InputFieldBox[x] is not a string or a box. ToExpression can only interpret strings or boxes as Wolfram Language input.
I don't expect
InputField[Dynamic[x]]but at least something which is a proper expression, e.g. button works:ToExpression @ ToBoxes @ Button[Dynamic[x]] // InputFormButton[Dynamic[x], Evaluator -> None, Appearance -> Automatic, Method -> "Preemptive"]Things get weirder,
MakeExpressioncan handleInputFieldcase:InputForm @ MakeExpression[ #, StandardForm ] & @ ToBoxes @ InputField[Dynamic[x]]HoldComplete[InputField[Dynamic[x]]]FileNameSetterInputForm@MakeExpression[ #, StandardForm ] & @ ToBoxes @ FileNameSetter[Dynamic[x]]ErrorBox[RowBox[{"FileNameSetterBoxes", "[", ErrorBox[Dynamic[x]], ",", "Open", ",", All, "]"}]]Syntax::sntxf: "FileNameSetterBoxes[" cannot be followed by "x,Open,All]".
Question
Are those bugs or have I missed something. Please help me understand that. :)
x = Dynamic[y]; MakeExpression@MakeBoxes@FileNameSetter[x]andx = Dynamic[y]; ToExpression@MakeBoxes@FileNameSetter[x]do work. – Karsten7 Sep 05 '16 at 12:44MakeExpression@MakeBoxes@FileNameSetter[Dynamic[f]]andToExpression@ToBoxes@FileNameSetter[Dynamic[f]]works in Mathematica version 9.0.1. – Karsten7 Sep 05 '16 at 13:01ToBoxes@FileNameSetter[Dynamic[f]]creates anInterpretationBox. Since version 10 aTemplateBoxis created. – Karsten7 Sep 05 '16 at 13:22FileNameSettercase the explanation could simply be that the proper definition forMakeExpression[ TemplateBox[{name_, type_, filter_}, "FileNameSetterBoxes"], StandardForm]is missing. DoFileNameSetterBoxeseven exist? – Karsten7 Sep 05 '16 at 14:10CurrentValue[{StyleDefinitions, "FileNameSetterBoxes"}]. Which the FE understands, but the kernel does not. So this does properly roundtrip to output cells and back to input cells, but not through the more constrainedMakeBoxes/MakeExpressionroundtrip. – John Fultz Sep 07 '16 at 13:52