commit a57b81b6112987e11bf243c174dfdab8430520c0
parent 2a386d05ae18af5d8cc32f260b23b28d61ba37fc
Author: Andres Navarro <canavarro82@gmail.com>
Date: Wed, 23 Mar 2011 16:55:00 -0300
Added string->symbol to the ground environment.
Diffstat:
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/kground.c b/src/kground.c
@@ -652,7 +652,7 @@ void kinit_ground_env(klisp_State *K)
each time */
/* TODO */
- /* 13.3.2? symbol->string */
+ /* 13.3.2? string->symbol */
/* TEMP: for now this can create symbols with no external representation
this includes all symbols with non identifiers characters.
*/
@@ -662,7 +662,8 @@ void kinit_ground_env(klisp_State *K)
because the report only says that read objects when written and read
again must be equal? which happens here
*/
- /* TODO */
+ add_applicative(K, ground_env, "string->symbol", string_to_symbol, 0);
+
/*
**
diff --git a/src/kgstrings.c b/src/kgstrings.c
@@ -455,7 +455,7 @@ void string_fillS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
each time */
/* TODO */
-/* 13.3.2? symbol->string */
+/* 13.3.2? string->symbol */
/* TEMP: for now this can create symbols with no external representation
this includes all symbols with non identifiers characters.
*/
@@ -465,7 +465,15 @@ void string_fillS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
because the report only says that read objects when written and read
again must be equal? which happens here
*/
-/* TODO */
+void string_to_symbol(klisp_State *K, TValue *xparams, TValue ptree,
+ TValue denv)
+{
+ UNUSED(xparams);
+ UNUSED(denv);
+ bind_1tp(K, "string->symbol", ptree, "string", ttisstring, str);
+ TValue new_sym = ksymbol_new_check_i(K, str);
+ kapply_cc(K, new_sym);
+}
/* Helpers */
bool kstringp(TValue obj)
diff --git a/src/kgstrings.h b/src/kgstrings.h
@@ -86,7 +86,7 @@ void string_fillS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv);
each time */
/* TODO */
-/* 13.3.2? symbol->string */
+/* 13.3.2? string->symbol */
/* TEMP: for now this can create symbols with no external representation
this includes all symbols with non identifiers characters.
*/
@@ -96,7 +96,8 @@ void string_fillS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv);
because the report only says that read objects when written and read
again must be equal? which happens here
*/
-/* TODO */
+void string_to_symbol(klisp_State *K, TValue *xparams, TValue ptree,
+ TValue denv);
/* Helpers */
bool kstringp(TValue obj);