我有一个point
记录类型定义如下时:元数不匹配构建子记录类型
(define-record-type point
(make-point x y)
point?
(x point-x)
(y point-y)
)
现在,我想扩展point
记录类型,定义了一个新的记录类型如下:
(define-record-type cpoint
(make-cpoint color)
cpoint?
(color cpoint-color)
(parent point)
)
当我在计划shell中运行上述定义时,一切正常。我可以正确构建point
类型。然而,当我尝试构建cpoint
类型如下:
(define p2 (make-cpoint 8 9 'red))
我收到以下错误:
; ...rfi/9/record.rkt:100:28: arity mismatch;; the expected number of arguments does not match the given number; expected: 1; given: 3; [,bt for context]
我因为cpoint
以为是point
孩子,它应该接受的参数为point
在其构造函数中键入。
我该如何做这项工作?
P.S我是Scheme的新手。