Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
2  
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. –  Nasser Aug 16 '13 at 8:45
    
Very similar question but asked from a different angle: (8126) (I am not marking as a duplicate.) –  Mr.Wizard Aug 16 '13 at 11:27

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Thank you for the answer. Can this question be categorized as a "bug"? –  M6299 Aug 17 '13 at 5:38
    
@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. –  Mr.Wizard Aug 17 '13 at 14:16

Your Answer

 
discard

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

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