【发布时间】:2011-12-23 20:03:25
【问题描述】:
在球拍中,这给了我一个错误:
(struct point-in-plane (pos_x pos_y))
(struct pixel point-in-plane (color))
(define a-pixel (pixel 1 2 "blue"))
(pixel-color a-pixel)
(pixel-pos_x a-pixel)
(pixel-pos_y a-pixel)
为了让它工作,我需要将最后两行替换为:
(point-in-plane-pos_x a-pixel)
(point-in-plane-pos_y a-pixel)
在 R6RS 中类似
#!r6rs
(import (rnrs))
(define-record-type point (fields x y))
(define-record-type cpoint (parent point) (fields color))
(define blue-point (make-cpoint 1 2 "blue"))
(write (cpoint-x blue-point))
给出类似的错误。
Scheme(和 Racket)不允许您访问通过以下方式在父类中定义的子类型的字段的原因是什么: subtypeID-fieldID 而不是 parenttypeID-fieldID
即在我的情况下,允许我使用 pixel-pos_x 和 pixel-pos_y 。
【问题讨论】: