Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:45:44+00:00 2026-05-27T19:45:44+00:00

In Racket this gives me an error: (struct point-in-plane (pos_x pos_y)) (struct pixel point-in-plane

  • 0

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) 

For it to work I need to replace the last two lines with:

(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 x y))
(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 Scheme (and Racket) don’t allow you to access the fields of a subtype that were defined in the parent by:
subtypeID-fieldID instead of by parenttypeID-fieldID

I.e. in my case allowing me to use pixel-pos_x and pixel-pos_y .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:45:45+00:00Added an answer on May 27, 2026 at 7:45 pm

    One reason is that struct allows you to define sub-structs with identically named fields. For example:

    (struct base (x y))
    (struct sub base (x y))
    
    (define rec (sub 1 2 3 4))
    (base-x rec) ; => 1
    (sub-x rec)  ; => 3
    

    This is because structs don’t really know about field names. From the Racket documentation: “A structure type’s fields are essentially unnamed, though names are supported for error-reporting purposes.” You would have to disallow this behavior in order to get extra accessors for sub-structs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following racket function produces the error: reference to undefined identifier: val This is
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
Currently learning Scheme/Racket and have problem running this piece of code. (if (or (<
I tested the following code in Racket/DrScheme: (define (makem) (define x 34) (list (lambda
I wrote a quick-sort in scheme (racket) #lang racket (define (quick-sort xs) (let* ([p
I need some basic stuff for working with the GUI library in Racket. How
A rookie Racket question. I'm using Krishnamurthi's PLAI textbook for this one, and the
Does racket have something like guile's procedure-source function, e.g.: (define (plus-one x) (+ 1
I have a problem with this example (define (+ x y) (if (= x
I am reading DrRacket document http://docs.racket-lang.org/guide/binding.html There is a function (define f (lambda (append)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.