Functions, Options and Symbols

This question can be answered programmatically, at least to some extent. If we restrict ourselves to System` context only, then:

names = Names["System`*"];

optnames = 
  Quiet@Union@
     Cases[
       ToExpression[
          #, 
          StandardForm, 
          Function[name, Options[Unevaluated[name]], HoldAll]
       ] & /@  names, 
       (name_Symbol -> _) :> Hold[name], 
       Infinity];

symbols = 
    ToExpression[
        #, 
        StandardForm, 
        Function[name, 
           If[SyntaxInformation[Unevaluated@name] =!= {}, Hold@name, {}], 
           HoldAll]
        ] & /@ names;

Intersection[optnames,symbols]

(*  {Hold[Eliminate],Hold[NotebookFileName],Hold[Sort],Hold[TimeZone],Hold[Tooltip]} *)

where I assumed that a function is a symbol with a non-trivial value of SyntaxInformation. This is likely not the best criteria, but I think it is good enough, given that many system functions have their internal ...Values not reflected by the ...Values top-level functions.

My understanding has been that such symbols are rare and the parctice to have a symbol as both a function and a name of the option is generally discouraged. But such symbols do exist, and I have no doubts that there are many more instances than those found here, both because the criteria I used here may be too strict (for example, uses of symbols lile PlotRange as a function aren't documented and don't have non-trivial SyntaxInformation attached to them), and so I may have missed some, and also because they may exist in other contexts not considered here.

Your second question could be answered in a similar fashion: here are the symbols which have values (but not necessarily top-level OwnValues):

ownsymbols = 
   Cases[ 
      ToExpression[#, StandardForm, Hold] & /@ names, 
      Hold[s_] /; Hold[s] =!= Hold[Evaluate[s]]
   ];

we can now see if there is any overlap with the other two groups:

Intersection[ownsymbols,symbols]

(* {Hold[NotebookInformation]} *)

Intersection[ownsymbols,optnames]

(* {} *)

so, some symbols having a value apparently may be functions (although probably the dominant set of such use cases would be aliases, like in the case of NotebookInformation), while, at least among the System` functions, symbols standing for option names appear to not have values. We can probably expect this last conclusion to be true in general, since Options isn't HoldAll, and therefore the option names having (Own)values don't make much sense since they will evaluate to their values before being seen by Options and other option-related functions.

Finally, a number of functions which are implemented using the auto-loading mechanism, initiallu have OwnValues attached to their symbols, which then later get removed and replaced by DownValues and / or SubValues, once the function has been loaded. They never have both at the same time though.

Tags:

Symbols