build: Don't include <config.h> in native programs when cross-compiling.
[bpt/guile.git] / libguile / variable.c
index a97444c..a9cc60e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2006, 2008, 2011 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
@@ -92,7 +92,7 @@ SCM_DEFINE (scm_variable_ref, "variable-ref", 1, 0, 0,
   SCM val;
   SCM_VALIDATE_VARIABLE (1, var);
   val = SCM_VARIABLE_REF (var);
-  if (val == SCM_UNDEFINED)
+  if (scm_is_eq (val, SCM_UNDEFINED))
     SCM_MISC_ERROR ("variable is unbound: ~S", scm_list_1 (var));
   return val;
 }
@@ -111,6 +111,18 @@ SCM_DEFINE (scm_variable_set_x, "variable-set!", 2, 0, 0,
 }
 #undef FUNC_NAME
 
+SCM_DEFINE (scm_variable_unset_x, "variable-unset!", 1, 0, 0,
+            (SCM var),
+            "Ensure that @var{var} is not bound to a value.\n"
+            "@var{var} must be a variable object.")
+#define FUNC_NAME s_scm_variable_unset_x
+{
+  SCM_VALIDATE_VARIABLE (1, var);
+  SCM_VARIABLE_SET (var, SCM_UNDEFINED);
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
 SCM_DEFINE (scm_variable_bound_p, "variable-bound?", 1, 0, 0, 
             (SCM var),
             "Return @code{#t} iff @var{var} is bound to a value.\n"
@@ -118,7 +130,7 @@ SCM_DEFINE (scm_variable_bound_p, "variable-bound?", 1, 0, 0,
 #define FUNC_NAME s_scm_variable_bound_p
 {
   SCM_VALIDATE_VARIABLE (1, var);
-  return scm_from_bool (SCM_VARIABLE_REF (var) != SCM_UNDEFINED);
+  return scm_from_bool (!scm_is_eq (SCM_VARIABLE_REF (var), SCM_UNDEFINED));
 }
 #undef FUNC_NAME