* defined? in module
@ 2009-07-05 13:18 Daniel Kraft
2009-07-17 14:54 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Kraft @ 2009-07-05 13:18 UTC (permalink / raw)
To: guile-user
Hi,
I'm trying to check if a given name is bound within some module. It
seems (from the documentation) that module objects are considered
environments; but this does not work:
scheme@(guile-user)> (defined? 'abc (current-module))
Backtrace:
In unknown file:
?: 0* [#<vm b7a8e650> #<program b70ac450 at <unknown port>:1:0 ()>]
2: 1* [#<program b70ac450 at <unknown port>:1:0 ()>]
?: 2* [defined? abc {#<directory (guile-user) 80bb3f0>}]
ERROR: In procedure defined?:
ERROR: Wrong type argument in position 2: #<directory (guile-user) 80bb3f0>
So, what's wrong here and how to do this correctly? (I know that
testing for 'abc in current-module is trivial, but say I want to find
out about 'abc in (language elisp runtime value-slot) for instance.)
BTW, finally, I want to do this in Tree-IL. But if I manage to do it in
Scheme, changing to Tree-IL is trivial.
Thanks a lot,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: defined? in module
2009-07-05 13:18 defined? in module Daniel Kraft
@ 2009-07-17 14:54 ` Ludovic Courtès
2009-07-24 12:05 ` Andy Wingo
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2009-07-17 14:54 UTC (permalink / raw)
To: guile-user
Hello Daniel,
I realized this question was left unanswered.
Daniel Kraft <d@domob.eu> writes:
> I'm trying to check if a given name is bound within some module. It
> seems (from the documentation) that module objects are considered
> environments; but this does not work:
>
> scheme@(guile-user)> (defined? 'abc (current-module))
You want to use `module-defined?':
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (module-defined? (current-module) '+)
#t
--8<---------------cut here---------------end--------------->8---
The second argument to `defined?' is probably only valid in the context
of the evaluator:
--8<---------------cut here---------------start------------->8---
guile> (version)
$1 = "1.8.6"
guile> (defined? '+ (the-environment))
$2 = #t
guile> (let ((x 2))
(defined? 'x (the-environment)))
$3 = #t
--8<---------------cut here---------------end--------------->8---
Maybe `defined?' should be changed in 1.9 to accept a module as its
second argument?
Thanks,
Ludo'.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: defined? in module
2009-07-17 14:54 ` Ludovic Courtès
@ 2009-07-24 12:05 ` Andy Wingo
0 siblings, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2009-07-24 12:05 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guile-user
On Fri 17 Jul 2009 16:54, ludo@gnu.org (Ludovic Courtès) writes:
> Maybe `defined?' should be changed in 1.9 to accept a module as its
> second argument?
Makes sense to me, yes.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-24 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-05 13:18 defined? in module Daniel Kraft
2009-07-17 14:54 ` Ludovic Courtès
2009-07-24 12:05 ` Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).