record-rtd(3scm) Scheme Programmer's Manual record-rtd(3scm)

record-rtd - get the rtd for the type of a record

(import (rnrs))                     ;R6RS
(import (rnrs records inspection))  ;R6RS

(record-rtd record)

Returns the rtd representing the type of record if the type is not opaque.

The rtd of the most precise type is returned; that is, the type t such that record is of type t but not of any type that extends t.

Most R6RS implementations define enumerations in terms of records.

Returns a single value; an rtd.

(define rtd-user
  (make-record-type-descriptor
    'user #f #f #f #f
    '#((immutable login) (immutable realname))))
(define rcd-user
  (make-record-constructor-descriptor
    rtd-user #f
    (lambda (p)
      (lambda (login realname)
        (p login realname)))))
(define make-user (record-constructor rcd-user))
(define lain (make-user 'lain "Lain Iwakura"))
(eqv? (record-rtd lain) rtd-user)  =>  #t

This procedure is an important part of the record inspection functionality and can be used to implement record printers, pattern matchers with record support, and other functionality that requires information about record types.

This procedure is unique to the R6RS record system. An equivalent procedure can be found in SRFI-237.

Implementations often use records to define new types, even types that are not required to use records for their internal representation. There is generally no guarantee that you can use record-rtd on these types and doing so is not portable.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain. In particular, record must be a record. Also raised if the type of record is opaque.

define-record-type(3scm), make-record-type-descriptor(3scm)

R6RS

This procedure first appeared in R6RS as part of the record system.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2023-08-15