6

Putting ??symbol in a cell and another expression in a different row of the cell returns the following error:

??symbol
1 + 2

Information::ssym: symbol 1+2 is not a symbol or a valid string pattern. >>

Information[symbol 1+2,LongForm->True]

But this does not happen with ?symbol:

?symbol
1+2

Global`symbol

3

Why does this happen?

M6299
  • 1,471
  • 1
  • 13
  • 20
  • 2
    Some parsing confusion on the FE? One can clearly see this since ??NDSolve followed by 1+2 on new line gives Information[NDsolve 1 + 2, LongForm -> True] but this does not show up with the short form (default) version of Information which is ? – Nasser Aug 16 '13 at 09:11

1 Answers1

5

Somewhat tautologically we can demonstrate that the Front End parses these differently:

parseString[s_String, prep : (True | False) : True] := 
  FrontEndExecute[UndocumentedTestFEParserPacket[s, prep]] 

parseString["?Sin\n2+2"]
parseString["??Sin\n2+2"]
{BoxData[{RowBox[{"?", "Sin"}], RowBox[{"2", "+", "2"}]}], StandardForm}

{BoxData[RowBox[{"??", RowBox[{RowBox[{"Sin", "2"}], "+", "2"}]}]], StandardForm}

A question remains as to why. Without any support I am going to suppose that the behavior of ?? is desired but that it was not extended to ? because that operator is also used for PatternTest.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371