summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorMikael Djurfeldt <djurfeldt@nada.kth.se>1997-02-26 12:08:26 +0000
committerMikael Djurfeldt <djurfeldt@nada.kth.se>1997-02-26 12:08:26 +0000
commit1dd28b3d653921db43755c8eb37c61a3d3805ec6 (patch)
tree91276ffb1bd0b051490bb22dbc41cf521a95c121 /libguile
parentafa64ca8188f46c552c2a4cc2323d2cbba31bd49 (diff)
downloadguile-1dd28b3d653921db43755c8eb37c61a3d3805ec6.tar.gz
* symbols.c, symbols.h (scm_symbol_value0): New function. Can be
used from C to easily lookup the value of a symbol in the current module.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/ChangeLog6
-rw-r--r--libguile/symbols.c18
-rw-r--r--libguile/symbols.h1
3 files changed, 25 insertions, 0 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 51a031853..2119cfd42 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,9 @@
+Wed Feb 26 12:53:58 1997 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
+
+ * symbols.c, symbols.h (scm_symbol_value0): New function. Can be
+ used from C to easily lookup the value of a symbol in the current
+ module.
+
Tue Feb 25 00:14:10 1997 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
* unif.c (scm_init_unif): Added #include "unif.x". (There are two
diff --git a/libguile/symbols.c b/libguile/symbols.c
index 1bd957f7d..73b27fbbf 100644
--- a/libguile/symbols.c
+++ b/libguile/symbols.c
@@ -422,6 +422,24 @@ scm_sysintern0 (name)
return scm_sysintern0_no_module_lookup (name);
}
+/* Lookup the value of the symbol named by the nul-terminated string
+ NAME in the current module. */
+SCM
+scm_symbol_value0 (name)
+ char *name;
+{
+ /* This looks silly - we look up the symbol twice. But it is in
+ fact necessary given the current module system because the module
+ lookup closures are written in scheme which needs real symbols. */
+ SCM symbol = scm_intern_obarray_soft (name, strlen (name), scm_symhash, 0);
+ SCM vcell = scm_sym2vcell (SCM_CAR (symbol),
+ SCM_CDR (scm_top_level_lookup_closure_var),
+ SCM_BOOL_F);
+ if (SCM_FALSEP (vcell))
+ return SCM_UNDEFINED;
+ return SCM_CDR (vcell);
+}
+
SCM_PROC(s_symbol_p, "symbol?", 1, 0, 0, scm_symbol_p);
SCM
diff --git a/libguile/symbols.h b/libguile/symbols.h
index 44f154286..d4808dc8b 100644
--- a/libguile/symbols.h
+++ b/libguile/symbols.h
@@ -113,6 +113,7 @@ extern SCM scm_intern SCM_P ((char *name, scm_sizet len));
extern SCM scm_intern0 SCM_P ((char * name));
extern SCM scm_sysintern SCM_P ((char *name, SCM val));
extern SCM scm_sysintern0 SCM_P ((char *name));
+extern SCM scm_symbol_value0 SCM_P ((char *name));
extern SCM scm_symbol_p SCM_P ((SCM x));
extern SCM scm_symbol_to_string SCM_P ((SCM s));
extern SCM scm_string_to_symbol SCM_P ((SCM s));