Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Created November 30, 2010 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dharmatech/722639 to your computer and use it in GitHub Desktop.
Save dharmatech/722639 to your computer and use it in GitHub Desktop.

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
> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment