diff options
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/evalext.c | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/libguile/evalext.c b/libguile/evalext.c index 56f74e213..19d8f2e02 100644 --- a/libguile/evalext.c +++ b/libguile/evalext.c @@ -31,49 +31,23 @@ #include "libguile/evalext.h" SCM_DEFINE (scm_defined_p, "defined?", 1, 1, 0, - (SCM sym, SCM env), - "Return @code{#t} if @var{sym} is defined in the lexical " - "environment @var{env}. When @var{env} is not specified, " - "look in the top-level environment as defined by the " - "current module.") + (SCM sym, SCM module), + "Return @code{#t} if @var{sym} is defined in the module " + "@var{module} or the current module when @var{module} is not" + "specified.") #define FUNC_NAME s_scm_defined_p { SCM var; SCM_VALIDATE_SYMBOL (1, sym); - if (SCM_UNBNDP (env)) - var = scm_sym2var (sym, scm_current_module_lookup_closure (), - SCM_BOOL_F); + if (SCM_UNBNDP (module)) + module = scm_current_module (); else - { - SCM frames = env; - register SCM b; - for (; SCM_NIMP (frames); frames = SCM_CDR (frames)) - { - SCM_ASSERT (scm_is_pair (frames), env, SCM_ARG2, FUNC_NAME); - b = SCM_CAR (frames); - if (scm_is_true (scm_procedure_p (b))) - break; - SCM_ASSERT (scm_is_pair (b), env, SCM_ARG2, FUNC_NAME); - for (b = SCM_CAR (b); SCM_NIMP (b); b = SCM_CDR (b)) - { - if (!scm_is_pair (b)) - { - if (scm_is_eq (b, sym)) - return SCM_BOOL_T; - else - break; - } - if (scm_is_eq (SCM_CAR (b), sym)) - return SCM_BOOL_T; - } - } - var = scm_sym2var (sym, - SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F, - SCM_BOOL_F); - } - + SCM_VALIDATE_MODULE (2, module); + + var = scm_module_variable (module, sym); + return (scm_is_false (var) || SCM_UNBNDP (SCM_VARIABLE_REF (var)) ? SCM_BOOL_F : SCM_BOOL_T); |