[plt-scheme] easy way to see if something is defined?

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Wed Mar 24 12:06:30 EDT 2010

On Mar 24, 2010, at 11:31 AM, Carl Eastlund wrote:

> On Wed, Mar 24, 2010 at 10:41 AM, Todd O'Bryan  
> <toddobryan at gmail.com> wrote:
>> Is there a more efficient/idiomatic way to see if an identifier is
>> currently defined other than
>>
>> (member blah (namespace-mapped-symbols (current-namespace)))
>>
>> ?
>>
>> Todd
>
> That only works if the current namespace happens to correspond to the
> code you are running.  It often does not.  At runtime, there is
> probably no reliable way to find this out.

You can use 'define-namespace-anchor' and 'namespace-anchor- 
 >namespace' to get the right namespace. I haven't tried it, but the  
docs claim they work at the top level (that is, outside of modules) too.

Ryan



Posted on the users mailing list.