我如何访问r的图层属性,1去哪里?我只能使用point-x和point-y访问2和3,即使它是一个共同值结构..
#lang racket
(define (object-constructor super-type layer)
(struct commmon-value(layer)
#:super super-type
#:transparent
#:property prop:procedure (lambda (self)
layer))
comm)
(struct point (x y)
#:transparent
#:property prop:procedure (lambda (self)
x y)))
(define r ((object-constructor struct:point 1) 2 3 4))
(point-x r)
(point-y r)
r
> (comm 2 3 4)
答案 0 :(得分:1)
#lang racket
(struct layer (common)
#:transparent
#:property prop:procedure (lambda (self) (layer-common self)))
(struct point layer (x y)
#:transparent
#:property prop:procedure (lambda (self) (layer-common self)))
(define r (point 1 2 3))
(match-define (point c x y) r)
(r)
c
x
y
输出结果为:
1
1
2
3