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);