scm_m_generalized_set_x (SCM xorig, SCM env)
{
SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (2 == scm_ilength (x), xorig, scm_s_expression, scm_s_set_x);
+ SCM_ASSYNT (2 == scm_ilength (x), scm_s_expression, scm_s_set_x);
if (SCM_SYMBOLP (SCM_CAR (x)))
return scm_cons (SCM_IM_SET_X, x);
else if (SCM_CONSP (SCM_CAR (x)))
return scm_cons (SCM_LIST2 (scm_sym_setter, SCM_CAAR (x)),
scm_append (SCM_LIST2 (SCM_CDAR (x), SCM_CDR (x))));
- return scm_wta (xorig, scm_s_variable, scm_s_set_x);
+ else
+ scm_misc_error (scm_s_set_x, scm_s_variable, SCM_EOL);
}
SCM_DEFINE (scm_definedp, "defined?", 1, 1, 0,
(SCM sym, SCM env),
- "Return @code{#t} if @var{sym} is defined in the top-level environment.")
+ "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.")
#define FUNC_NAME s_scm_definedp
{
- SCM vcell;
+ SCM var;
SCM_VALIDATE_SYMBOL (1,sym);
if (SCM_UNBNDP (env))
- vcell = scm_sym2vcell(sym,
- scm_module_system_booted_p
- ? SCM_TOP_LEVEL_LOOKUP_CLOSURE
- : SCM_EOL,
- SCM_BOOL_F);
+ var = scm_sym2var (sym, scm_current_module_lookup_closure (),
+ SCM_BOOL_F);
else
{
SCM frames = env;
return SCM_BOOL_T;
}
}
- vcell = scm_sym2vcell (sym,
- SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F,
- SCM_BOOL_F);
+ var = scm_sym2var (sym,
+ SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F,
+ SCM_BOOL_F);
}
- return (SCM_FALSEP (vcell) || SCM_UNBNDP (SCM_CDR (vcell))
+ return (SCM_FALSEP (var) || SCM_UNBNDP (SCM_VARIABLE_REF (var))
? SCM_BOOL_F
: SCM_BOOL_T);
}
{
SCM arg1 = x;
x = SCM_CDR (x);
- SCM_ASSYNT (SCM_TOP_LEVEL (env), arg1, "bad placement ", s_undefine);
+ SCM_ASSYNT (SCM_TOP_LEVEL (env), "bad placement ", s_undefine);
SCM_ASSYNT (SCM_CONSP (x) && SCM_NULLP (SCM_CDR (x)),
- arg1, scm_s_expression, s_undefine);
+ scm_s_expression, s_undefine);
x = SCM_CAR (x);
- SCM_ASSYNT (SCM_SYMBOLP (x), arg1, scm_s_variable, s_undefine);
- arg1 = scm_sym2vcell (x, scm_env_top_level (env), SCM_BOOL_F);
- SCM_ASSYNT (SCM_NFALSEP (arg1) && !SCM_UNBNDP (SCM_CDR (arg1)),
- x, "variable already unbound ", s_undefine);
- SCM_SETCDR (arg1, SCM_UNDEFINED);
+ SCM_ASSYNT (SCM_SYMBOLP (x), scm_s_variable, s_undefine);
+ arg1 = scm_sym2var (x, scm_env_top_level (env), SCM_BOOL_F);
+ SCM_ASSYNT (SCM_NFALSEP (arg1) && !SCM_UNBNDP (SCM_VARIABLE_REF (arg1)),
+ "variable already unbound ", s_undefine);
+ SCM_VARIABLE_SET (arg1, SCM_UNDEFINED);
#ifdef SICP
- return SCM_CAR (arg1);
+ return x;
#else
return SCM_UNSPECIFIED;
#endif