smithzv wrote:I wanted to know if APPLY is some kind of black box function/language primitive. I was under the impression that the only language primitives are special operators/forms (perhaps from the first few chapters I got to read of Lisp in Small Pieces). I think maybe this is just plain false.
It's not like APPLY can't be implemented on top of other primitives, but in general, you can't reimplement your Lisp implementation's version of APPLY portably. The situation is the same as for everything else that deals with some kind of data structure.
How do you replace CAR with a function of your own? Well, you can't; the only thing you can do is redefine what a cons cell is (using closures, for example) and then rip out everything that deals with cons cells and reimplement it in terms of your newly defined data structure. In this sense, CAR is a primitive operation. You can't replace it without reimplementing most of Common Lisp because cons cells are defined in terms of CONS, CAR, CDR, RPLACA, and RPLACD.
Functions, likewise, are defined in terms of LAMBDA and APPLY (and maybe some more). If you want to reimplement APPLY, you'll have to redefine what a function is and rewrite LAMBDA, DEFUN, FUNCTION, et cetera accordingly (which would likely affect almost every component in the system including the loader, so I imagine you'd effectively have to replace all of Common Lisp in this case).
If you're the implementor of a Common Lisp system, there is some merit in only implementing a few primitives and defining everything in terms of these, and you can probably do so, but as a user of someone else's system, you don't retain quite the same power.