I believe this a question that most of us have encountered when we were beginners but forgot when we got more familiar with Mathematica.
We know the notation $y=y(x)$ for functions, where $y$ here simultaneously represents the functional relation and the dependent variable, isn't rare. We also know it's trouble in Mathematica because it'll cause infinite recursion:
y = y[x]
$RecursionLimit::reclim: Recursion depth of 256 exceeded. >>
Hold[y[x]][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x][x]...
This behavior makes the language strict, of course. But recently, when I found myself in a situation with some justification for using a lot of $y=y(x)$ style notation, the question in the title came to my mind: what if this notation were well behaved in Mathematica?
Needless to say, though quite similar, there're many differences between Mathematica syntax and traditional math notation. For most cases we can easily see the advantages of such deviations. For example, the strict distinctions of []
,()
,{}
,[[]]
. However, the advantage of the currently built-in behavior of y = y[x]
seems not to be obvious. In other words, I can't see what kind of problems will arise if a symbol were allowed to have OwnValues
and DownValues
at the same time. In such case, OwnValues
of a symbol would only be evaluated when the symbol is not the head of any expressions.
Can I achieve this feature in Mathematica?
Stack
, which makes it inefficient, and won't work if insideStackInhibit
. Otherwise, I think we have to wait until they create the attributeOnlyEvaluateIfNotHead
, or create theOnlyIfNotHeadOwnValues
$\endgroup$Map
,Apply
, etc $\endgroup$