[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Translator
Date: Fri, 14 Sep 90 21:22 EDT
From: barmar@Think.COM (Barry Margolin)
Date: Fri, 14 Sep 90 20:20 EDT
From: RWK@fuji.ila.com (Robert W. Kerns)
APPLY does not use hash tables. However, for maximum speed and
minimum paging, you should pass actual functions, and not
symbols, to apply. I.e
(setf (gethash name *name->function-table*) #'rewrite-function)
not
(setf (gethash name *name->function-table*) 'rewrite-function)
However, you should note that this mechanism can be a pain during
development. If you redefine REWRITE-FUNCTION after storing the
function in the table the first way, you will continue to call the old
definition when you extract it, while the second form will cause the
current function binding of the symbol always to be used.
I campaigned (and won) for automatic coercion of symbols to functions by
APPLY, FUNCALL, etc. in X3J13 for precisely this reason. I've seen
users burned many times when they store a function in a data structure,
load a patch file that fixes a bug in the function, yet the bug still
appears.
An intermediate strategy is to store the location of the function cell
(LOCF #'rewrite-function) and then use LOCATION-CONTENTS in conjunction with
the APPLY or FUNCALL. This will get the new definition when a redefinition
occurs, but will avoid the paging overhead of having to reference the symbol
(which is likely to be far away from the function cell).
I also applaud Genera 8.0's enhancement to the printed representation of
functions: a function object that isn't the current binding of its name
symbol has "(Superceded)" in the printed rep.
I hope, it has "(Superseded)" which is the correct spelling. ;-> (I just checked,
it does.)
barmar
- References:
- Translator
- From: barmar@Think.COM (Barry Margolin)