add predicate record? to (picrin record), and fix bug of record-type predicate
This commit is contained in:
parent
cd96014104
commit
ef38874850
|
@ -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
|
||||
|
|
11
src/record.c
11
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);
|
||||
|
|
Loading…
Reference in New Issue