1 /* Copyright (C) 1998,1999,2000,2001,2002,2003, 2006, 2008 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
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but 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 02110-1301 USA
24 #include "libguile/_scm.h"
25 #include "libguile/eval.h"
26 #include "libguile/fluids.h"
27 #include "libguile/modules.h"
29 #include "libguile/validate.h"
30 #include "libguile/evalext.h"
32 SCM_DEFINE (scm_defined_p, "defined?", 1, 1, 0,
34 "Return @code{#t} if @var{sym} is defined in the lexical "
35 "environment @var{env}. When @var{env} is not specified, "
36 "look in the top-level environment as defined by the "
38 #define FUNC_NAME s_scm_defined_p
42 SCM_VALIDATE_SYMBOL (1, sym);
45 var = scm_sym2var (sym, scm_current_module_lookup_closure (),
51 for (; SCM_NIMP (frames); frames = SCM_CDR (frames))
53 SCM_ASSERT (scm_is_pair (frames), env, SCM_ARG2, FUNC_NAME);
55 if (scm_is_true (scm_procedure_p (b)))
57 SCM_ASSERT (scm_is_pair (b), env, SCM_ARG2, FUNC_NAME);
58 for (b = SCM_CAR (b); SCM_NIMP (b); b = SCM_CDR (b))
62 if (scm_is_eq (b, sym))
67 if (scm_is_eq (SCM_CAR (b), sym))
71 var = scm_sym2var (sym,
72 SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F,
76 return (scm_is_false (var) || SCM_UNBNDP (SCM_VARIABLE_REF (var))
83 SCM_REGISTER_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
86 SCM_DEFINE (scm_self_evaluating_p, "self-evaluating?", 1, 0, 0,
88 "Return #t for objects which Guile considers self-evaluating")
89 #define FUNC_NAME s_scm_self_evaluating_p
91 switch (SCM_ITAG3 (obj))
98 /* characters, booleans, other immediates */
99 return scm_from_bool (!scm_is_null (obj));
101 switch (SCM_TYP7 (obj))
103 case scm_tcs_closures:
118 SCM_MISC_ERROR ("Internal error: Object ~S has unknown type",
120 return SCM_UNSPECIFIED; /* never reached */
127 #include "libguile/evalext.x"