Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
SRFI-99
TOC »
Author
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.
- (make-rtd NAME FIELDS [[#:parent] PARENT #f] [#:uid UID (gensym NAME)] [#:sealed SEALED? #f] [#:opaque OPAQUE? #f] [#:property RTP VALUE] ...)procedure
Create a new record type descriptor.
- rtd? Vprocedure
Test whether V is a record type descriptor.
- rtd-constructor RTD #!optional FIELDSprocedure
Obtain a constructor procedure for records of the type described by RTD, optionally restricting the FIELDS to be initialized.
- rtd-predicate RTDprocedure
Obtain a predicate procedure for records of the type described by RTD.
- rtd-accessor RTD NAMEprocedure
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.
- rtd-mutator RTD NAMEprocedure
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.
- record? Vprocedure
Test whether V is some kind of record.
- record-rtd Vprocedure
Obtain the record type descriptor corresponding to V's type or return #f if V is not an instance of a transparent record type.
- rtd-name RTDprocedure
Determine the descriptive name of a record type.
- rtd-uid RTDprocedure
Determine the unique identifier used to tag instances of a record type.
- rtd-sealed? RTDprocedure
Test whether a record type is sealed and cannot have subtypes.
- rtd-opaque? RTDprocedure
Test whether a record type is opaque and cannot be extracted from instances using record-rtd.
- rtd-parent RTDprocedure
Determine the parent type descriptor of RTD.
- rtd-field-names RTDprocedure
Compute a vector of fields defined directly by RTD.
- rtd-all-field-names RTDprocedure
Compute a vector of fields defined by RTD or its supertypes.
- rtd-field-mutable? RTD NAMEprocedure
Test whether the field called NAME in records of type RTD is mutable.
- (make-rtp [DEFAULT #f])procedure
Create a new record property accessor.
- rtd-properties RTDprocedure
Compute a list of record properties attached directly to RTD.
- rtd-all-properties RTDprocedure
Compute a list of all record properties attached to RTD or its supertypes.
srfi-99-records-syntactic
Syntactic sugar to facilitate the definition of record types.
- (define-record-type (RTD OPTION ...) CONSTRUCTOR PREDICATE FIELD ...)syntax
- (define-record-type RTD CONSTRUCTOR PREDICATE FIELD ...)syntax
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.
- (define-record-constructor RTD (NAME FIELD ...))syntax
- (define-record-constructor RTD NAME)syntax
- (define-record-constructor RTD #t)syntax
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.
- (define-record-predicate RTD NAME)syntax
- (define-record-predicate RTD #t)syntax
Defines NAME as a predicate procedure for instances of RTD.
If the only argument is #t, the name is formed by appending ? to RTD.
- (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)syntax
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!.
- (define-record-property RTP [DEFAULT])syntax
Defines a new record property accessor RTP, optionally passing a DEFAULT to make-rtp.
- (define-record-printer (RTD . ARGS) . BODY)syntax
- (define-record-printer RTD EXPR)syntax
Defines a record printer for direct instances of RTD.
In contrast to the built-in form of this macro provided by the CHICKEN standard library, RTD is interpreted as an identifier bound to a record type descriptor, not as the unique identifier used to tag instances of the record type.
srfi-99-variants
Syntactic sugar to facilitate the definition of variant types.
- (define-variant-type (RTD OPTION ...) PREDICATE (VARIANT FIELD ...) ...)syntax
- (define-variant-type RTD PREDICATE (VARIANT FIELD ...) ...)syntax
Defines a new record type RTD, optionally passing a set of OPTIONs to make-rtd. The record has no fields.
If PREDICATE is not #f a predicate procedure for the new record type is defined using define-record-predicate.
Variant subtypes of RTD are defined using define-variant-constructor for each VARIANT clause.
- (define-variant-constructor RTD (VARIANT FIELD ...))syntax
Defines a constructor for a new variant subtype of RTD. The subtype has the given immutable FIELDs and the constructor initializes all fields of the record.
The variant subtype is sealed and it is opaque iff RTD is opaque. The UID of the subtype is formed by appending the UID of RTD, - and VARIANT.
The record type descriptor of the variant subtype is attached to the constructor VARIANT as extended procedure data.
- (variant-case RTD V ((VARIANT FIELD ...) . BODY) [(else . BODY)])syntax
The form first ensures that V is indeed an instance of RTD, raising a type error otherwise.
Each VARIANT designates a variant subtype constructor, each FIELD is an identifier to be bound to the corresponding, identically named field of the variant instance. If any of the variant clauses matches the type of V, the corresponding BODY is evaluated and the result is returned from the variant-case form.
If none of the variant clauses match the type of V, the else clause's BODY is evaluated instead. If no else clause is present either, an error is raised indicating that no matching variant was found.
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.