deprecate lookup closures
authorAndy Wingo <wingo@pobox.com>
Wed, 23 May 2012 10:00:23 +0000 (12:00 +0200)
committerAndy Wingo <wingo@pobox.com>
Wed, 23 May 2012 10:00:23 +0000 (12:00 +0200)
* libguile/deprecated.h (SCM_TOP_LEVEL_LOOKUP_CLOSURE):
* libguile/deprecated.c (scm_lookup_closure_module):
  (scm_module_lookup_closure):
  (scm_current_module_lookup_closure): Deprecate this part of the eval
  closure interface.  It was unused internally, after the scm_sym2var
  refactor.

* libguile/eval.h:
* libguile/modules.c:
* libguile/modules.h: Remove deprecated code.

* libguile/goops.c (scm_ensure_accessor): Use scm_module_variable
  instead of calling the lookup closure.  However I'm not sure that this
  code is used at all.

libguile/deprecated.c
libguile/deprecated.h
libguile/eval.h
libguile/goops.c
libguile/modules.c
libguile/modules.h

index c19d58b..a41f454 100644 (file)
@@ -2694,6 +2694,55 @@ scm_sym2var (SCM sym, SCM proc, SCM definep)
 }
 #undef FUNC_NAME
 
+SCM
+scm_lookup_closure_module (SCM proc)
+{
+  scm_c_issue_deprecation_warning
+    ("Eval closures are deprecated.  See \"Accessing Modules From C\" in\n"
+     "the manual, for replacements.");
+
+  if (scm_is_false (proc))
+    return scm_the_root_module ();
+  else if (SCM_EVAL_CLOSURE_P (proc))
+    return SCM_PACK (SCM_SMOB_DATA (proc));
+  else
+    /* FIXME: The `module' property is no longer set on eval closures, as it
+       introduced a circular reference that precludes garbage collection of
+       modules with the current weak hash table semantics (see
+       http://lists.gnu.org/archive/html/guile-devel/2009-01/msg00102.html and
+       http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2465
+       for details). Since it doesn't appear to be used (only in this
+       function, which has 1 caller), we no longer extend
+       `set-module-eval-closure!' to set the `module' property. */
+    abort ();
+}
+
+SCM
+scm_module_lookup_closure (SCM module)
+{
+  scm_c_issue_deprecation_warning
+    ("Eval closures are deprecated.  See \"Accessing Modules From C\" in\n"
+     "the manual, for replacements.");
+
+  if (scm_is_false (module))
+    return SCM_BOOL_F;
+  else
+    return SCM_MODULE_EVAL_CLOSURE (module);
+}
+
+SCM
+scm_current_module_lookup_closure ()
+{
+  scm_c_issue_deprecation_warning
+    ("Eval closures are deprecated.  See \"Accessing Modules From C\" in\n"
+     "the manual, for replacements.");
+
+  if (scm_module_system_booted_p)
+    return scm_module_lookup_closure (scm_current_module ());
+  else
+    return SCM_BOOL_F;
+}
+
 
 \f
 
index be6cd81..e777d2f 100644 (file)
@@ -817,6 +817,16 @@ SCM_DEPRECATED SCM scm_sym2var (SCM sym, SCM thunk, SCM definep);
 
 \f
 
+/* Eval closure deprecation, 23-05-2012.  */
+#define SCM_TOP_LEVEL_LOOKUP_CLOSURE (scm_current_module_lookup_closure())
+
+SCM_DEPRECATED SCM scm_lookup_closure_module (SCM proc);
+SCM_DEPRECATED SCM scm_module_lookup_closure (SCM module);
+SCM_DEPRECATED SCM scm_current_module_lookup_closure (void);
+
+
+\f
+
 void scm_i_init_deprecated (void);
 
 #endif
index 014f0de..9e5f654 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef SCM_EVAL_H
 #define SCM_EVAL_H
 
-/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011
+/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012
  * Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -57,10 +57,6 @@ typedef SCM (*scm_t_trampoline_2) (SCM proc, SCM arg1, SCM arg2);
 
 #define SCM_EXTEND_ENV scm_acons
 
-/*fixme* This should probably be removed throught the code. */
-
-#define SCM_TOP_LEVEL_LOOKUP_CLOSURE (scm_current_module_lookup_closure())
-
 \f
 
 SCM_API SCM scm_call_0 (SCM proc);
