chicken-users
[Top][All Lists]
Advanced

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

Re: Question about how to check a symbol is bound


From: Shawn Wagner
Subject: Re: Question about how to check a symbol is bound
Date: Thu, 22 Jun 2023 22:28:16 -0700

Looks like unbound? and symbol-value take quoted symbols if passing them directly: And for list you have to use the transformed name scheme#list

#;2> (unbound? 'x)
#t
#;3> (define x 1)
#;4> (unbound? 'x)
#f
#;5> (symbol-value 'x)
1
#;6> (symbol-value 'scheme#list)
#<procedure (scheme#list . lst)>

On Thu, Jun 22, 2023 at 10:15 PM Pan Xie <xiepan@skyguard.com.cn> wrote:
Hello

I am new to CHICKEN scheme and here is a (very) quick question of how to
check whether a symbol is bound.

I know it doable but I can't find the way.

I don't find the methods from the main CHICKEN manual document. Then I
import the "symbol-value-utils" module. I believe the "unbound?" or
"symbol-value" will do what I want, but to my surprise they does NOT:

I expect `symbol-value' will give me value of a symbol, but it will
throw exception for an
undefined symbol, even I provide the default value:

(symbol-value foo #f)
Error: unbound variable: foo

I expect (symbol-value (string->symbol "list")) will give me the list
procedure, but what I get is '#f'

(symbol-value (string->symbol "list"))
#f

I expect (unbound? foo) will return True value, but it just throw exception.

Does CHICKEN scheme provide facilities that make user check whether
arbitrary symbol is bound or get its value, just like the `boundp' or
`symbol-value' in Common Lisp?

Thanks
Pan



reply via email to

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