From 464925d220036391ec0a8cd1a709c73d12a808d5 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 3 Mar 2014 22:21:34 +0900 Subject: [PATCH] refactor pic_for_each --- include/picrin/pair.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/picrin/pair.h b/include/picrin/pair.h index 8db722d6..632e45dd 100644 --- a/include/picrin/pair.h +++ b/include/picrin/pair.h @@ -32,14 +32,13 @@ pic_value pic_list6(pic_state *, pic_value, pic_value, pic_value, pic_value, pic pic_value pic_list_by_array(pic_state *, size_t, pic_value *); pic_value pic_make_list(pic_state *, int, pic_value); -#define PIC_FOR_EACH_HELPER(var, tmp, list) \ +#define pic_for_each(var, list) \ + pic_for_each_helper__(var, GENSYM(pic_for_each_tmp__), list) +#define pic_for_each_helper__(var, tmp, list) \ for (pic_value tmp = (list); \ pic_nil_p(tmp) ? false : ((var = pic_car(pic, tmp)), true); \ tmp = pic_cdr(pic, tmp)) -#define pic_for_each(var, list) \ - PIC_FOR_EACH_HELPER(var, GENSYM(pic_for_each_tmp__), list) \ - int pic_length(pic_state *, pic_value); pic_value pic_reverse(pic_state *, pic_value); pic_value pic_append(pic_state *, pic_value, pic_value);