16
$\begingroup$

Robby Villegas here shows a nice way to see all the types associated with a symbol. He sets a symbol, valueTypes, to an explicit list of the values types in version 3.0 of Mathematica (I took off his dollar sign (he wrote $ValueTypes) so as not to give the false impression that valueTypes is provided by the system --- Robby just writes it out from some other source, maybe just deep knowledge or the source code):

valueTypes = {Attributes, DefaultValues, DownValues, FormatValues, 
   Messages, NValues, OwnValues, Options, SubValues, UpValues};
Through[valueTypes[Unevaluated[E]]]
{{Constant, Protected, ReadProtected}, {}, {}, {HoldPattern[MakeBoxes[E, _]] :> 
"\[ExponentialE]"}, {HoldPattern[E::usage] :> "E is the exponential constant 
\[ExponentialE] (base of natural logarithms), with numerical value 
\[TildeEqual] 2.71828."}, {}, {}, {}, {}, {}}

This was way back in version 3. We're at version 10.2, now, and I wonder whether any new "value types" have been added to the system.

Is there an authoritative list of these types, either in the documentation or in a system-supplied symbol I can inspect?


The question "Copying one symbol into another" is about a similar, but non-identical problem. Why is my question not a duplicate? The solution to copying involves the function Language`ExtendedDefintion, which explicitly lists the following value types:

In[1]:= Language`ExtendedDefinition[f]

Out[1]= Language`DefinitionList[HoldForm[f] -> 
  {OwnValues -> {}, SubValues -> {}, UpValues -> {}, 
   DownValues -> {}, NValues -> {}, FormatValues -> {}, 
   DefaultValues -> {}, Messages -> {}, Attributes -> {}}]

Note that it does not list Options. Options are instead stored within DefaultValues for some reason:

In[2]:= Options[f] = {a -> 1};
In[3]:= Language`ExtendedDefinition[f]

Out[3]= Language`DefinitionList[HoldForm[f] -> 
      {OwnValues -> {}, SubValues -> {}, 
       UpValues -> {}, DownValues -> {}, NValues -> {}, 
       FormatValues -> {}, DefaultValues -> {HoldPattern[Options[f]] -> {a -> 1}}, 
       Messages -> {}, Attributes -> {}}]

This shows that Options and Default are somehow different from the other value types, and they are both stored inside DefaultValues. Yet they still fit the description of "values associated with a symbol" (and are listed by Definition). I would like to have a full list of such value types, including Options and Default.

$\endgroup$
6
  • 3
    $\begingroup$ Related: Copying one symbol into another $\endgroup$
    – jkuczm
    Commented Jul 31, 2015 at 13:48
  • $\begingroup$ Doesn't Language`ExtendedDefinition from related question give you the answer to whether there is an authoritative list? "Access" versus "access & storage" (of symbol values) seems a minor distinction. The second sentence is the reason people are not encouraged to delete duplicates, because they provide different routes to the same answer. The actual questions posed in duplicates often reflect the views of different people who don't completely understand the issues at hand (or why would they ask?).... $\endgroup$
    – Michael E2
    Commented Aug 1, 2015 at 13:33
  • 1
    $\begingroup$ ...Their different views can be helpful to others who search for solutions to problems that have the same answer. In your case, you already have eight upvotes, a considerable reward, and there is no penalty if the community marks the question a duplicate. Sometimes a question is literally an exact duplicate and it receives no upvotes. Other times, the questions should be linked and the community still values it. But it's not clear to me whether you're disagreeing with the close-votes or clarifying why you asked in the first place. $\endgroup$
    – Michael E2
    Commented Aug 1, 2015 at 13:33
  • $\begingroup$ @Michael I was asked to edit my question and explain why I thought it wasn't a duplicate. I struggled a bit to express why I thought not, and you've added good clarity that the value of the question is that it adds another path to the answer, though the two paths are close. There is another point on which I now have more clarity, implied by your question, and I didn't have that clarity when I wrote my edit. That's on the difference between "closed" and "deleted." I would not object to the question's being closed, but I don't think it should be deleted if it can still help others. $\endgroup$
    – Reb.Cabin
    Commented Aug 2, 2015 at 1:33
  • 1
    $\begingroup$ I hijacked your question a bit. :-) Please check it and just revert if you disagree. $\endgroup$
    – Szabolcs
    Commented Aug 3, 2015 at 15:56

1 Answer 1

9
$\begingroup$

Thanks to the link to "Copying one symbol into another" in jkuczm's comment, I found a partial answer with Language`ExtendedDefinition. For instance:

Language`ExtendedDefinition[Log]
Language`DefinitionList[Log->{
OwnValues->{},
SubValues->{},
UpValues->{},
DownValues->{},
NValues->{},
FormatValues->{HoldPattern[MakeBoxes[Log[BoxForm`b_,BoxForm`z_],TraditionalForm]]:>RowBox[{SubscriptBox[log,MakeBoxes[BoxForm`b,TraditionalForm]],(,MakeBoxes[BoxForm`z,TraditionalForm],)}]},
DefaultValues->{},
Messages->{HoldPattern[Log::usage]->Log[z] gives the natural logarithm of z (logarithm to base e). Log[b,z] gives the logarithm to base b. },
Attributes->{Listable,NumericFunction,Protected}}]

I say "partial" only because there is a slight mystery: in my notebook, I had to actually evaluate the symbol Log before its Messages attribute showed any value. Small point.

$\endgroup$
5
  • 1
    $\begingroup$ So the answer to your posted question is really that nothing has changed since Villegas wrote his paper? $\endgroup$
    – m_goldberg
    Commented Jul 31, 2015 at 15:51
  • $\begingroup$ Looks like nothing has changed since V 3.0, which is remarkable. The implied bigger question was having a way to tell what all the attributes of a symbol are so that I can write programs to manipulate them (metaprogramming). $\endgroup$
    – Reb.Cabin
    Commented Jul 31, 2015 at 19:59
  • 2
    $\begingroup$ Just one issue to keep in mind (maybe related to the missing Messages, too): Attributes of built-in functions can be misleading unless you evaluate the function to force auto-loading of missing information. See here. So in other words, you can't always get accurate information about the language before actually using it... $\endgroup$
    – Jens
    Commented Jul 31, 2015 at 22:00
  • 1
    $\begingroup$ There's also Options, which you mentioned in the question but Language`ExtendedDefinition doesn't show. They show up in the DefaultValues for some reason ... Your original list was more complete than this one. $\endgroup$
    – Szabolcs
    Commented Aug 3, 2015 at 15:37
  • 1
    $\begingroup$ BTW this also answers why this probably should NOT be considered a duplicate. While Language`ExtendedDefinition is useful for copying everything associated with a symbol, it doesn't trivially show us what sorts of things may potentially be associated with a symbol. A naive use of this function didn't return Options! $\endgroup$
    – Szabolcs
    Commented Aug 3, 2015 at 15:38

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.