Merge branch 'master' into boehm-demers-weiser-gc
[bpt/guile.git] / libguile / environments.c
index 10ce8c8..78ccd28 100644 (file)
@@ -1,51 +1,30 @@
-/* Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2000,2001, 2003, 2006, 2008 Free Software Foundation, Inc.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this software; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * As a special exception, the Free Software Foundation gives permission
- * for additional uses of the text contained in its release of GUILE.
- *
- * The exception is that, if you link the GUILE library with other files
- * to produce an executable, this does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * Your use of that executable is in no way restricted on account of
- * linking the GUILE library code into it.
- *
- * This exception does not however invalidate any other reasons why
- * the executable file might be covered by the GNU General Public License.
- *
- * This exception applies only to the code released by the
- * Free Software Foundation under the name GUILE.  If you copy
- * code from other Free Software Foundation releases into a copy of
- * GUILE, as the General Public License permits, the exception does
- * not apply to the code that you add in this way.  To avoid misleading
- * anyone as to the status of such modified files, you must delete
- * this exception notice from them.
- *
- * If you write modifications of your own for GUILE, it is your choice
- * whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice.  */
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
 
 \f
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 #include "libguile/_scm.h"
 #include "libguile/alist.h"
 #include "libguile/eval.h"
-#include "libguile/gh.h"
 #include "libguile/hash.h"
+#include "libguile/list.h"
 #include "libguile/ports.h"
 #include "libguile/smob.h"
 #include "libguile/symbols.h"
@@ -58,7 +37,7 @@
 
 scm_t_bits scm_tc16_environment;
 scm_t_bits scm_tc16_observer;
-#define DEFAULT_OBARRAY_SIZE 137
+#define DEFAULT_OBARRAY_SIZE 31
 
 SCM scm_system_environment;
 
@@ -119,7 +98,7 @@ scm_error_environment_immutable_location (const char *func, SCM env, SCM symbol)
 SCM
 scm_make_environment (void *type)
 {
-  return scm_cell (scm_tc16_environment, (scm_t_bits) type);
+  SCM_RETURN_NEWSMOB (scm_tc16_environment, type);
 }
 
 
@@ -129,7 +108,7 @@ SCM_DEFINE (scm_environment_p, "environment?", 1, 0, 0,
            "otherwise.")
 #define FUNC_NAME s_scm_environment_p
 {
-  return SCM_BOOL (SCM_ENVIRONMENT_P (obj));
+  return scm_from_bool (SCM_ENVIRONMENT_P (obj));
 }
 #undef FUNC_NAME
 
@@ -141,9 +120,9 @@ SCM_DEFINE (scm_environment_bound_p, "environment-bound?", 2, 0, 0,
 #define FUNC_NAME s_scm_environment_bound_p
 {
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, FUNC_NAME);
 
-  return SCM_BOOL (SCM_ENVIRONMENT_BOUND_P (env, sym));
+  return scm_from_bool (SCM_ENVIRONMENT_BOUND_P (env, sym));
 }
 #undef FUNC_NAME
 
@@ -158,7 +137,7 @@ SCM_DEFINE (scm_environment_ref, "environment-ref", 2, 0, 0,
   SCM val;
 
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, FUNC_NAME);
 
   val = SCM_ENVIRONMENT_REF (env, sym);
 
@@ -178,7 +157,7 @@ SCM
 scm_c_environment_ref (SCM env, SCM sym)
 {
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, "scm_c_environment_ref");
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, "scm_c_environment_ref");
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, "scm_c_environment_ref");
   return SCM_ENVIRONMENT_REF (env, sym);
 }
 
@@ -186,7 +165,7 @@ scm_c_environment_ref (SCM env, SCM sym)
 static SCM
 environment_default_folder (SCM proc, SCM symbol, SCM value, SCM tail)
 {
-  return gh_call3 (proc, symbol, value, tail);
+  return scm_call_3 (proc, symbol, value, tail);
 }
 
 
