4

What is the difference between ? Definition and ?? Information?

If I define two functions for the same symbol

f[x_] := Cos[x]
f[b_, c_] := Sin[b c]

I get the same result for ?f and ??f

enter image description here

I've read the documentation, but it's not giving me a real sense of the difference. Are there different use cases? Can I always use one of these (? or ??) and ignore the other?

ps. Which tags are appropriate for this question?

István Zachar
  • 47,032
  • 20
  • 143
  • 291
TransferOrbit
  • 3,547
  • 13
  • 26

1 Answers1

7

Actually, while the input escape ?? is shorthand for Information, ? is not a shorthand for Definition (though ? might use Definition). Basically, if there is a usage message defined, ? returns that, if not, it returns definitions. Information and ?? always return everything accessible. Compare:

In[25]:= f[x_] := Cos[x]
f[b_, c_] := Sin[b c]
f::usage = "blahblah";

Definition@f
 f[x_] := Cos[x]

f[b_, c_] := Sin[b c]

?f (* prints usage message if exists, Definitions[f] otherwise *)
  blahblah
Information@f (* same as ??f *)
blahblah

f[x_]:=Cos[x]

f[b_,c_]:=Sin[b c]

According to the documentation under Document Constructs:

Mathematica graphics

Of course, any definition is only printed if the symbol is not ReadProtected. Information itself is ReadProtected, hence only attributes and options are listed:

Definition@Information
Attributes[Information] = {HoldAll, Protected, ReadProtected}

Options[Information] = {LongForm -> True}

Compare the above to the extensive output produced by PrintDefinitions, that delves deep into the symbol's definition (large output is omitted):

Needs["GeneralUtilities`"];
PrintDefinitions@Information

Furthermore, you can abuse the ? operator to ask about multiple functions:

?*Chart

Mathematica graphics

István Zachar
  • 47,032
  • 20
  • 143
  • 291