Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defhook does not replace hooks #49

Closed
AlbertoEAF opened this issue Sep 14, 2021 · 2 comments
Closed

defhook does not replace hooks #49

AlbertoEAF opened this issue Sep 14, 2021 · 2 comments

Comments

@AlbertoEAF
Copy link

AlbertoEAF commented Sep 14, 2021

The API of (defhook :before/:after *hook-body*) is not usable for running lisp images / interactive development. Every time the defhook form is met, which happens when reloading the file / test system or running the file again, etc., will result in adding another hook.

Adding a function named (rove:clean-hooks) would work:

(setf (ROVE/CORE/SUITE/PACKAGE::suite-before-hooks (ROVE/CORE/SUITE/PACKAGE:package-suite *package*)) nil)

but wouldn't be elegant to have to call it explicitly in the file.

The problem is the hook calls will keep adding up. I.e., if my hook is a (format t "hook!") every time I run (asdf:test-system :my-system) or reload the file I'll have more and more "hook!" messages showing up before each test.

I see no other solution than naming the hook, so that when the defhook form is met it can replace the old definition. E.g.:

(defhook my-db-hook :before 
    ...hook-body)
@fukamachi
Copy link
Owner

Sounds troublesome.
I prefer your idea, naming hooks. It would have the same issue as #50, though.

@AlbertoEAF
Copy link
Author

Thanks Eitaro :)
Can you add this to the readme? The new named defhook form. Otherwise users won't guess this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants