Sometime ago, there was a discussion on the Racket users list about an experimental version of define-record-type
(R6RS records) which supports a shorthand notation for element access.
This extended version of define-record-type
is available as an R6RS library.
Since Racket supports R6RS as one of it's languages, it's possible to use (dharmalab records define-record-type)
from within programs written in the Racket language or the R6RS language.
To try the library out in Racket:
$ cd ~/scheme # Where '~/scheme' is the path to your Scheme libraries
$ git clone git://github.com/dharmatech/dharmalab.git
Adjust your PLTCOLLECTS
environment variable:
export PLTCOLLECTS=/usr/racket/collects:~/scheme
Put this in the DrRacket definitions window:
#!r6rs
(import (rnrs)
(dharmalab records define-record-type))
(define-record-type++ point
(fields x y))
Run the program. Now in the interactions window:
> (define p0 (make-point 10 20))
> (is-point p0)
> p0.x
10
> p0.y
20
>