In Racket, this gives me an error:
(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)
To do this, I need to replace the last two lines:
(point-in-plane-pos_x a-pixel) (point-in-plane-pos_y a-pixel)
Similarly in R6RS
#!r6rs (import (rnrs)) (define-record-type point (fields xy)) (define-record-type cpoint (parent point) (fields color)) (define blue-point (make-cpoint 1 2 "blue")) (write (cpoint-x blue-point))
Gives a similar error.
What is the reason why Scheme (and Racket) does not allow you to access the subtype fields that were defined in the parent element: subtypeID-fieldID instead of parenttypeID-fieldID
those. in my case, letting me use pixel-pos_x and pixel-pos_y.
source share