Following the comments on the answer here I would like to know if there is a way to deduce from the documentation if a built-in expression is a function or simply "a variable that stores something".

For the motivation you can look here: without knowing if object are wrapper or not it would have been impossible for me to know that First[ContourPlot] gives the good variable to provide to Epilog for instance.

For instance, looking at the docs for graphics, it is not possible to understand that "primitives" and "options" are not parameter to provide to the function "Graphics" but actually what is stored in a Graphics type variable.

I find the documentation extremly confusing to learn, which is why I ask my question.

Thus, my question is precisely:

  • Is there a way from the documentation to know if the expression is a function or a variable storing something
  • If not, can I use some way in Mathematica to know it
  • $\begingroup$ primitives and options are parameters to the Graphics function which constructs the graphics. That's what the documentation is saying by writing it as Graphics[primitives, options]. Usually the parameters are italicized and lowercase in the documentation, while the function names and directives start uppercased and are hyperlinked / blue. The Graphics doesn't store anything. It's a function that takes a bunch of primitives, directives and options, and it takes that recipe to render the graphics. $\endgroup$ – flinty Oct 1 '20 at 22:37
  • $\begingroup$ Why do you need to know? $\endgroup$ – Rohit Namjoshi Oct 1 '20 at 23:18
  • $\begingroup$ @flinty the "issue" is that Graphics is an inert wrapper and not so much a function (the rendering is technically also not really done by Graphics and more by MakeBoxesand the FE). If you look at the linked question, you can see that OP is asking how one can tell that a symbol is such an inert wrapper, and that it is therefore possible to extract the primitives simply by applying First. $\endgroup$ – Lukas Lang Oct 2 '20 at 6:07
  • 1
    $\begingroup$ @StarBucK It says in the documentation about Epilog it is expecting primitives. It says in the documentation for things like Polygon and Line (expand the details and options section) that xxx can be used as a geometric region or a graphics primitive. If you do x = ContourPlot[...]; Head[x] you get a Graphics. So you know x is a graphics and the form of Graphics is Graphics[primitives, options], so you know the First argument is a list of primitives. If a function f is like a wrapper thing, then its Head doesn't change when the function is used, e.g Head[f[2]] === f $\endgroup$ – flinty Oct 2 '20 at 13:40
  • 1
    $\begingroup$ ... and Head[Graphics[{Red, Disk[]}]] is still a Graphics. By the way, if you want a list of primitives, expand the details and options section in the Graphics documentation where it says The following graphics primitives can be used:... . Primitives are things like Arrow, AASTriangle, Disk, BezierCurve etc... $\endgroup$ – flinty Oct 2 '20 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.