[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] (Updated) Run hook when variable is set
From: |
Stefan Monnier |
Subject: |
Re: [PATCH] (Updated) Run hook when variable is set |
Date: |
Sat, 07 Feb 2015 10:09:38 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> Your goal is to avoid the «if» at the end. In order to do that, you'd need
> two functions:
> (defun set-internal-1 (args)
> (block nil
> (if (constant-p)
> (if hooked ; Mutually exclusive with actual constant
> (progn
> (set-internal-1-and-run-varhook args)
> (return))
> (if (forbidden-p)
> (error "setting constant")
> (return))))
> (do-some-stuff)
> (and-many-more-lines-of-stuff)
> (set-some-variable)))
> (defun set-internal-1-and-run-varhook (args)
> (do-some-stuff)
> (and-many-more-lines-of-stuff)
> (set-some-variable)
> (run-varhook))
No, the idea was rather to do:
(defun set-internal-1 (args)
(block nil ; Because Elisp isn't CL
(if (constant-or-hooked-p)
(if (constant-p)
(if (forbidden-p)
(error "setting constant")
(return))
(funcall symbol-watch-function ..args..))
(do-some-stuff)
(and-many-more-lines-of-stuff)
(set-some-variable))))
> I'd like to bikeshed the function names a bit more. Handler functions for
> varhook are already capable of not only reading variables, but also writing
> them. And now, writing (or blocking of writing) is actually going to be one
> of the intended use cases. That means ‟watch” is a misleading way of
> describing it; watching (which implies only reading) is only one of the
> things that a handler might do.
I think watchpoints usually have the functionality of catching the
modifications, being able to see the "before-change value" and being
able to replace the assignment with something else. So "watch" makes
a lot of sense to me.
> BTW, why is the order of the first two arguments to advice-add reversed from
> add-function? And the words in their names too.
Don't ask,
Stefan
- Re: [PATCH] Run hook when variable is set, David Kastrup, 2015/02/01
- Re: [PATCH] Run hook when variable is set, Kelly Dean, 2015/02/02
- Re: [PATCH] Run hook when variable is set, Stefan Monnier, 2015/02/02
- Re: [PATCH] Run hook when variable is set, Kelly Dean, 2015/02/03
- Re: [PATCH] Run hook when variable is set, Stefan Monnier, 2015/02/03
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/04
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/05
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/06
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/06
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/07
- Re: [PATCH] (Updated) Run hook when variable is set,
Stefan Monnier <=
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/08
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/12
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/13
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/13
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/14
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/15
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/16
- Re: [PATCH] (Updated) Run hook when variable is set, Richard Stallman, 2015/02/17
- The purpose of makunbound (Was: Run hook when variable is set), Kelly Dean, 2015/02/17
- Re: The purpose of makunbound, Stefan Monnier, 2015/02/18