From 772c59dead74d672d2a8217aaee0d921260500d1 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 6 Aug 2014 02:14:43 +0900 Subject: [PATCH] add (picrin symbol) --- piclib/CMakeLists.txt | 1 + piclib/picrin/base.scm | 2 +- piclib/picrin/macro.scm | 1 + piclib/scheme/base.scm | 8 ++++++++ src/symbol.c | 13 +++++++++---- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/piclib/CMakeLists.txt b/piclib/CMakeLists.txt index 3d08eb27..87dd693f 100644 --- a/piclib/CMakeLists.txt +++ b/piclib/CMakeLists.txt @@ -1,6 +1,7 @@ list(APPEND PICLIB_SCHEME_LIBS ${PROJECT_SOURCE_DIR}/piclib/picrin/base.scm ${PROJECT_SOURCE_DIR}/piclib/picrin/list.scm + ${PROJECT_SOURCE_DIR}/piclib/picrin/symbol.scm ${PROJECT_SOURCE_DIR}/piclib/picrin/macro.scm ${PROJECT_SOURCE_DIR}/piclib/scheme/base.scm diff --git a/piclib/picrin/base.scm b/piclib/picrin/base.scm index b7174be3..c4ca864f 100644 --- a/piclib/picrin/base.scm +++ b/piclib/picrin/base.scm @@ -2,7 +2,7 @@ (import (rename (picrin base core) (define define*)) (picrin base macro) (picrin base list) - (scheme base)) + (picrin base symbol)) (define-syntax define (lambda (form use-env mac-env) diff --git a/piclib/picrin/macro.scm b/piclib/picrin/macro.scm index 016fa95d..3b12d3ff 100644 --- a/piclib/picrin/macro.scm +++ b/piclib/picrin/macro.scm @@ -4,6 +4,7 @@ (import (picrin base macro) (picrin base) (picrin list) + (picrin symbol) (scheme base) (picrin dictionary)) diff --git a/piclib/scheme/base.scm b/piclib/scheme/base.scm index 39ddfe2c..f689a4f9 100644 --- a/piclib/scheme/base.scm +++ b/piclib/scheme/base.scm @@ -1,6 +1,7 @@ (define-library (scheme base) (import (picrin base) (picrin list) + (picrin symbol) (picrin macro)) (export define set! lambda quote @@ -842,6 +843,13 @@ assv assoc) + ;; 6.5 Symbols + + (export symbol? + symbol=? + symbol->string + string->symbol) + ;; 6.6 Characters (define-macro (define-char-transitive-predicate name op) diff --git a/src/symbol.c b/src/symbol.c index 10fd3822..2add0769 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -149,8 +149,13 @@ pic_symbol_string_to_symbol(pic_state *pic) void pic_init_symbol(pic_state *pic) { - pic_defun(pic, "symbol?", pic_symbol_symbol_p); - pic_defun(pic, "symbol=?", pic_symbol_symbol_eq_p); - pic_defun(pic, "symbol->string", pic_symbol_symbol_to_string); - pic_defun(pic, "string->symbol", pic_symbol_string_to_symbol); + pic_deflibrary (pic, "(picrin base symbol)") { + pic_defun(pic, "symbol?", pic_symbol_symbol_p); + pic_defun(pic, "symbol->string", pic_symbol_symbol_to_string); + pic_defun(pic, "string->symbol", pic_symbol_string_to_symbol); + } + + pic_deflibrary (pic, "(picrin symbol)") { + pic_defun(pic, "symbol=?", pic_symbol_symbol_eq_p); + } }