You are looking at historical revision 25169 of this page. It may differ significantly from its current revision.

SRFI-99

Author

Thomas Chust

Requirements

None

Provided Modules

The extension consists of a single library, srfi-99, that provides a number of public modules.

srfi-99

A convenience module that re-exports the bindings from all the other modules so that

 (require-extension srfi-99)

works as expected.

srfi-99-records

A convenience module that re-exports the bindings from all the other srfi-99-records-... modules.

srfi-99-records-procedural

The procedural interface to record type descriptors.

[procedure] (make-rtd NAME FIELDS [[#:parent] PARENT #f] [#:uid UID (gensym NAME)] [#:sealed SEALED? #f] [#:opaque OPAQUE? #f] [#:property RTP VALUE] ...)

Create a new record type descriptor.

[procedure] (rtd? V)

Test whether V is a record type descriptor.

[procedure] (rtd-constructor RTD [FIELDS])

Obtain a constructor procedure for records of the type described by RTD, optionally restricting the FIELDS to be initialized.

[procedure] (rtd-predicate RTD)

Obtain a predicate procedure for records of the type described by RTD.

[procedure] (rtd-accessor RTD NAME)

Obtain an accessor procedure for the field called NAME in records of the type described by RTD. If the field is mutable, the accessor procedure has an attached SRFI-17 setter.

[procedure] (rtd-mutator RTD NAME)

Obtain a mutator procedure for the mutable field called NAME in records of the type described by RTD.

srfi-99-records-inspection

Access to reflective information about records.

[procedure] (record? V)

Test whether V is some kind of record.

[procedure] (record-rtd V)

Obtain the record type descriptor corresponding to V's type or return #f if V is not an instance of a transparent record type.

[procedure] (rtd-name RTD)

Determine the descriptive name of a record type.

[procedure] (rtd-uid RTD)

Determine the unique identifier used to tag instances of a record type.

[procedure] (rtd-sealed? RTD)

Test whether a record type is sealed and cannot have subtypes.

[procedure] (rtd-opaque? RTD)

Test whether a record type is opaque and cannot be extracted from instances using record-rtd.

[procedure] (rtd-parent RTD)

Determine the parent type descriptor of RTD.

[procedure] (rtd-field-names RTD)

Compute a vector of fields defined directly by RTD.

[procedure] (rtd-all-field-names RTD)

Compute a vector of fields defined by RTD or its supertypes.

[procedure] (rtd-field-mutable? RTD NAME)

Test whether the field called NAME in records of type RTD is mutable.

[procedure] (make-rtp [DEFAULT #f])

Create a new record property accessor.

srfi-99-records-syntactic

Syntactic sugar to facilitate the definition of record types.

[syntax] (define-record-type (RTD OPTION ...) CONSTRUCTOR PREDICATE FIELD ...)
[syntax] (define-record-type RTD CONSTRUCTOR PREDICATE FIELD ...)

Defines a new record type RTD, optionally passing a set of OPTIONs to make-rtd. The record has fields described by the given FIELD specifications.

If CONSTRUCTOR is not #f, a constructor procedure for the new record type is defined using define-record-constructor, if PREDICATE is not #f a predicate procedure for the new record type is defined using define-record-predicate.

Accessors and mutators for the record type's fields are defined using define-record-field.

[syntax] (define-record-constructor RTD (NAME FIELD ...))
[syntax] (define-record-constructor RTD NAME)
[syntax] (define-record-constructor RTD #t)

Defines NAME as a constructor procedure for instances of RTD, optionally restricting the set of initialized FIELDs.

If the only argument is #t, the name is formed by prepending make- to RTD.

[syntax] (define-record-predicate RTD NAME)
[syntax] (define-record-predicate RTD #t)

Defines NAME as a predicate procedure for instances of RTD.

If the only argument is #t, the name is formed by appending ? to RTD.

[syntax] (define-record-field RTD (NAME ACCESSOR MUTATOR))
[syntax] (define-record-field RTD (NAME))
[syntax] (define-record-field RTD (NAME ACCESSOR))
[syntax] (define-record-field RTD NAME)

Defines accessor and possibly mutator procedures for the field NAME in instances of RTD.

If the accessor name is not specified (in the second or fourth form), it is formed by appending RTD, - and NAME. If the mutator name is not specified (in the second form), it is formed by appending RTD, -, NAME and -set!.

[syntax] (define-record-property RTP [DEFAULT])

Defines a new record property accessor RTP, optionally passing a DEFAULT to make-rtp.

srfi-99-variants

Syntactic sugar to facilitate the definition of variant types.

Official Documentation

The SRFI-99 standard document describes the basic functionality. The repository site documents extensions provided by this implementation.

License

 Copyright (C) 2011 Thomas Chust <chust@web.de>.  All rights reserved.
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation files
 (the Software), to deal in the Software without restriction,
 including without limitation the rights to use, copy, modify, merge,
 publish, distribute, sublicense, and/or sell copies of the Software,
 and to permit persons to whom the Software is furnished to do so,
 subject to the following conditions:
 
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.