From ef3887485062f2d324c08caa7aa94f03118f5f24 Mon Sep 17 00:00:00 2001 From: Yuito Murase Date: Mon, 4 Aug 2014 23:01:47 +0900 Subject: [PATCH] add predicate record? to (picrin record), and fix bug of record-type predicate --- piclib/scheme/base.scm | 3 ++- src/record.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/piclib/scheme/base.scm b/piclib/scheme/base.scm index ae6416fe..dc697aa2 100644 --- a/piclib/scheme/base.scm +++ b/piclib/scheme/base.scm @@ -765,7 +765,8 @@ (let ((rectype (cadr form)) (name (caddr form))) `(define (,name obj) - (record-of? obj ,rectype)))))) + (and (record? obj) + (record-of? obj ,rectype))))))) (define-syntax define-record-field (ir-macro-transformer diff --git a/src/record.c b/src/record.c index 572eb013..8412c874 100644 --- a/src/record.c +++ b/src/record.c @@ -59,6 +59,16 @@ pic_record_record(pic_state *pic) return pic_obj_value(rec); } +static pic_value +pic_record_record_p(pic_state *pic) +{ + pic_value rec; + + pic_get_args(pic, "o", &rec); + + return pic_bool_value(pic_record_p(rec)); +} + static pic_value pic_record_record_of(pic_state *pic) { @@ -100,6 +110,7 @@ pic_init_record(pic_state *pic) { pic_deflibrary (pic, "(picrin record)") { pic_defun(pic, "make-record", pic_record_record); + pic_defun(pic, "record?", pic_record_record_p); pic_defun(pic, "record-of?", pic_record_record_of); pic_defun(pic, "record-ref", pic_record_record_ref); pic_defun(pic, "record-set!", pic_record_record_set);