Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

enter image description here

Now read the Cell expression back from testnb:

SelectionMove[testnb, Before, Notebook];
SelectionMove[testnb, Next, Cell];
NotebookRead[testnb]

Mathematica graphics

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:

enter image description here

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:

Mathematica graphics

My question:

Did I miss something? Or is this a bug?

My system: Mathematica 9.0.0.0 on Windows 7 32-bit

share|improve this question
This may have been fixed in 9.0.1. Please take a look at what I got with 9.0.1 on OS X: i.stack.imgur.com/8J6Oy.png – Szabolcs Feb 25 at 19:13
@Szabolcs Thanks for the information! Now I begin to wonder when and why this wired bug.. – Silvia Feb 25 at 19:19
This is very similar to a bug I encountered with Mathematica version 5 on windowsXP. The problem was : when I had a comment at the end of a cell, the cell became sometimes corrupted. A look inside the cell with ctrl-shift-E reveals a Row without List inside. – andre Feb 25 at 21:43
(follow the last comment) Maybe this problem has something to do with the fact there are two different characters * (see doc or ask details). These characters are very similar, but I saw at screen that the * in the (* was not the same as in *) (depending on system?) – andre Feb 25 at 21:46
2  
It was a bug, newly introduced to 9.0.0, and subsequently fixed in 9.0.1. The same problem led to the oft-reported corruption of certain cells when you tired to merge them. – John Fultz Feb 27 at 10:46
show 2 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.