Bug introduced in 9.0 and fixed in 9.0.1
When considering this question about re-formatting Cell
(also this one), I encountered an issue which confuses me. I'll let the code itself speak:
Consider the following simple Cell
expression, which contains a comment line:
cellexpr =
Cell[BoxData[{RowBox[{RowBox[{"a", ";"}], "\[IndentingNewLine]",
RowBox[{"(*", RowBox[{"b", ";"}], "*)"}]}],
"\[IndentingNewLine]", "c"}], "Input"];
Write it to a Notebook
:
testnb = NotebookCreate[];
NotebookWrite[testnb, cellexpr];
It looks like the following, which is what one would expect:
Now read the Cell
expression back from testnb
:
SelectionMove[testnb, Before, Notebook];
SelectionMove[testnb, Next, Cell];
NotebookRead[testnb]
Note the first RowBox
, it has a structure as RowBox[ item1, item2, ...]
, which is ill-posed since the first argument to RowBox must be a list. And the obtained Cell
expression is therefor ill-posed, which can be seen by CellPrint
-ing it:
I noticed that if the comment-line part is removed (e.g. by deleting "(*"
and "*)"
in cellexpr
), everything works fine. And for the example in this question, the second comment is correctly obtained:
My question:
Did I miss something? Or is this a bug?
My system: Mathematica 9.0.0.0 on Windows 7 32-bit