architecture.hooks
architecture.hooks copied to clipboard
Redefining a function does not update the handler
Recipe:
(defvar *my-hook* nil
"My hook is only run for educational purposes.")
(defun foo ()
17)
(hooks:add-to-hook '*my-hook* #'foo)
(hooks:run-hook '*my-hook*)
; 17
(defun foo ()
18)
(hooks:run-hook '*my-hook*)
; 17
I believe this is because add-to-hook takes a function value as parameter and not a symbol.
Since cl-hooks is meant to be used mostly by the end user, I believe it should behave in the most expected way, so taking a symbol could help here.
What about adding support for both symbols and function values? This way the user could decide which handler should change upon function redefinition and which one should not.
But may be that would be more confusing.
Thoughts?
CC @vindarel
What about adding support for both symbols and function values? This way the user could decide which handler should change upon function redefinition and which one should not.
I agree.