The ability to manipulate symbols is such a great strength of elisp and lisp in general, and if I understand symbols correctly, I think the symbol system makes it effortless to programmatically access and modify variables, to the extent that the notion of modules and scopes become just special cases. But there is one aspect of symbols in elisp which I just cannot comprehend, namely that it has both a symbol-value and a symbol-function. It bothers me because:
Conceptually, I think it breaks the principle of first-class functions, that functions are on the same footing as other values, for it is literally forcing a divide in between;
Perhaps due to my inexperience, I haven’t yet encountered any situation where this becomes useful.
So I wish to ask, what do you think about this design? Why was there a distinction between symbol-value and symbol-function in the first place, when you can treat functions themselves as values? Was it merely due to historical reasons, that when elisp was designed, the functional programming paradigm was still immature? Is there any virtue in, or any theoretical justification for, this division? And at last, how is it most commonly utilized?
Thanks! This actually helps. My initial reaction upon reading your reply and trying it out, was that some heterogeneity is still there, in that the manner of invocation for the function is different depending on whether it is in the value slot or the function slot. But then it occurred to me, that this heterogeneity does lead to a possible rationale for the distinction between the value cell and the function cell: the value slot is to be thought of as specifying how the symbol behaves as a “passive” object (hence the need for funcall even when the value slot is a function), and the function slot as specifying how the symbol “acts” on others (hence no funcall). It’s not “function vs not-a-function”, but “active vs passive”.
Also, I stumbled upon this article, if you or anyone else is interested, you can give it a read. I haven’t gone through it yet, but somewhere down the lines it says:
In Lisp1, the functional position of a form and the argument positions of forms are evaluated according to the same rules. In Lisp2, the rules for evaluation in the functional position of a form are distinct from those for evaluation in the argument positions of the form.
Which confirms that, at least in elisp, the treatment is indeed different.