[gambit-list] Determine if symbol is bound

Marc Feeley feeley at iro.umontreal.ca
Mon May 9 09:55:11 EDT 2011


On 2011-05-08, at 4:30 PM, William James wrote:

> How do you check to see if a symbol is already bound?
> To be used in this fashion:
> 
> (if (bound? x)
>  (set! x 22)
>  (define x 22))

This is the official way to test is a global variable is bound:

(define (bound? name)
  (not (##unbound? (##global-var-ref (##make-global-var name)))))

Marc





More information about the Gambit-list mailing list