As this post has discussed, UpValues are certainly useful, and as this post has discussed, g /: f[g[x_]] := h[x] is not equivalent to f[g[x_]] := h[x], but that's not the point. It appears that other languages don't provide the alleged UpValues in general.
So, my question is: can UpValues and other *Values all always be converted to DownValues (rather than asking for those distinctions)? And if not, does this mean that one can never implement the same functionalities in MMA's competitive products (like Maple and Mathics)?
Asked
Active
Viewed 99 times
4
user688486
- 485
- 1
- 7
1 Answers
2
This is not an answer but a comment with image.
Certainly the UpValues can be converted to DownValues and the SubValues can be curried to DownValues manually, but then we mess up the bindings of symbols.
Before embracing associations I usually used the DownValues, UpValues and SubValues to store data.
Although there is no native OOP in Mathematica, we can treat certain symbols e.g. class as class like,
masterOf[class]^=...
servantOf[class]^=...
isProtected[class]^=...
class["some instance"]=...
...
For example, the GR packages xAct`* use this method to manage relations between geometric objects

So UpValues is quite useful to make the dependencies of symbols more structured.
But with the more powerful Association and the interface Dataset, we can free ourselves from the cumbersome symbol management.
Lacia
- 2,253
- 3
- 19
DownValuesareProtectedand/orLocked. – QuantumDot Feb 28 '23 at 19:50OwnValuesandSubValuescan be converted toDownValues? – Jason B. Feb 28 '23 at 20:22(*x=.;*)Language`ExtendedFullDefinition[Global`x]givesLanguage`DefinitionList[x->{OwnValues->{},SubValues->{},UpValues->{},DownValues->{},NValues->{},FormatValues->{},DefaultValues->{},Messages->{},Attributes->{Protected}}]; I think that other values are as important as downvalue. – user688486 Mar 01 '23 at 04:16OwnValueviax=14. What does it mean to "convert" that to aDownValue? – Jason B. Mar 01 '23 at 13:02DownValuesandUpValues. However, the main focus of attention is simply upvalue and downvalue, so I have edited my problem. – user688486 Mar 01 '23 at 14:26