3 ms·
A function is an object. When we redefine a global function, we're simply replacing the symbol's function binding to point to a new function object. That can be
by kazinator 8y ago
A function is an object. When we redefine a global function, we're simply replacing the symbol's function binding to point to a new function object. That can be an atomic operation: a word-sized cell is overwritten.
If one or more threads are executing the old function, then they continue to do that. That object is referenced by those threads and so doesn't become garbage until the last thread stops executing it. Newly issued calls to that function go to the new one through the newly established binding.
ANSI CL allows functions that are in the source file (actually compilation unit) to use more efficient calling; they don't have to go through the global symbol function binding. The idea is that compilation units are replaced at once, rather than individual functions. Call optimizing behavior can be overridden for individual functions by declaim-ing them notinline.
- register 8y agoOk so this means that calls accross compilation units always incur an indirection, right? Also I don't get how swapping the whole compilation unit can be achieved atomically. A compilation unit might be composed by several functions. Where can I find more? I have tried to look in the literature but haven't found anything that reaches this level of detail.
- segmondy 8y agodo you understand lisp symbols? read up on it and try to understand how they are represented internally, that's the key.