[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Example use of macro to minimize and generalize the code
From: |
Michael Heerdegen |
Subject: |
Re: Example use of macro to minimize and generalize the code |
Date: |
Tue, 01 Jun 2021 01:37:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis <bugs@gnu.support> writes:
> (defmacro when-tabulated-id (table id &rest body)
> (declare (indent 2) (debug t))
> (ignore id)
> `(if id
> (progn
> ,@body)
> (if (or (eq ,table 'any)
> (string-equal ,table rcd-current-table))
> (let ((id (tabulated-list-get-id)))
> (if id
> (progn ,@body)
> (message "Did not get ID")))
> (message "This function is for table `%s' only" ,table))))
There is something wrong with that definition however: the variable `id'
is completely ignored, specifying something at that argument position is
redundant.
Tt may "work" by accident if the symbol `id' happens to be dynamically
bound to the same thing that you specify as argument, but only when that
exact variable name is used and only in dynamically binding Lisp.
Normally the byte compiler warns about this kind of problem - of course
only if you don't silence it ;-)
Michael.
- Re: Why is defun not executed during load-file?, (continued)
- Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/30
- Re: Why is defun not executed during load-file?, Emanuel Berg, 2021/05/30
- RE: [External] : Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/30
- Re: [External] : Re: Why is defun not executed during load-file?, Emanuel Berg, 2021/05/30
- RE: [External] : Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Emanuel Berg, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Stefan Monnier, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Marcin Borkowski, 2021/05/31
- Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Re: Example use of macro to minimize and generalize the code,
Michael Heerdegen <=
- Re: Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Michael Heerdegen, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Michael Heerdegen, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Example use of macro to minimize and generalize the code (2), Jean Louis, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Michael Heerdegen, 2021/05/31
- RE: [External] : Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/31