2

I'm getting different results with respect to Abort when performed in a reference documentation notebook vs a new notebook. I am pretty confident it's to do with the newlines I introduced in my new notebook, because it all works fine when I collapse it back onto one line.

In[12]:= ClearAll[a]; ClearAll[b];

In[13]:= Print[a]; Abort[]; Print[b]

During evaluation of In[13]:= a

Out[14]= $Aborted

During evaluation of In[13]:= hi

But in the documentation window for "tutorial/InterruptsAndAborts", the first evaluable cell:

In[3]:= Print[a]; Abort[]; Print[b]

During evaluation of In[3]:= a

Out[3]= $Aborted

I've checked Hold[<that>] // FullForm // CopyToClipboard and they are not identical, though they do display identically: in my notebook, it's a TagBox monstrosity:

\!\(
TagBox[
StyleBox[
RowBox[{"Hold", "[", 
RowBox[{"CompoundExpression", "[", 
RowBox[{
RowBox[{"Print", "[", "a", "]"}], ",", 
RowBox[{"Abort", "[", "]"}], ",", 
RowBox[{"Print", "[", "b", "]"}]}], "]"}], "]"}],
ShowSpecialCharacters->False,
ShowStringCharacters->True,
NumberMarks->True],
FullForm]\)

Whereas in the documentation window it's precisely:

Hold[Print[a]; Abort[]; Print[b]]

Question: why are newlines causing different behaviour with respect to Abort here? I am strongly inclined to call this a bug, because the FullForm of the expression with newlines displays identically to the FullForm of the expression without newlines; it's only when you attempt to copy the held output (e.g. with CopyToClipboard) that you discover they're different.

My version:

In[12]:= $Version
Out[12]= "12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019)"

(This odd behaviour discovered while trying to answer Stop a script. Just stop it .)

Patrick Stevens
  • 6,107
  • 1
  • 16
  • 42
  • 1
    What's also very interesting is that enclosing the newline version with parentheses changes its behavior to the single line case... – thorimur Feb 26 '21 at 22:28
  • 1
    Each separate line is a separate evaluation, even within the same cell. Check this comment: assert in notebook and the whole topic. It is about Assert and its issues but boils down to your problem. – Kuba Feb 26 '21 at 23:31

0 Answers0