@@ -226,7 +205,7 @@ SCM_DEFINE (scm_environment_fold, "environment-fold", 3, 0, 0,
 #define FUNC_NAME s_scm_environment_fold
 {
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (SCM_EQ_P (scm_procedure_p (proc), SCM_BOOL_T), 
+  SCM_ASSERT (scm_is_true (scm_procedure_p (proc)), 
              proc, SCM_ARG2, FUNC_NAME);
 
   return SCM_ENVIRONMENT_FOLD (env, environment_default_folder, proc, init);
@@ -263,13 +242,13 @@ SCM_DEFINE (scm_environment_define, "environment-define", 3, 0, 0,
   SCM status;
 
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, FUNC_NAME);
 
   status = SCM_ENVIRONMENT_DEFINE (env, sym, val);
 
-  if (SCM_EQ_P (status, SCM_ENVIRONMENT_SUCCESS))
+  if (scm_is_eq (status, SCM_ENVIRONMENT_SUCCESS))
     return SCM_UNSPECIFIED;
-  else if (SCM_EQ_P (status, SCM_ENVIRONMENT_BINDING_IMMUTABLE))
+  else if (scm_is_eq (status, SCM_ENVIRONMENT_BINDING_IMMUTABLE))
     scm_error_environment_immutable_binding (FUNC_NAME, env, sym);
   else
     abort();
@@ -289,13 +268,13 @@ SCM_DEFINE (scm_environment_undefine, "environment-undefine", 2, 0, 0,
   SCM status;
 
   SCM_ASSERT(SCM_ENVIRONMENT_P(env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT(SCM_SYMBOLP(sym), sym, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT(scm_is_symbol(sym), sym, SCM_ARG2, FUNC_NAME);
 
   status = SCM_ENVIRONMENT_UNDEFINE (env, sym);
 
-  if (SCM_EQ_P (status, SCM_ENVIRONMENT_SUCCESS))
+  if (scm_is_eq (status, SCM_ENVIRONMENT_SUCCESS))
     return SCM_UNSPECIFIED;
-  else if (SCM_EQ_P (status, SCM_ENVIRONMENT_BINDING_IMMUTABLE))
+  else if (scm_is_eq (status, SCM_ENVIRONMENT_BINDING_IMMUTABLE))
     scm_error_environment_immutable_binding (FUNC_NAME, env, sym);
   else
     abort();
@@ -317,15 +296,15 @@ SCM_DEFINE (scm_environment_set_x, "environment-set!", 3, 0, 0,
   SCM status;
 
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, FUNC_NAME);
 
   status = SCM_ENVIRONMENT_SET (env, sym, val);
 
-  if (SCM_EQ_P (status, SCM_ENVIRONMENT_SUCCESS))
+  if (scm_is_eq (status, SCM_ENVIRONMENT_SUCCESS))
     return SCM_UNSPECIFIED;
   else if (SCM_UNBNDP (status))
     scm_error_environment_unbound (FUNC_NAME, env, sym);
-  else if (SCM_EQ_P (status, SCM_ENVIRONMENT_LOCATION_IMMUTABLE))
+  else if (scm_is_eq (status, SCM_ENVIRONMENT_LOCATION_IMMUTABLE))
     scm_error_environment_immutable_binding (FUNC_NAME, env, sym);
   else
     abort();
@@ -352,15 +331,15 @@ SCM_DEFINE (scm_environment_cell, "environment-cell", 3, 0, 0,
   SCM location;
 
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, FUNC_NAME);
-  SCM_ASSERT (SCM_BOOLP (for_write), for_write, SCM_ARG3, FUNC_NAME);
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_bool (for_write), for_write, SCM_ARG3, FUNC_NAME);
 
-  location = SCM_ENVIRONMENT_CELL (env, sym, !SCM_FALSEP (for_write));
+  location = SCM_ENVIRONMENT_CELL (env, sym, scm_is_true (for_write));
   if (!SCM_IMP (location))
     return location;
   else if (SCM_UNBNDP (location))
     scm_error_environment_unbound (FUNC_NAME, env, sym);
-  else if (SCM_EQ_P (location, SCM_ENVIRONMENT_LOCATION_IMMUTABLE))
+  else if (scm_is_eq (location, SCM_ENVIRONMENT_LOCATION_IMMUTABLE))
     scm_error_environment_immutable_location (FUNC_NAME, env, sym);
   else /* no cell */
     return location;
@@ -378,7 +357,7 @@ SCM
 scm_c_environment_cell(SCM env, SCM sym, int for_write)
 {
   SCM_ASSERT (SCM_ENVIRONMENT_P (env), env, SCM_ARG1, "scm_c_environment_cell");
-  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG2, "scm_c_environment_cell");
+  SCM_ASSERT (scm_is_symbol (sym), sym, SCM_ARG2, "scm_c_environment_cell");
 
   return SCM_ENVIRONMENT_CELL (env, sym, for_write);
 }
@@ -387,7 +366,7 @@ scm_c_environment_cell(SCM env, SCM sym, int for_write)
 static void
 environment_default_observer (SCM env, SCM proc)
 {
-  gh_call1 (proc, env);
+  scm_call_1 (proc, env);
 }
 
 
@@ -466,20 +445,6 @@ SCM_DEFINE (scm_environment_unobserve, "environment-unobserve", 1, 0, 0,
 #undef FUNC_NAME
 
 
-static SCM
-environment_mark (SCM env)
-{
-  return (*(SCM_ENVIRONMENT_FUNCS (env)->mark)) (env);
-}
-
-
-static size_t
-environment_free (SCM env)
-{
-  (*(SCM_ENVIRONMENT_FUNCS (env)->free)) (env);
-  return 0;
-}
-
 
 static int
 environment_print (SCM env, SCM port, scm_print_state *pstate)
@@ -491,23 +456,15 @@ environment_print (SCM env, SCM port, scm_print_state *pstate)
 
 /* observers */
 
-static SCM
-observer_mark (SCM observer)
-{
-  scm_gc_mark (SCM_OBSERVER_ENVIRONMENT (observer));
-  scm_gc_mark (SCM_OBSERVER_DATA (observer));
-  return SCM_BOOL_F;
-}
-
 
 static int
 observer_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
 {
-  SCM address = scm_ulong2num (SCM_UNPACK (type));
-  SCM base16 = scm_number_to_string (address, SCM_MAKINUM (16));
+  SCM address = scm_from_size_t (SCM_UNPACK (type));
+  SCM base16 = scm_number_to_string (address, scm_from_int (16));
 
   scm_puts ("#<observer ", port);
-  scm_puts (SCM_STRING_CHARS (base16), port);
+  scm_display (base16, port);
   scm_puts (">", port);
 
   return 1;
@@ -530,10 +487,13 @@ observer_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
 static SCM
 obarray_enter (SCM obarray, SCM symbol, SCM data)
 {
-  size_t hash = SCM_SYMBOL_HASH (symbol) % SCM_VECTOR_LENGTH (obarray);
+  size_t hash = scm_i_symbol_hash (symbol) % SCM_HASHTABLE_N_BUCKETS (obarray);
   SCM entry = scm_cons (symbol, data);
-  SCM slot = scm_cons (entry, SCM_VELTS (obarray)[hash]);
-  SCM_VELTS (obarray)[hash] = slot;
+  SCM slot = scm_cons (entry, SCM_HASHTABLE_BUCKET (obarray, hash));
+  SCM_SET_HASHTABLE_BUCKET  (obarray, hash, slot);
+  SCM_HASHTABLE_INCREMENT (obarray);
+  if (SCM_HASHTABLE_N_ITEMS (obarray) > SCM_HASHTABLE_UPPER (obarray))
+    scm_i_rehash (obarray, scm_i_hash_symbol, 0, "obarray_enter");
 
   return entry;
 }
@@ -546,23 +506,28 @@ obarray_enter (SCM obarray, SCM symbol, SCM data)
 static SCM
 obarray_replace (SCM obarray, SCM symbol, SCM data)
 {
-  size_t hash = SCM_SYMBOL_HASH (symbol) % SCM_VECTOR_LENGTH (obarray);
+  size_t hash = scm_i_symbol_hash (symbol) % SCM_HASHTABLE_N_BUCKETS (obarray);
   SCM new_entry = scm_cons (symbol, data);
   SCM lsym;
   SCM slot;
 
-  for (lsym = SCM_VELTS (obarray)[hash]; !SCM_NULLP (lsym); lsym = SCM_CDR (lsym))
+  for (lsym = SCM_HASHTABLE_BUCKET (obarray, hash);
+       !scm_is_null (lsym);
+       lsym = SCM_CDR (lsym))
     {
       SCM old_entry = SCM_CAR (lsym);
-      if (SCM_EQ_P (SCM_CAR (old_entry), symbol))
+      if (scm_is_eq (SCM_CAR (old_entry), symbol))
        {
          SCM_SETCAR (lsym, new_entry);
          return old_entry;
        }
     }
 
-  slot = scm_cons (new_entry, SCM_VELTS (obarray)[hash]);
-  SCM_VELTS (obarray)[hash] = slot;
+  slot = scm_cons (new_entry, SCM_HASHTABLE_BUCKET (obarray, hash));
+  SCM_SET_HASHTABLE_BUCKET (obarray, hash, slot);
+  SCM_HASHTABLE_INCREMENT (obarray);
+  if (SCM_HASHTABLE_N_ITEMS (obarray) > SCM_HASHTABLE_UPPER (obarray))
+    scm_i_rehash (obarray, scm_i_hash_symbol, 0, "obarray_replace");
 
   return SCM_BOOL_F;
 }
@@ -574,13 +539,15 @@ obarray_replace (SCM obarray, SCM symbol, SCM data)
 static SCM
 obarray_retrieve (SCM obarray, SCM sym)
 {
-  size_t hash = SCM_SYMBOL_HASH (sym) % SCM_VECTOR_LENGTH (obarray);
+  size_t hash = scm_i_symbol_hash (sym) % SCM_HASHTABLE_N_BUCKETS (obarray);
   SCM lsym;
 
-  for (lsym = SCM_VELTS (obarray)[hash]; !SCM_NULLP (lsym); lsym = SCM_CDR (lsym))
+  for (lsym = SCM_HASHTABLE_BUCKET (obarray, hash);
+       !scm_is_null (lsym);
+       lsym = SCM_CDR (lsym))
     {
       SCM entry = SCM_CAR (lsym);
-      if (SCM_EQ_P (SCM_CAR (entry), sym))
+      if (scm_is_eq (SCM_CAR (entry), sym))
        return entry;
     }
 
@@ -595,36 +562,32 @@ obarray_retrieve (SCM obarray, SCM sym)
 static SCM
 obarray_remove (SCM obarray, SCM sym)
 {
-  size_t hash = SCM_SYMBOL_HASH (sym) % SCM_VECTOR_LENGTH (obarray);
-  SCM lsym;
-  SCM *lsymp;
+  size_t hash = scm_i_symbol_hash (sym) % SCM_HASHTABLE_N_BUCKETS (obarray);
+  SCM table_entry = SCM_HASHTABLE_BUCKET (obarray, hash);
+  SCM handle = scm_sloppy_assq (sym, table_entry);
 
-  /* Dirk:FIXME:: gc problem due to use of &SCM_VELTS[hash] */
-  for (lsym = *(lsymp = &SCM_VELTS (obarray)[hash]);
-       !SCM_NULLP (lsym);
-       lsym = *(lsymp = SCM_CDRLOC (lsym)))
+  if (scm_is_pair (handle))
     {
-      SCM entry = SCM_CAR (lsym);
-      if (SCM_EQ_P (SCM_CAR (entry), sym))
-       {
-         *lsymp = SCM_CDR (lsym);
-         return entry;
-       }
+      SCM new_table_entry = scm_delq1_x (handle, table_entry);
+      SCM_SET_HASHTABLE_BUCKET (obarray, hash, new_table_entry);
+      SCM_HASHTABLE_DECREMENT (obarray);
     }
-  return SCM_BOOL_F;
+
+  return handle;
 }
 
 
 static void
 obarray_remove_all (SCM obarray)
 {
-  size_t size = SCM_VECTOR_LENGTH (obarray);
+  size_t size = SCM_HASHTABLE_N_BUCKETS (obarray);
   size_t i;
 
   for (i = 0; i < size; i++)
     {
-      SCM_VELTS (obarray)[i] = SCM_EOL;
+      SCM_SET_HASHTABLE_BUCKET (obarray, i, SCM_EOL);
     }
+  SCM_SET_HASHTABLE_N_ITEMS (obarray, 0);
 }
 
 \f
@@ -653,19 +616,21 @@ struct core_environments_base {
 #define CORE_ENVIRONMENT_WEAK_OBSERVER_VECTOR(env) \
   (CORE_ENVIRONMENTS_BASE (env)->weak_observers)
 #define CORE_ENVIRONMENT_WEAK_OBSERVERS(env) \
-  (SCM_VELTS (CORE_ENVIRONMENT_WEAK_OBSERVER_VECTOR (env)) [0])
+  (scm_c_vector_ref (CORE_ENVIRONMENT_WEAK_OBSERVER_VECTOR (env), 0))
 #define SCM_SET_CORE_ENVIRONMENT_WEAK_OBSERVERS(env, v) \
-  (SCM_VELTS (CORE_ENVIRONMENT_WEAK_OBSERVER_VECTOR (env)) [0] = (v))
+  (scm_c_vector_set_x (CORE_ENVIRONMENT_WEAK_OBSERVER_VECTOR (env), 0, (v)))
 
 \f
 
 static SCM
 core_environments_observe (SCM env, scm_environment_observer proc, SCM data, int weak_p)
 {
-  SCM observer = scm_double_cell (scm_tc16_observer,
-                                 SCM_UNPACK (env),
-                                 SCM_UNPACK (data),
-                                 (scm_t_bits) proc);
+  SCM observer;
+
+  SCM_NEWSMOB3 (observer, scm_tc16_observer,
+               SCM_UNPACK (env),
+               SCM_UNPACK (data),
+               (scm_t_bits) proc);
 
   if (!weak_p)
     {
@@ -694,32 +659,33 @@ core_environments_unobserve (SCM env, SCM observer)
        ? CORE_ENVIRONMENT_WEAK_OBSERVERS (env)
        : CORE_ENVIRONMENT_OBSERVERS (env);
 
-      if (!SCM_NULLP (l))
+      if (!scm_is_null (l))
        {
          SCM rest = SCM_CDR (l);
          SCM first = handling_weaks
            ? SCM_CDAR (l)
            : SCM_CAR (l);
 
-         if (SCM_EQ_P (first, observer))
+         if (scm_is_eq (first, observer))
            {
              /* Remove the first observer */
-             handling_weaks
-               ? SCM_SET_CORE_ENVIRONMENT_WEAK_OBSERVERS (env, rest)
-               : SCM_SET_CORE_ENVIRONMENT_OBSERVERS (env, rest);
+             if (handling_weaks)
+               SCM_SET_CORE_ENVIRONMENT_WEAK_OBSERVERS (env, rest);
+              else
+                SCM_SET_CORE_ENVIRONMENT_OBSERVERS (env, rest);
              return;
            }
 
          do {
            SCM rest = SCM_CDR (l);
 
-           if (!SCM_NULLP (rest)) 
+           if (!scm_is_null (rest)) 
              {
                SCM next = handling_weaks
                  ? SCM_CDAR (l)
                  : SCM_CAR (l);
 
-               if (SCM_EQ_P (next, observer))
+               if (scm_is_eq (next, observer))
                  {
                    SCM_SETCDR (l, SCM_CDR (rest));
                    return;
@@ -727,7 +693,7 @@ core_environments_unobserve (SCM env, SCM observer)
              }
 
            l = rest;
-         } while (!SCM_NULLP (l));
+         } while (!scm_is_null (l));
        }
     }
 
@@ -735,20 +701,6 @@ core_environments_unobserve (SCM env, SCM observer)
 }
 
 
-static SCM
-core_environments_mark (SCM env)
-{
-  scm_gc_mark (CORE_ENVIRONMENT_OBSERVERS (env));
-  return CORE_ENVIRONMENT_WEAK_OBSERVER_VECTOR (env);
-}
-
-
-static void
-core_environments_finalize (SCM env SCM_UNUSED)
-{
-}
-
-
 static void
 core_environments_preinit (struct core_environments_base *body)
 {
@@ -764,7 +716,7 @@ core_environments_init (struct core_environments_base *body,
 {
   body->funcs = funcs;
   body->observers = SCM_EOL;
-  body->weak_observers = scm_make_weak_value_hash_table (SCM_MAKINUM (1));
+  body->weak_observers = scm_make_weak_value_alist_vector (scm_from_int (1));
 }
 
 
@@ -806,7 +758,8 @@ update_catch_handler (void *ptr, SCM tag, SCM args)
 {
   struct update_data *data = (struct update_data *) ptr;
   SCM observer = data->observer;
-  SCM message = scm_makfrom0str ("Observer `~A' signals `~A' error: ~S");
+  SCM message =
+    scm_from_locale_string ("Observer `~A' signals `~A' error: ~S");
 
   return scm_cons (message, scm_list_3 (observer, tag, args));
 }
@@ -825,7 +778,7 @@ core_environments_broadcast (SCM env)
        ? CORE_ENVIRONMENT_WEAK_OBSERVERS (env)
        : CORE_ENVIRONMENT_OBSERVERS (env);
 
-      for (; !SCM_NULLP (observers); observers = SCM_CDR (observers))
+      for (; !scm_is_null (observers); observers = SCM_CDR (observers))
        {
           struct update_data data;
          SCM observer = handling_weaks
@@ -845,7 +798,7 @@ core_environments_broadcast (SCM env)
        }
     }
 
-  if (!SCM_NULLP (errors))
+  if (!scm_is_null (errors))
     {
       /* Dirk:FIXME:: As soon as scm_misc_error is fixed to handle the name
        * parameter correctly it should not be necessary any more to also pass
@@ -902,10 +855,12 @@ leaf_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init)
   SCM result = init;
   SCM obarray = LEAF_ENVIRONMENT (env)->obarray;
 
-  for (i = 0; i < SCM_VECTOR_LENGTH (obarray); i++)
+  for (i = 0; i < SCM_HASHTABLE_N_BUCKETS (obarray); i++)
     {
       SCM l;
-      for (l = SCM_VELTS (obarray)[i]; !SCM_NULLP (l); l = SCM_CDR (l))
+      for (l = SCM_HASHTABLE_BUCKET (obarray, i);
+          !scm_is_null (l);
+          l = SCM_CDR (l))
        {
          SCM binding = SCM_CAR (l);
          SCM symbol = SCM_CAR (binding);
@@ -938,7 +893,7 @@ leaf_environment_undefine (SCM env, SCM sym)
   SCM obarray = LEAF_ENVIRONMENT (env)->obarray;
   SCM removed = obarray_remove (obarray, sym);
   
-  if (!SCM_FALSEP (removed))
+  if (scm_is_true (removed))
     core_environments_broadcast (env);
 
   return SCM_ENVIRONMENT_SUCCESS;
@@ -975,31 +930,15 @@ leaf_environment_cell (SCM env, SCM sym, int for_write SCM_UNUSED)
 }
 
 
-static SCM
-leaf_environment_mark (SCM env)
-{
-  scm_gc_mark (LEAF_ENVIRONMENT (env)->obarray);
-  return core_environments_mark (env);
-}
-
-
-static void
-leaf_environment_free (SCM env)
-{
-  core_environments_finalize (env);
-  scm_gc_free (LEAF_ENVIRONMENT (env), sizeof (struct leaf_environment),
-              "leaf environment");
-}
-
 
 static int
 leaf_environment_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
 {
-  SCM address = scm_ulong2num (SCM_UNPACK (type));
-  SCM base16 = scm_number_to_string (address, SCM_MAKINUM (16));
+  SCM address = scm_from_size_t (SCM_UNPACK (type));
+  SCM base16 = scm_number_to_string (address, scm_from_int (16));
 
   scm_puts ("#<leaf environment ", port);
-  scm_puts (SCM_STRING_CHARS (base16), port);
+  scm_display (base16, port);
   scm_puts (">", port);
 
   return 1;
@@ -1015,8 +954,6 @@ static struct scm_environment_funcs leaf_environment_funcs = {
   leaf_environment_cell,
   core_environments_observe,
   core_environments_unobserve,
-  leaf_environment_mark,
-  leaf_environment_free,
   leaf_environment_print
 };
 
@@ -1054,7 +991,7 @@ SCM_DEFINE (scm_leaf_environment_p, "leaf-environment?", 1, 0, 0,
            "otherwise.")
 #define FUNC_NAME s_scm_leaf_environment_p
 {
-  return SCM_BOOL (SCM_LEAF_ENVIRONMENT_P (object));
+  return scm_from_bool (SCM_LEAF_ENVIRONMENT_P (object));
 }
 #undef FUNC_NAME
 
@@ -1101,9 +1038,9 @@ struct eval_environment {
 #define EVAL_ENVIRONMENT(env) \
   ((struct eval_environment *) SCM_CELL_WORD_1 (env))
 
-#define IMMUTABLE SCM_MAKINUM (0)
-#define MUTABLE   SCM_MAKINUM (1)
-#define UNKNOWN   SCM_MAKINUM (2)
+#define IMMUTABLE SCM_I_MAKINUM (0)
+#define MUTABLE   SCM_I_MAKINUM (1)
+#define UNKNOWN   SCM_I_MAKINUM (2)
 
 #define CACHED_LOCATION(x) SCM_CAR (x)
 #define CACHED_MUTABILITY(x) SCM_CADR (x)
@@ -1130,7 +1067,7 @@ eval_environment_lookup (SCM env, SCM sym, int for_write)
 
       SCM entry = SCM_CDR (binding);
 
-      if (SCM_CONSP (entry))
+      if (scm_is_pair (entry))
        {
          /* The entry in the obarray is a cached location. */
 
@@ -1141,15 +1078,15 @@ eval_environment_lookup (SCM env, SCM sym, int for_write)
            return location;
 
          mutability = CACHED_MUTABILITY (entry);
-         if (SCM_EQ_P (mutability, MUTABLE))
+         if (scm_is_eq (mutability, MUTABLE))
            return location;
 
-         if (SCM_EQ_P (mutability, UNKNOWN))
+         if (scm_is_eq (mutability, UNKNOWN))
            {
              SCM source_env = CACHED_SOURCE_ENVIRONMENT (entry);
              SCM location = SCM_ENVIRONMENT_CELL (source_env, sym, 1);
 
-             if (SCM_CONSP (location))
+             if (scm_is_pair (location))
                {
                  SET_CACHED_MUTABILITY (entry, MUTABLE);
                  return location;
@@ -1189,14 +1126,14 @@ eval_environment_lookup (SCM env, SCM sym, int for_write)
 
          if (!SCM_UNBNDP (location))
            {
-             if (SCM_CONSP (location))
+             if (scm_is_pair (location))
                {
                  SCM mutability = for_write ? MUTABLE : UNKNOWN;
                  SCM entry = scm_cons2 (location, mutability, source_env);
                  obarray_enter (obarray, sym, entry);
                  return location;
                }
-             else if (SCM_EQ_P (location, SCM_ENVIRONMENT_LOCATION_NO_CELL))
+             else if (scm_is_eq (location, SCM_ENVIRONMENT_LOCATION_NO_CELL))
                {
                  obarray_enter (obarray, sym, source_env);
                  return source_env;
@@ -1219,7 +1156,7 @@ eval_environment_ref (SCM env, SCM sym)
 {
   SCM location = eval_environment_lookup (env, sym, 0);
 
-  if (SCM_CONSP (location))
+  if (scm_is_pair (location))
     return SCM_CDR (location);
   else if (!SCM_UNBNDP (location))
     return SCM_ENVIRONMENT_REF (location, sym);
@@ -1237,7 +1174,7 @@ eval_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
   if (!SCM_ENVIRONMENT_BOUND_P (local, symbol))
     {
       SCM proc_as_nr = SCM_CADR (extended_data);
-      unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, 0, NULL);
+      unsigned long int proc_as_ul = scm_to_ulong (proc_as_nr);
       scm_environment_folder proc = (scm_environment_folder) proc_as_ul;
       SCM data = SCM_CDDR (extended_data);
 
@@ -1255,7 +1192,7 @@ eval_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init)
 {
   SCM local = EVAL_ENVIRONMENT (env)->local;
   SCM imported = EVAL_ENVIRONMENT (env)->imported;
-  SCM proc_as_nr = scm_ulong2num ((unsigned long int) proc);
+  SCM proc_as_nr = scm_from_ulong ((unsigned long) proc);
   SCM extended_data = scm_cons2 (local, proc_as_nr, data);
   SCM tmp_result = scm_c_environment_fold (imported, eval_environment_folder, extended_data, init);
 
@@ -1289,7 +1226,7 @@ eval_environment_set_x (SCM env, SCM sym, SCM val)
 {
   SCM location = eval_environment_lookup (env, sym, 1);
 
-  if (SCM_CONSP (location))
+  if (scm_is_pair (location))
     {
       SCM_SETCDR (location, val);
       return SCM_ENVIRONMENT_SUCCESS;
@@ -1298,7 +1235,7 @@ eval_environment_set_x (SCM env, SCM sym, SCM val)
     {
       return SCM_ENVIRONMENT_SET (location, sym, val);
     }
-  else if (SCM_EQ_P (location, IMMUTABLE))
+  else if (scm_is_eq (location, IMMUTABLE))
     {
       return SCM_ENVIRONMENT_LOCATION_IMMUTABLE;
     }
@@ -1316,11 +1253,11 @@ eval_environment_cell (SCM env, SCM sym, int for_write)
 {
   SCM location = eval_environment_lookup (env, sym, for_write);
 
-  if (SCM_CONSP (location))
+  if (scm_is_pair (location))
     return location;
   else if (SCM_ENVIRONMENT_P (location))
     return SCM_ENVIRONMENT_LOCATION_NO_CELL;
-  else if (SCM_EQ_P (location, IMMUTABLE))
+  else if (scm_is_eq (location, IMMUTABLE))
     return SCM_ENVIRONMENT_LOCATION_IMMUTABLE;
   else
     return SCM_UNDEFINED;
@@ -1328,38 +1265,15 @@ eval_environment_cell (SCM env, SCM sym, int for_write)
 #undef FUNC_NAME
 
 
-static SCM
-eval_environment_mark (SCM env)
-{
-  struct eval_environment *body = EVAL_ENVIRONMENT (env);
-
-  scm_gc_mark (body->obarray);
-  scm_gc_mark (body->imported);
-  scm_gc_mark (body->imported_observer);
-  scm_gc_mark (body->local);
-  scm_gc_mark (body->local_observer);
-
-  return core_environments_mark (env);
-}
-
-
-static void
-eval_environment_free (SCM env)
-{
-  core_environments_finalize (env);
-  scm_gc_free (EVAL_ENVIRONMENT (env), sizeof (struct eval_environment),
-              "eval environment");
-}
-
 
 static int
 eval_environment_print (SCM type, SCM port, scm_print_state *pstate SCM_UNUSED)
 {
-  SCM address = scm_ulong2num (SCM_UNPACK (type));
-  SCM base16 = scm_number_to_string (address, SCM_MAKINUM (16));
+  SCM address = scm_from_size_t (SCM_UNPACK (type));
+  SCM base16 = scm_number_to_string (address, scm_from_int (16));
 
   scm_puts ("#<eval environment ", port);
-  scm_puts (SCM_STRING_CHARS (base16), port);
+  scm_display (base16, port);
   scm_puts (">", port);
 
   return 1;
@@ -1375,8 +1289,6 @@ static struct scm_environment_funcs eval_environment_funcs = {
     eval_environment_cell,
     core_environments_observe,
     core_environments_unobserve,
-    eval_environment_mark,
-    eval_environment_free,
     eval_environment_print
 };
 
@@ -1456,7 +1368,7 @@ SCM_DEFINE (scm_eval_environment_p, "eval-environment?", 1, 0, 0,
            "otherwise.")
 #define FUNC_NAME s_scm_eval_environment_p
 {
-  return SCM_BOOL (SCM_EVAL_ENVIRONMENT_P (object));
+  return scm_from_bool (SCM_EVAL_ENVIRONMENT_P (object));
 }
 #undef FUNC_NAME
 
@@ -1575,7 +1487,7 @@ import_environment_lookup (SCM env, SCM sym)
   SCM result = SCM_UNDEFINED;
   SCM l;
 
-  for (l = imports; !SCM_NULLP (l); l = SCM_CDR (l))
+  for (l = imports; !scm_is_null (l); l = SCM_CDR (l))
     {
       SCM imported = SCM_CAR (l);
 
@@ -1583,14 +1495,14 @@ import_environment_lookup (SCM env, SCM sym)
        {
          if (SCM_UNBNDP (result))
            result = imported;
-         else if (SCM_CONSP (result))
+         else if (scm_is_pair (result))
            result = scm_cons (imported, result);
          else
            result = scm_cons2 (imported, result, SCM_EOL);
        }
     }
 
-  if (SCM_CONSP (result))
+  if (scm_is_pair (result))
     return scm_reverse (result);
   else
     return result;
@@ -1617,7 +1529,7 @@ import_environment_ref (SCM env, SCM sym)
     {
       return SCM_UNDEFINED;
     }
-  else if (SCM_CONSP (owner))
+  else if (scm_is_pair (owner))
     {
       SCM resolve = import_environment_conflict (env, sym, owner);
 
@@ -1642,11 +1554,11 @@ import_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
   SCM imported_env = SCM_CADR (extended_data);
   SCM owner = import_environment_lookup (import_env, symbol);
   SCM proc_as_nr = SCM_CADDR (extended_data);
-  unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, 0, NULL);
+  unsigned long int proc_as_ul = scm_to_ulong (proc_as_nr);
   scm_environment_folder proc = (scm_environment_folder) proc_as_ul;
   SCM data = SCM_CDDDR (extended_data);
 
-  if (SCM_CONSP (owner) && SCM_EQ_P (SCM_CAR (owner), imported_env))
+  if (scm_is_pair (owner) && scm_is_eq (SCM_CAR (owner), imported_env))
     owner = import_environment_conflict (import_env, symbol, owner);
 
   if (SCM_ENVIRONMENT_P (owner))
@@ -1660,11 +1572,11 @@ import_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
 static SCM
 import_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init)
 {
-  SCM proc_as_nr = scm_ulong2num ((unsigned long int) proc);
+  SCM proc_as_nr = scm_from_ulong ((unsigned long) proc);
   SCM result = init;
   SCM l;
 
-  for (l = IMPORT_ENVIRONMENT (env)->imports; !SCM_NULLP (l); l = SCM_CDR (l))
+  for (l = IMPORT_ENVIRONMENT (env)->imports; !scm_is_null (l); l = SCM_CDR (l))
     {
       SCM imported_env = SCM_CAR (l);
       SCM extended_data = scm_cons (env, scm_cons2 (imported_env, proc_as_nr, data));
@@ -1707,7 +1619,7 @@ import_environment_set_x (SCM env, SCM sym, SCM val)
     {
       return SCM_UNDEFINED;
     }
-  else if (SCM_CONSP (owner))
+  else if (scm_is_pair (owner))
     {
       SCM resolve = import_environment_conflict (env, sym, owner);
 
@@ -1734,7 +1646,7 @@ import_environment_cell (SCM env, SCM sym, int for_write)
     {
       return SCM_UNDEFINED;
     }
-  else if (SCM_CONSP (owner))
+  else if (scm_is_pair (owner))
     {
       SCM resolve = import_environment_conflict (env, sym, owner);
 
@@ -1751,34 +1663,16 @@ import_environment_cell (SCM env, SCM sym, int for_write)
 #undef FUNC_NAME
 
 
-static SCM
-import_environment_mark (SCM env)
-{
-  scm_gc_mark (IMPORT_ENVIRONMENT (env)->imports);
-  scm_gc_mark (IMPORT_ENVIRONMENT (env)->import_observers);
-  scm_gc_mark (IMPORT_ENVIRONMENT (env)->conflict_proc);
-  return core_environments_mark (env);
-}
-
-
-static void
-import_environment_free (SCM env)
-{
-  core_environments_finalize (env);
-  scm_gc_free (IMPORT_ENVIRONMENT (env), sizeof (struct import_environment),
-              "import environment");
-}
-
 
 static int
 import_environment_print (SCM type, SCM port, 
                          scm_print_state *pstate SCM_UNUSED)
 {
-  SCM address = scm_ulong2num (SCM_UNPACK (type));
-  SCM base16 = scm_number_to_string (address, SCM_MAKINUM (16));
+  SCM address = scm_from_size_t (SCM_UNPACK (type));
+  SCM base16 = scm_number_to_string (address, scm_from_int (16));
 
   scm_puts ("#<import environment ", port);
-  scm_puts (SCM_STRING_CHARS (base16), port);
+  scm_display (base16, port);
   scm_puts (">", port);
 
   return 1;
@@ -1794,8 +1688,6 @@ static struct scm_environment_funcs import_environment_funcs = {
   import_environment_cell,
   core_environments_observe,
   core_environments_unobserve,
-  import_environment_mark,
-  import_environment_free,
   import_environment_print
 };
 
@@ -1868,7 +1760,7 @@ SCM_DEFINE (scm_import_environment_p, "import-environment?", 1, 0, 0,
            "@code{#f} otherwise.")
 #define FUNC_NAME s_scm_import_environment_p
 {
-  return SCM_BOOL (SCM_IMPORT_ENVIRONMENT_P (object));
+  return scm_from_bool (SCM_IMPORT_ENVIRONMENT_P (object));
 }
 #undef FUNC_NAME
 
@@ -1897,20 +1789,20 @@ SCM_DEFINE (scm_import_environment_set_imports_x, "import-environment-set-import
   SCM l;
 
   SCM_ASSERT (SCM_IMPORT_ENVIRONMENT_P (env), env, SCM_ARG1, FUNC_NAME);
-  for (l = imports; SCM_CONSP (l); l = SCM_CDR (l))
+  for (l = imports; scm_is_pair (l); l = SCM_CDR (l))
     {
       SCM obj = SCM_CAR (l);
       SCM_ASSERT (SCM_ENVIRONMENT_P (obj), imports, SCM_ARG2, FUNC_NAME);
     }
-  SCM_ASSERT (SCM_NULLP (l), imports, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_null (l), imports, SCM_ARG2, FUNC_NAME);
 
-  for (l = body->import_observers; !SCM_NULLP (l); l = SCM_CDR (l))
+  for (l = body->import_observers; !scm_is_null (l); l = SCM_CDR (l))
     {
       SCM obs = SCM_CAR (l);
       SCM_ENVIRONMENT_UNOBSERVE (env, obs);
     }
 
-  for (l = imports; !SCM_NULLP (l); l = SCM_CDR (l))
+  for (l = imports; !scm_is_null (l); l = SCM_CDR (l))
     {
       SCM imp = SCM_CAR (l);
       SCM obs = SCM_ENVIRONMENT_OBSERVE (imp, import_environment_observer, env, 1);
@@ -1963,7 +1855,7 @@ export_environment_ref (SCM env, SCM sym)
   struct export_environment *body = EXPORT_ENVIRONMENT (env);
   SCM entry = scm_assq (sym, body->signature);
 
-  if (SCM_FALSEP (entry))
+  if (scm_is_false (entry))
     return SCM_UNDEFINED;
   else
     return SCM_ENVIRONMENT_REF (body->private, sym);
@@ -1978,7 +1870,7 @@ export_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM ini
   SCM result = init;
   SCM l;
 
-  for (l = body->signature; !SCM_NULLP (l); l = SCM_CDR (l))
+  for (l = body->signature; !scm_is_null (l); l = SCM_CDR (l))
     {
       SCM symbol = SCM_CAR (l);
       SCM value = SCM_ENVIRONMENT_REF (body->private, symbol);
@@ -2016,13 +1908,13 @@ export_environment_set_x (SCM env, SCM sym, SCM val)
   struct export_environment *body = EXPORT_ENVIRONMENT (env);
   SCM entry = scm_assq (sym, body->signature);
 
-  if (SCM_FALSEP (entry))
+  if (scm_is_false (entry))
     {
       return SCM_UNDEFINED;
     }
   else
     {
-      if (SCM_EQ_P (SCM_CADR (entry), symbol_mutable_location))
+      if (scm_is_eq (SCM_CADR (entry), symbol_mutable_location))
        return SCM_ENVIRONMENT_SET (body->private, sym, val);
       else
        return SCM_ENVIRONMENT_LOCATION_IMMUTABLE;
@@ -2038,13 +1930,13 @@ export_environment_cell (SCM env, SCM sym, int for_write)
   struct export_environment *body = EXPORT_ENVIRONMENT (env);
   SCM entry = scm_assq (sym, body->signature);
 
-  if (SCM_FALSEP (entry))
+  if (scm_is_false (entry))
     {
       return SCM_UNDEFINED;
     }
   else
     {
-      if (!for_write || SCM_EQ_P (SCM_CADR (entry), symbol_mutable_location))
+      if (!for_write || scm_is_eq (SCM_CADR (entry), symbol_mutable_location))
        return SCM_ENVIRONMENT_CELL (body->private, sym, for_write);
       else
        return SCM_ENVIRONMENT_LOCATION_IMMUTABLE;
@@ -2053,37 +1945,16 @@ export_environment_cell (SCM env, SCM sym, int for_write)
 #undef FUNC_NAME
 
 
-static SCM
-export_environment_mark (SCM env)
-{
-  struct export_environment *body = EXPORT_ENVIRONMENT (env);
-
-  scm_gc_mark (body->private);
-  scm_gc_mark (body->private_observer);
-  scm_gc_mark (body->signature);
-
-  return core_environments_mark (env);
-}
-
-
-static void
-export_environment_free (SCM env)
-{
-  core_environments_finalize (env);
-  scm_gc_free (EXPORT_ENVIRONMENT (env), sizeof (struct export_environment),
-              "export environment");
-}
-
 
 static int
 export_environment_print (SCM type, SCM port,
                          scm_print_state *pstate SCM_UNUSED)
 {
-  SCM address = scm_ulong2num (SCM_UNPACK (type));
-  SCM base16 = scm_number_to_string (address, SCM_MAKINUM (16));
+  SCM address = scm_from_size_t (SCM_UNPACK (type));
+  SCM base16 = scm_number_to_string (address, scm_from_int (16));
 
   scm_puts ("#<export environment ", port);
-  scm_puts (SCM_STRING_CHARS (base16), port);
+  scm_display (base16, port);
   scm_puts (">", port);
 
   return 1;
@@ -2099,8 +1970,6 @@ static struct scm_environment_funcs export_environment_funcs = {
   export_environment_cell,
   core_environments_observe,
   core_environments_unobserve,
-  export_environment_mark,
-  export_environment_free,
   export_environment_print
 };
 
@@ -2194,7 +2063,7 @@ SCM_DEFINE (scm_export_environment_p, "export-environment?", 1, 0, 0,
            "@code{#f} otherwise.")
 #define FUNC_NAME s_scm_export_environment_p
 {
-  return SCM_BOOL (SCM_EXPORT_ENVIRONMENT_P (object));
+  return scm_from_bool (SCM_EXPORT_ENVIRONMENT_P (object));
 }
 #undef FUNC_NAME
 
@@ -2251,11 +2120,11 @@ export_environment_parse_signature (SCM signature, const char* caller)
   SCM result = SCM_EOL;
   SCM l;
 
-  for (l = signature; SCM_CONSP (l); l = SCM_CDR (l))
+  for (l = signature; scm_is_pair (l); l = SCM_CDR (l))
     {
       SCM entry = SCM_CAR (l);
 
-      if (SCM_SYMBOLP (entry))
+      if (scm_is_symbol (entry))
        {
          SCM new_entry = scm_cons2 (entry, symbol_immutable_location, SCM_EOL);
          result = scm_cons (new_entry, result);
@@ -2269,22 +2138,22 @@ export_environment_parse_signature (SCM signature, const char* caller)
          SCM mutability;
          SCM l2;
 
-         SCM_ASSERT (SCM_CONSP (entry), entry, SCM_ARGn, caller);
-         SCM_ASSERT (SCM_SYMBOLP (SCM_CAR (entry)), entry, SCM_ARGn, caller);
+         SCM_ASSERT (scm_is_pair (entry), entry, SCM_ARGn, caller);
+         SCM_ASSERT (scm_is_symbol (SCM_CAR (entry)), entry, SCM_ARGn, caller);
 
          sym = SCM_CAR (entry);
 
-         for (l2 = SCM_CDR (entry); SCM_CONSP (l2); l2 = SCM_CDR (l2))
+         for (l2 = SCM_CDR (entry); scm_is_pair (l2); l2 = SCM_CDR (l2))
            {
              SCM attribute = SCM_CAR (l2);
-             if (SCM_EQ_P (attribute, symbol_immutable_location))
+             if (scm_is_eq (attribute, symbol_immutable_location))
                immutable = 1;
-             else if (SCM_EQ_P (attribute, symbol_mutable_location))
+             else if (scm_is_eq (attribute, symbol_mutable_location))
                mutable = 1;
              else
                SCM_ASSERT (0, entry, SCM_ARGn, caller);
            }
-         SCM_ASSERT (SCM_NULLP (l2), entry, SCM_ARGn, caller);
+         SCM_ASSERT (scm_is_null (l2), entry, SCM_ARGn, caller);
          SCM_ASSERT (!mutable || !immutable, entry, SCM_ARGn, caller);
 
          if (!mutable && !immutable)
@@ -2295,7 +2164,7 @@ export_environment_parse_signature (SCM signature, const char* caller)
          result = scm_cons (new_entry, result);
        }
     }
-  SCM_ASSERT (SCM_NULLP (l), signature, SCM_ARGn, caller);
+  SCM_ASSERT (scm_is_null (l), signature, SCM_ARGn, caller);
 
   /* Dirk:FIXME:: Now we know that signature is syntactically correct.  There
    * are, however, no checks for symbols entered twice with contradicting
@@ -2330,13 +2199,10 @@ scm_environments_prehistory ()
 {
   /* create environment smob */
   scm_tc16_environment = scm_make_smob_type ("environment", 0);
-  scm_set_smob_mark (scm_tc16_environment, environment_mark);
-  scm_set_smob_free (scm_tc16_environment, environment_free);
   scm_set_smob_print (scm_tc16_environment, environment_print);
 
   /* create observer smob */
   scm_tc16_observer = scm_make_smob_type ("observer", 0);
-  scm_set_smob_mark (scm_tc16_observer, observer_mark);
   scm_set_smob_print (scm_tc16_observer, observer_print);
 
   /* create system environment */
@@ -2348,9 +2214,7 @@ scm_environments_prehistory ()
 void
 scm_init_environments ()
 {
-#ifndef SCM_MAGIC_SNARFER
 #include "libguile/environments.x"
-#endif
 }