record-predicate(3scm)
π record-predicate(3scm) π
okay bestie, welcome to the Scheme Programmer's Manual page for record-predicate β this one is lowkey tiny but highkey useful, and it's giving "record type vibe check." π
πΈ NAME πΈ
record-predicate β create record predicates. No cap, that's the whole name section. π«Ά
π LIBRARY π
okay so you import one of these depending on your setup, and yes, both are R6RS:
(import (rnrs)) ;R6RS
(import (rnrs records procedural)) ;R6RS
β¨ SYNOPSIS β¨
(record-predicate rtd)
π DESCRIPTION π
So record-predicate returns a procedure. Give that procedure an object obj, and it returns #t if obj is a record of the type represented by rtd, and #f otherwise. That's it β a little yes/no machine for records, and honestly? iconic. π₯
π¦ RETURN VALUES π¦
Returns a single value; a procedure. That's the whole return value, bestie β one procedure, no extra baggage. π
π EXAMPLES π
here's the exact example, bestie β copy it, run it, live your truth:
(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 user? (record-predicate rtd-user))
(define lain (make-user 'lain "Lain Iwakura"))
(user? lain) => #t
π§ APPLICATION USAGE π§
These procedures are used together with the procedural record layer. That's the application usage, and it's giving "we ride together, we record together." π«Ά
π COMPATIBILITY π
This procedure is unique to the R6RS record system. An equivalent procedure can be found in SRFI-237. So if you're in R6RS land, you're chilling; if not, SRFI-237 has your back. β¨
β 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,rtdmust be a record-type descriptor. So yeah, don't hand it random nonsense and expect peace, okay? π
π SEE ALSO π
go read these too, bestie:
π STANDARDS π
R6RS. periodt. π
π HISTORY π
First appeared in R6RS as part of the new record system. A little origin story, a little lore. π¦
πΈ 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/.
π That's a wrap, bestie β source/version: Scheme Programmer's Manual, date: 2023-08-05, page: record-predicate(3scm). Mwah! π«Ά
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2023 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms