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

advise and watch really exist in sbcl? #503

Open
bo-tato opened this issue Jul 25, 2023 · 2 comments
Open

advise and watch really exist in sbcl? #503

bo-tato opened this issue Jul 25, 2023 · 2 comments

Comments

@bo-tato
Copy link

bo-tato commented Jul 25, 2023

Thanks for the cookbook it is an awesome resource. In the section on debugging under advise and watch it says:

They do exist in SBCL but are not exported.

That would be really great as being able to set a watch on some variable and breaking when it's modified is the one thing I miss from emacs lisp. I can't find anything else on this searching online, or searching the whole sbcl source code for "advise" and "watch".

@vindarel
Copy link
Contributor

ah yes, I miss it too. I actually saw that here: https://github.com/lisp-mirror/budden-tools/tree/213ab2b52a1b0c0b496efd30c3b5143f5c8e1ff2/cl-advice It "used to work on SBCL 1.4.2".

here they say

An advise-like mechanism has to be present in any CL implementation in order to support trace; it just isn't necessarily exposed.

@bo-tato
Copy link
Author

bo-tato commented Jul 26, 2023

great info, thanks! from that reddit link the same user notes you can implement advice yourself in ordinary common lisp without any special help from the implementation:

You can put a new function into a function binding with (set (symbol-function ) ). Your new function can call the old one (which you can keep in some table keyed on whatever), and do things around it. That is called "advice". Then later you can restore the old one. All of this can be done portably, and with compiled functions.

It seems that cl-advice library is calling sb-int:encapsulate, which is still present in latest SBCL, it seems internally SBCL calls advise/unadvise encapsulate/unencapsulate and is defined in src/code/fdefinition.lisp.
Still there is no watch in SBCL?

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