[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Easy way to find if a variable is already defined?

From: felix winkelmann
Subject: Re: [Chicken-users] Easy way to find if a variable is already defined?
Date: Wed, 23 Feb 2005 06:13:11 +0100

On Wed, 23 Feb 2005 04:40:35 +0100, Sunnan <address@hidden> wrote:
> Is there a (standard or chicken-specific) way to find out if a variable
> is already defined or not? Eg:
> (defined? xyzzy)
> -> #f
> (define xyzzy (lambda () 'test))
> (defined? xyzzy)
> -> #t

In the manual, you will find the following (unit lolevel):
 Accessing toplevel variables

 - procedure: global-bound?
          (global-bound? SYMBOL)
     Returns `#t', if the global ("toplevel") variable with the name
     `SYMBOL' is bound to a value, or `#f' otherwise.

 - procedure: global-ref
          (global-ref SYMBOL)
     Returns the value of the global variable `SYMBOL'.  If no variable
     under that name is bound, an error is signalled.

 - procedure: global-set!
          (global-set! SYMBOL X)
     Sets the global variable named `SYMBOL' to the value `X'.

> What about other environment inspecting stuff? CL has lots of these, and
> I'm wondering if they're available for Chicken as well, or if I have to
> do without.

This might be helpful as well:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]