From ac136bbc2e7a7a44cdbf86341e67639fa786fbfc Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 13 Feb 2014 14:59:51 +0900 Subject: [PATCH] add gensym function --- src/macro.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/macro.c b/src/macro.c index f44f5812..b2df4447 100644 --- a/src/macro.c +++ b/src/macro.c @@ -637,6 +637,18 @@ pic_macro_include(pic_state *pic) return body; } +static pic_value +pic_macro_gensym(pic_state *pic) +{ + static const char skel[] = ".g"; + pic_sym uniq; + + pic_get_args(pic, ""); + + uniq = pic_gensym(pic, pic_intern_cstr(pic, skel)); + return pic_symbol_value(uniq); +} + static pic_value pic_macro_make_sc(pic_state *pic) { @@ -898,6 +910,7 @@ pic_init_macro(pic_state *pic) xh_put_int(pic->lib->senv->name, pic->sDEFINE_MACRO, pic->sDEFINE_MACRO); pic_export(pic, pic->sDEFINE_MACRO); + pic_defun(pic, "gensym", pic_macro_gensym); pic_defun(pic, "make-syntactic-closure", pic_macro_make_sc); pic_defun(pic, "identifier?", pic_macro_identifier_p); pic_defun(pic, "identifier=?", pic_macro_identifier_eq_p);