XLISP boundp

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# boundp

Type: | - | predicate function (subr)
Source: | - | xlbfun.c

## Syntax

(boundp symbol)
  symbol - a symbol expression
  returns - T if a value is bound to the symbol, NIL otherwise

## Description

The 'boundp' predicate function tests if 'symbol' evaluates to a symbol in the *obarray* with a value bound to it. T is returned if 'symbol' has a value, NIL is returned otherwise. Note that 'boundp' does not test if local let variables, or class or instance variables exist.

## Examples

    (setq a 1)            => 1    ; create a variable A in the *OBARRAY*
    (boundp 'a)           => T    ; variable A has a value 1

    (let ((b 'value))
      (boundp b))         => NIL  ; BOUNDP does NOT test LET bindings

    (defun foo (x)                ; create a function FOO in the *OBARRAY*
      (print x))          => FOO

    (boundp 'foo)         => NIL  ; FOO is not a variable

    (print myvar)         => error: unbound variable - MYVAR
    (boundp 'myvar)       => NIL

    (setq myvar 'abc)             ; give MYVAR a value
    (boundp 'myvar)       => T

Note that 'symbol' is a symbol expression. This means that 'symbol' is evaluated and the return value is tested:

    (setq myvar 'qq)              ; MYVAR evaluates to QQ
    (boundp myvar)        => NIL  ; but QQ has no value yet

    (setq qq 'new-value)          ; give QQ a value
    (boundp myvar)        => T

See also:

- Contents → Predicate Functions

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference