1 /* Copyright (C) 1998,1999,2000,2001,2002,2003, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include "libguile/_scm.h"
26 #include "libguile/eval.h"
27 #include "libguile/fluids.h"
28 #include "libguile/modules.h"
30 #include "libguile/validate.h"
31 #include "libguile/evalext.h"
33 SCM_DEFINE (scm_defined_p
, "defined?", 1, 1, 0,
34 (SCM sym
, SCM module
),
35 "Return @code{#t} if @var{sym} is defined in the module "
36 "@var{module} or the current module when @var{module} is not"
38 #define FUNC_NAME s_scm_defined_p
42 SCM_VALIDATE_SYMBOL (1, sym
);
44 if (SCM_UNBNDP (module
))
45 module
= scm_current_module ();
47 SCM_VALIDATE_MODULE (2, module
);
49 var
= scm_module_variable (module
, sym
);
51 return (scm_is_false (var
) || SCM_UNBNDP (SCM_VARIABLE_REF (var
))
58 SCM_DEFINE (scm_self_evaluating_p
, "self-evaluating?", 1, 0, 0,
60 "Return #t for objects which Guile considers self-evaluating")
61 #define FUNC_NAME s_scm_self_evaluating_p
63 switch (SCM_ITAG3 (obj
))
70 /* characters, booleans, other immediates */
71 return scm_from_bool (!scm_is_null_and_not_nil (obj
));
73 switch (SCM_TYP7 (obj
))
78 case scm_tc7_hashtable
:
80 case scm_tc7_dynamic_state
:
89 case scm_tc7_bytevector
:
91 case scm_tc7_bitvector
:
98 SCM_MISC_ERROR ("Internal error: Object ~S has unknown type",
100 return SCM_UNSPECIFIED
; /* never reached */
107 #include "libguile/evalext.x"