The 'boundp' predicate function checks to see if 'symbol' is a symbol with a value bound to it. T is returned if 'symbol' has a value, NIL is returned otherwise. Note that 'symbol' is a symbol expression. It is evaluated and the resulting expression is the one that is checked.
(setq a 1) ; set up A with value 1 (boundp 'a) ; returns T - value is 1 (defun foo (x) (print x)) ; set up function FOO (boundp 'foo) ; returns NIL - value is closure (boundp 'defvar) ; returns NIL - value is closure (boundp 'car) ; returns NIL - value is closure (print myvar) ; error: unbound variable (BOUNDP 'myvar) ; returns NIL (setq myvar 'abc) ; set up MYVAR with a value (BOUNDP 'myvar) ; returns T - because of SETQ (setq myvar 'qq) ; set up MYVAR to have value QQ (BOUNDP myvar) ; returns NIL - because QQ has ; no value yet (setq qq 'new-value) ; set QQ to have value NEW-VALUE (BOUNDP myvar) ; returns T
See the
boundp
predicate function in the