我有一個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的新手。