[gambit-list] Determine if symbol is bound

REPLeffect repleffect at gmail.com
Fri May 20 14:05:05 EDT 2011


On Fri, May 20, 2011 at 9:52 AM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>
> On 2011-05-20, at 10:40 AM, REPLeffect wrote:
>
>> On Mon, May 9, 2011 at 8:55 AM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>>>
>>> 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
>>>
>>
>> I tried this running this in the interpreter, and got the following result:
>>
>>> (define (bound? name)
>>      (not (##unbound? (##global-var-ref (##make-global-var name)))))
>>> (bound? mytest)
>> *** ERROR IN (console)@1779.9 -- Unbound variable: mytest
>> 1>
>>
>> Am I missing something?  'mytest' was undefined, obviously, but
>> shouldn't bound? have returned #f ?
>
> Try
>
>  (bound? 'mytest)
>
> Marc
>
>
>

oh, duh.  Now I feel really stupid.  :-D



More information about the Gambit-list mailing list