record-rtd(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

record-rtd(3scm) β€” get the rtd for the type of a record. Bestie, this is from the Scheme Programmer's Manual, and it's literally about peeking at a record's type descriptor. πŸ’…

🌸 LIBRARY 🌸

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

✨ SYNOPSIS ✨

(record-rtd record)

πŸ’– DESCRIPTION πŸ’–

So this returns the rtd representing the type of record β€” but only if the type is not opaque. πŸ™ˆ

You get the rtd of the most precise type, meaning the type t such that record is of type t but not of any type that extends t. Periodt.

🧚 IMPLEMENTATION NOTES 🧚

Ngl, most R6RS implementations define enumerations in terms of records. πŸ‘‘

πŸ¦‹ RETURN VALUES πŸ¦‹

Returns a single value; an rtd. That's it, that's the whole vibe check. ✨

πŸ“ EXAMPLES πŸ“

(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

🌈 APPLICATION USAGE 🌈

This procedure is an important part of the record inspection functionality, and it can be used to implement record printers, pattern matchers with record support, and other functionality that requires information about record types. It's giving very useful, honestly. 🫢

πŸ’€ COMPATIBILITY πŸ’€

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. So like… don't just assume, bestie. 😭

πŸ”₯ ERRORS πŸ”₯

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. This is also raised if the type of record is opaque. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

⭐ STANDARDS ⭐

R6RS. Iconic behavior. ✨

πŸŽ€ HISTORY πŸŽ€

This procedure first appeared in R6RS as part of the record system. A whole main-character origin story. πŸ’–

🌸 AUTHORS 🌸

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


πŸ’– okay that's the whole page, bestie! Source/version: the Scheme Programmer's Manual, page record-rtd(3scm), dated 2023-08-15. periodt. πŸ’…

πŸ“¦ where this page comes from