architecture.hooks icon indicating copy to clipboard operation
architecture.hooks copied to clipboard

Redefining a function does not update the handler

Open Ambrevar opened this issue 6 years ago • 1 comments

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

Ambrevar avatar Sep 17 '19 12:09 Ambrevar

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.

scymtym avatar Sep 17 '19 12:09 scymtym