1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 16:50:21 +02:00

deprecate scm_sym2var

* libguile/deprecated.h:
* libguile/deprecated.c (scm_sym2var): Deprecate this function.

* libguile/modules.h:
* libguile/modules.c (scm_module_ensure_local_variable): New public
  function, replacing scm_sym2var with a true definep, without going
  through eval closures (which are deprecated).
  (scm_current_module): Rework to do something sensible before modules
  are booted.
  (scm_module_lookup, scm_lookup): Refactor to use scm_module_variable.
  (scm_module_define, scm_define): Refactor to use
  scm_module_ensure_local_variable.

* libguile/vm-i-system.c (define!): Use scm_define.

* libguile/vm.c (resolve_variable): Use scm_module_lookup.

* libguile/macros.c (scm_make_syntax_transformer): Use
  scm_module_variable.

* libguile/gdbint.c (gdb_binding): Use scm_define.

* doc/ref/api-modules.texi (Accessing Modules from C): Add docs for
  scm_module_ensure_local_variable.
This commit is contained in:
Andy Wingo 2012-05-23 11:46:30 +02:00
parent 15bb587f45
commit 62e15979b5
9 changed files with 132 additions and 97 deletions

View file

@ -2,7 +2,7 @@
deprecate something, move it here when that is feasible.
*/
/* Copyright (C) 2003, 2004, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
/* Copyright (C) 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@ -2637,6 +2637,64 @@ scm_i_deprecated_asrtgo (scm_t_bits condition)
}
/* scm_sym2var
*
* looks up the variable bound to SYM according to PROC. PROC should be
* a `eval closure' of some module.
*
* When no binding exists, and DEFINEP is true, create a new binding
* with a initial value of SCM_UNDEFINED. Return `#f' when DEFINEP as
* false and no binding exists.
*
* When PROC is `#f', it is ignored and the binding is searched for in
* the scm_pre_modules_obarray (a `eq' hash table).
*/
SCM
scm_sym2var (SCM sym, SCM proc, SCM definep)
#define FUNC_NAME "scm_sym2var"
{
SCM var;
if (definep)
scm_c_issue_deprecation_warning
("scm_sym2var is deprecated. Use scm_define or scm_module_define\n"
"to define variables. In some rare cases you may need\n"
"scm_module_ensure_local_variable.");
else
scm_c_issue_deprecation_warning
("scm_sym2var is deprecated. Use scm_module_variable to look up\n"
"variables.");
if (SCM_NIMP (proc))
{
if (SCM_EVAL_CLOSURE_P (proc))
{
/* Bypass evaluator in the standard case. */
var = scm_eval_closure_lookup (proc, sym, definep);
}
else
var = scm_call_2 (proc, sym, definep);
}
else
{
if (scm_is_false (definep))
var = scm_module_variable (scm_the_root_module (), sym);
else
var = scm_module_ensure_local_variable (scm_the_root_module (), sym);
}
if (scm_is_true (var) && !SCM_VARIABLEP (var))
SCM_MISC_ERROR ("~S is not bound to a variable", scm_list_1 (sym));
return var;
}
#undef FUNC_NAME
void