En Emacs Lisp, ¿cómo compruebo si una variable está definida?
En Emacs Lisp, ¿cómo compruebo si una variable está definida?
80
4 answers
Es posible que desee boundp: devuelve t si la variable (un símbolo) no es nula; más precisamente, si su enlace actual no es nulo. Devuelve nil de lo contrario.
(boundp 'abracadabra) ; Starts out void.
=> nil
(let ((abracadabra 5)) ; Locally bind it.
(boundp 'abracadabra))
=> t
(boundp 'abracadabra) ; Still globally void.
=> nil
(setq abracadabra 5) ; Make it globally nonvoid.
=> 5
(boundp 'abracadabra)
=> t
125
Author: dfa,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-04-17 01:13:20
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-04-17 01:13:20
Además de la respuesta de dfa es posible que también desee ver si está enlazada como una función usando fboundp:
(defun baz ()
)
=> baz
(boundp 'baz)
=> nil
(fboundp 'baz)
=> t
39
Author: Jacob Gabrielson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:25:54
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:25:54
Si desea verificar un valor de variable desde emacs (no se si esto aplica, ya que escribió "in Emacs Lisp"?):
M-:
inicia Eval
en el mini búfer. Escriba el nombre de la variable y pulse intro. El mini-buffer muestra el valor de la variable.
Si la variable no está definida, se obtiene un error del depurador.
3
Author: Gauthier,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-06-29 12:01:09
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-06-29 12:01:09
Recuerde que las variables que tienen el valor nil se consideran definidas.
(progn (setq filename3 nil)(boundp 'filename3)) ;; returns t
(progn (setq filename3 nil)(boundp 'filename5)) ;; returns nil
0
Author: cjohansson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-07 05:28:37
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-07 05:28:37