index 2f9cf30..f4b2b34 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011
+/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2011,2012
  * Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -2765,13 +2765,21 @@ SCM_KEYWORD (k_getter, "getter");
 SCM
 scm_ensure_accessor (SCM name)
 {
-  SCM gf = scm_call_2 (SCM_TOP_LEVEL_LOOKUP_CLOSURE, name, SCM_BOOL_F);
+  SCM var, gf;
+
+  var = scm_module_variable (scm_current_module (), name);
+  if (SCM_VARIABLEP (var) && !SCM_UNBNDP (SCM_VARIABLE_REF (var)))
+    gf = SCM_VARIABLE_REF (var);
+  else
+    gf = SCM_BOOL_F;
+
   if (!SCM_IS_A_P (gf, scm_class_accessor))
     {
       gf = scm_make (scm_list_3 (scm_class_generic, k_name, name));
       gf = scm_make (scm_list_5 (scm_class_accessor,
                                 k_name, name, k_setter, gf));
     }
+
   return gf;
 }
 
index 9ccbad3..a7c0c0c 100644 (file)
@@ -236,38 +236,6 @@ scm_c_export (const char *name, ...)
 }
 
 
-/* Environments */
-
-SCM_SYMBOL (sym_module, "module");
-
-SCM
-scm_lookup_closure_module (SCM proc)
-{
-  if (scm_is_false (proc))
-    return scm_the_root_module ();
-  else if (SCM_EVAL_CLOSURE_P (proc))
-    return SCM_PACK (SCM_SMOB_DATA (proc));
-  else
-    {
-      SCM mod;
-
-      /* FIXME: The `module' property is no longer set on eval closures, as it
-        introduced a circular reference that precludes garbage collection of
-        modules with the current weak hash table semantics (see
-        http://lists.gnu.org/archive/html/guile-devel/2009-01/msg00102.html and
-        http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2465
-        for details). Since it doesn't appear to be used (only in this
-        function, which has 1 caller), we no longer extend
-        `set-module-eval-closure!' to set the `module' property. */
-      abort ();
-
-      mod = scm_procedure_property (proc, sym_module);
-      if (scm_is_false (mod))
-       mod = scm_the_root_module ();
-      return mod;
-    }
-}
-
 /*
  * C level implementation of the standard eval closure
  *
@@ -611,24 +579,6 @@ SCM_DEFINE (scm_eval_closure_module,
 }
 #undef FUNC_NAME
 
-SCM
-scm_module_lookup_closure (SCM module)
-{
-  if (scm_is_false (module))
-    return SCM_BOOL_F;
-  else
-    return SCM_MODULE_EVAL_CLOSURE (module);
-}
-
-SCM
-scm_current_module_lookup_closure ()
-{
-  if (scm_module_system_booted_p)
-    return scm_module_lookup_closure (scm_current_module ());
-  else
-    return SCM_BOOL_F;
-}
-
 SCM_SYMBOL (sym_macroexpand, "macroexpand");
 
 SCM_DEFINE (scm_module_transformer, "module-transformer", 1, 0, 0,
index a67ec08..dee77ff 100644 (file)
@@ -119,16 +119,13 @@ SCM_API void scm_c_export (const char *name, ...);
 
 SCM_API SCM scm_module_public_interface (SCM module);
 SCM_API SCM scm_module_import_interface (SCM module, SCM sym);
-SCM_API SCM scm_module_lookup_closure (SCM module);
 SCM_API SCM scm_module_transformer (SCM module);
-SCM_API SCM scm_current_module_lookup_closure (void);
 SCM_API SCM scm_current_module_transformer (void);
 SCM_API SCM scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep);
 SCM_API SCM scm_standard_eval_closure (SCM module);
 SCM_API SCM scm_standard_interface_eval_closure (SCM module);
 SCM_API SCM scm_eval_closure_module (SCM eval_closure); /* deprecated already */
 SCM_API SCM scm_get_pre_modules_obarray (void);
-SCM_API SCM scm_lookup_closure_module (SCM proc);
 
 SCM_INTERNAL void scm_modules_prehistory (void);
 SCM_INTERNAL void scm_init_modules (void);