Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug?? [defined? and modules]
Chris Bitmead <chrisb@ans.com.au> writes:
> Does the following behaviour indicate a bug??
>
> guile> dynamic-link
> #<primitive-procedure dynamic-link>
> guile> (defined? dynamic-link)
> ERROR: In procedure defined? in expression (defined? dynamic-link):
> ERROR: Wrong type argument in position 1: #<primitive-procedure
> dynamic-link>
> ABORT: (wrong-type-arg)
No. `define?' is a normal procedure and you have to pass it a symbol.
`defined?' could be defined like this
(define (defined? symbol)
(module-defined? (current-module) symbol))
I suggest you use `module-defined?' directly to be explicit about the
module issues. Using the current-module is probably not what you want
most of the time.
The current-module is the module that is current when the code is
*evaluated*, not the module in which it is defined. You probably want
to use the current-module only at the top-level, or when working in
the innards of the module system itself.
A typical use is maybe
(define-module (my module)
:use-module (his module))
(define my-module (current-module))
(define (foo)
(if (module-defined? my-module 'bar)
(do-something-with bar)))
Using `defined?' would not be the same thing, because the
current-module can be anything when foo is evaluated.
- References:
- Bug??
- From: Chris Bitmead <chrisb@ans.com.au>
Guile Home |
Main Index |
Thread Index