1
$\begingroup$

Information[symbol] shows information about a symbol and is equivalent to ?symbol.

Information[symbol]
?symbol

Global`symbol

Information[symbol, LongForm -> True]
??symbol

Global`symbol

Using FullForm with ?symbol returns the following error:

FullForm[Unevaluated[?symbol]]

Syntax::bktmcp: Expression "Unevaluated[?symbol]]" has no closing "]".

Syntax::sntxi: Incomplete expression; more input is needed .

But using FullForm with Information[Unevaluated[symbol]] returns the following expression without any error:

FullForm[Unevaluated[Information[symbol]]]

Unevaluated[Information[symbol,Rule[LongForm,False]]]

Why does this happen?

$\endgroup$
2
  • 2
    $\begingroup$ my guess: Because you can't simply pass ? x as argument to a function, since ?x is not a symbol. i.e one can't make a symbol called "?" But The front end FE on the other hand simply parses this for you (it is being nice) and then converts internally to Information[x] and that is why it works now as argument to FullForm but you can't pass "? x" yourself as argument. It is meant to be used just for asking help on the FE only. I mean, only FE can parse this as first token read. Again, only a guess. $\endgroup$
    – Nasser
    Commented Aug 16, 2013 at 8:45
  • $\begingroup$ Very similar question but asked from a different angle: (8126) (I am not marking as a duplicate.) $\endgroup$
    – Mr.Wizard
    Commented Aug 16, 2013 at 11:27

1 Answer 1

3
$\begingroup$

I believe this is due to special parsing just as I described in:
Infix form of PutAppend ( >>> ) does not work with variable.

  • You cannot assume that all input forms are valid syntax at an arbitrary place in an expression.

It was my interest in seeing how Mathematica was interpreting certain input (that is, what Box expression were being sent to the Kernel) that lead me to ask How can I get the unchanged Box form of an arbitrary expression?


Incidentally I just discovered that if I copy the expression out of a String rather than typing it directly it is accepted as valid input:

enter image description here

I can't explain why the copy makes a difference (I don't think it should) but we can see that it does by looked at the Cell Expressions (Shift+Ctrl+E):

Cell[BoxData[
 RowBox[{"FullForm", "[", 
  RowBox[{"Unevaluated", "[", 
   RowBox[{"?", "symbol"}], "]"}], "]"}]], "Input"]

Cell[BoxData[
 RowBox[{"FullForm", "[", 
  RowBox[{"Unevaluated", "[", 
   RowBox[{"?", "symbol]]"}]}]}]], "Input"]

Notice the unmatched brackets in the second expression, causing the error.

$\endgroup$
2
  • $\begingroup$ Thank you for the answer. Can this question be categorized as a "bug"? $\endgroup$
    – M6299
    Commented Aug 17, 2013 at 5:38
  • $\begingroup$ @M6299 You're welcome. I don't think it's a bug. I think rather, as stated, it is a nonstandard parsing designed for convenience, and it only works properly at the beginning of a line. $\endgroup$
    – Mr.Wizard
    Commented Aug 17, 2013 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.