(html (head (title "sph-lib (sph record)") (link (@ (rel "stylesheet") (type "text/css") (href "/css/sph.css"))) (meta (@ (name "viewport") (content "width=device-width,initial-scale=1"))) #f) (body () (div (@ (class top)) (nav (a (@ (href "/")) "start") ", " (a (@ (href "/feed.xml")) "feed")) "") (div (@ (class "middle")) (div (@ (class mtime) (title "last modification time of the current page")) "2019-01-06") (section (h1 "(sph record)") (div (p "*deprecated* vectors as records.") (p "part of " (a (@ (href "../../sph-lib.html")) "sph-lib")) ((section (@ (class "library-description")) (h1 "library description") (div (p "see vector-accessor from (sph vector) instead and create records like #(symbol:type-name value ...).") (p "access vector elements with field names.") (p "this library is supposed to be simpler in definition and usage than previously existing record libraries (rnrs, srfi) and") (p "more powerful by being based on vectors (records) and hashtables (layouts) and their less restricted interoperability.") (p "any vector can be accessed as a record and records can be accessed as vectors.") (p "if type information is desired then for example a symbol type name can be used as the first element of the vector.") (p "vector records have the typical literal vector representation for read/write.") (p "usage:") (p "(define-record my-record a b c)") (p "(define-record my-other-record (a accessor-name setter-name) b (c my-other-c))") (p "(define x (record my-record 1 2))") (p "(my-record-a x) -> 1") (p "(my-record-c x) -> #f") (p "(my-record-c-set! x 3)") (p "syntax") (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "record-update-b :: record-layout a field-names ...")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp") (*ENTITY* "nbsp") (*ENTITY* "nbsp")) "create a new vector with field name and value taken from given identifier and variable value.")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp") (*ENTITY* "nbsp") (*ENTITY* "nbsp")) "example: (record-update layout instance name name-2)")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp") (*ENTITY* "nbsp") (*ENTITY* "nbsp")) "same as (record-update layout instance (q name) name (q name-2) name ...)")))) (section (@ (class "library-name")) (h1 "import name") (p "(sph record)")) (section (@ (class "library-exports")) (h1 "exports") (div (ul (@ (class "doc-index")) (li (a (@ (href "#doc-b-" "alist->record") (class (procedure))) "alist->record")) (li (a (@ (href "#doc-b-" "define-record") (class (syntax))) "define-record")) (li (a (@ (href "#doc-b-" "define-record-accessors") (class (syntax))) "define-record-accessors")) (li (a (@ (href "#doc-b-" "define-record-setters") (class (syntax))) "define-record-setters")) (li (a (@ (href "#doc-b-" "make-record") (class (procedure))) "make-record")) (li (a (@ (href "#doc-b-" "make-record-layout") (class (procedure))) "make-record-layout")) (li (a (@ (href "#doc-b-" "record") (class (procedure))) "record")) (li (a (@ (href "#doc-b-" "record-accessor") (class (procedure))) "record-accessor")) (li (a (@ (href "#doc-b-" "record-accessors") (class (procedure))) "record-accessors")) (li (a (@ (href "#doc-b-" "record-append") (class (procedure))) "record-append")) (li (a (@ (href "#doc-b-" "record-field-names") (class (procedure))) "record-field-names")) (li (a (@ (href "#doc-b-" "record-field-names-unordered") (class (procedure))) "record-field-names-unordered")) (li (a (@ (href "#doc-b-" "record-layout->predicate") (class (procedure))) "record-layout->predicate")) (li (a (@ (href "#doc-b-" "record-layout-extend!") (class (procedure))) "record-layout-extend!")) (li (a (@ (href "#doc-b-" "record-layout-length") (class (procedure))) "record-layout-length")) (li (a (@ (href "#doc-b-" "record-layout-merge!") (class (procedure))) "record-layout-merge!")) (li (a (@ (href "#doc-b-" "record-layout?") (class (procedure))) "record-layout?")) (li (a (@ (href "#doc-b-" "record-length") (class (procedure))) "record-length")) (li (a (@ (href "#doc-b-" "record-list-filter-value") (class (procedure))) "record-list-filter-value")) (li (a (@ (href "#doc-b-" "record-ref") (class (procedure))) "record-ref")) (li (a (@ (href "#doc-b-" "record-setter") (class (procedure))) "record-setter")) (li (a (@ (href "#doc-b-" "record-setters") (class (procedure))) "record-setters")) (li (a (@ (href "#doc-b-" "record-take") (class (procedure))) "record-take")) (li (a (@ (href "#doc-b-" "record-update") (class (procedure))) "record-update")) (li (a (@ (href "#doc-b-" "record-update-b") (class (syntax))) "record-update-b")) (li (a (@ (href "#doc-b-" "record-update-q") (class (syntax))) "record-update-q")) (li (a (@ (href "#doc-b-" "record?") (class (procedure))) "record?")) (li (a (@ (href "#doc-b-" "vector->record") (class (procedure))) "vector->record"))) (div (@ (class "doc-bindings")) (div (@ (id "doc-b-" "alist->record") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "alist->record") " " (span (@ (class "first-sig")) "a record-layout ->")) (div (@ (class "rest-sig")) (div "alist record-layout -> record")) (div (@ (class "description")) ("extract record data from alist using record-layout and result in one record.\ncurrently, string keys are also recognized"))) (div (@ (id "doc-b-" "define-record") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "define-record")) "" "") (div (@ (id "doc-b-" "define-record-accessors") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "define-record-accessors") " " (span (@ (class "first-sig")) "record-layout (identifier field-name) ...")) "" "") (div (@ (id "doc-b-" "define-record-setters") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "define-record-setters") " " (span (@ (class "first-sig")) "record-layout (identifier field-name) ...")) "" "") (div (@ (id "doc-b-" "make-record") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "make-record") " " (span (@ (class "first-sig")) "record-layout ->")) (div (@ (class "rest-sig")) (div "record-layout -> record")) "") (div (@ (id "doc-b-" "make-record-layout") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "make-record-layout") " " (span (@ (class "first-sig")) "field-spec ->")) (div (@ (class "rest-sig")) (div "(symbol ...) -> record-layout")) (div (@ (class "description")) ("results in a new record-layout with the given field names"))) (div (@ (id "doc-b-" "record") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record") " " (span (@ (class "first-sig")) "record-layout values ... ->")) (div (@ (class "rest-sig")) (div "record-layout (any ...) -> record")) (div (@ (class "description")) ("create a new record by specifying the layout and the values in\nthe same order as they are specified in layout field-spec. not all values have to be given, unspecified fields are set to "))) (div (@ (id "doc-b-" "record-accessor") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-accessor") " " (span (@ (class "first-sig")) "record-layout field-name ->")) (div (@ (class "rest-sig")) (div "record-layout symbol -> procedure {record -> field-value}")) (div (@ (class "description")) ("returns an accessor procedure for the given record-layout and field-name."))) (div (@ (id "doc-b-" "record-accessors") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-accessors") " " (span (@ (class "first-sig")) "record-layout ->")) (div (@ (class "rest-sig")) (div "hashtable:record-layout -> (proc ...)")) (div (@ (class "description")) ("returns all accessors for the given record-layout in a list"))) (div (@ (id "doc-b-" "record-append") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-append") " " (span (@ (class "first-sig")) " ->")) (div (@ (class "rest-sig")) (div "(vector-append vec ...) -> vector")) (div (@ (class "description")) ("Return a newly allocated vector that contains all elements in order\nfrom the subsequent locations in VEC ..."))) (div (@ (id "doc-b-" "record-field-names") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-field-names") " " (span (@ (class "first-sig")) "record-layout ->")) (div (@ (class "rest-sig")) (div "hashtable:record-layout -> vector:#(symbol ...)")) (div (@ (class "description")) ("result in the field-names of record in the same order as they were specified."))) (div (@ (id "doc-b-" "record-field-names-unordered") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-field-names-unordered") " " (span (@ (class "first-sig")) "hashtable ->")) "" "") (div (@ (id "doc-b-" "record-layout->predicate") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-layout->predicate") " " (span (@ (class "first-sig")) "a [type-prefix] ->")) (div (@ (class "rest-sig")) (div "record-layout [symbol:type-name] -> procedure:{vector -> boolean}")) (div (@ (class "description")) ("if type-prefix is given, the first field of the record is required to contain the type-prefix"))) (div (@ (id "doc-b-" "record-layout-extend!") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-layout-extend!") " " (span (@ (class "first-sig")) "layout-1 layout-2 ->")) "" "") (div (@ (id "doc-b-" "record-layout-length") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-layout-length") " " (span (@ (class "first-sig")) "hashtable ->")) "" "") (div (@ (id "doc-b-" "record-layout-merge!") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-layout-merge!") " " (span (@ (class "first-sig")) "a b ... ->")) (div (@ (class "rest-sig")) (div "hashtable hashtable ... -> unspecified")) (div (@ (class "description")) ("copy the values of hash b to hash a. existing key values are overwritten"))) (div (@ (id "doc-b-" "record-layout?") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-layout?") " " (span (@ (class "first-sig")) "obj ->")) "" "") (div (@ (id "doc-b-" "record-length") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-length") " " (span (@ (class "first-sig")) "a ->")) "" "") (div (@ (id "doc-b-" "record-list-filter-value") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-list-filter-value") " " (span (@ (class "first-sig")) "record-list value match-accessor retrieve-accessor ->")) (div (@ (class "rest-sig")) (div "list procedure:accessor procedure:accessor -> false/(any ...)")) (div (@ (class "description")) ("filter record list entries by values retrieved by match-accessor that match the given value,\nand return a list of values retrieved by retrieve-accessor"))) (div (@ (id "doc-b-" "record-ref") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-ref") " " (span (@ (class "first-sig")) "record record-layout field-name ->")) (div (@ (class "rest-sig")) (div "record record-layout symbol -> any")) (div (@ (class "description")) ("get the value for field-name of the given record.\nrecord-ref is considerably slower than using an accessor procedure"))) (div (@ (id "doc-b-" "record-setter") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-setter") " " (span (@ (class "first-sig")) "record-layout field-name ->")) (div (@ (class "rest-sig")) (div "record-layout symbol -> procedure {record value -> unspecified}")) (div (@ (class "description")) ("returns a setter procedure for the given layout and field-name"))) (div (@ (id "doc-b-" "record-setters") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-setters") " " (span (@ (class "first-sig")) "record-layout ->")) (div (@ (class "rest-sig")) (div "record-layout (symbol ...) -> proc ...")) (div (@ (class "description")) ("returns all setters for the given layout in a list"))) (div (@ (id "doc-b-" "record-take") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-take") " " (span (@ (class "first-sig")) "record-layout a ->")) "" (div (@ (class "description")) ("this adjusts the length of the given vector to match the length of the layout.\nextra fields in are left out if the layout is smaller"))) (div (@ (id "doc-b-" "record-update") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record-update") " " (span (@ (class "first-sig")) "record-layout a field-name/value ... ->")) (div (@ (class "rest-sig")) (div "vector [integer any] ... -> vector")) (div (@ (class "description")) ("create a copy of the given record with values in fields set to new values.\nfield name and value are given alternatingly.\nexample: (record-update myrecord (quote a) #\\c (quote b) #\\d)"))) (div (@ (id "doc-b-" "record-update-b") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "record-update-b") " " (span (@ (class "first-sig")) "record-layout a field-name ...")) "" "") (div (@ (id "doc-b-" "record-update-q") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "record-update-q") " " (span (@ (class "first-sig")) "record-layout a field-name/value ...")) "" "") (div (@ (id "doc-b-" "record?") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "record?") " " (span (@ (class "first-sig")) "a ->")) "" "") (div (@ (id "doc-b-" "vector->record") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "vector->record") " " (span (@ (class "first-sig")) "record-layout a ->")) "" (div (@ (class "description")) ("this adjusts the length of the given vector to match the length of the layout.\nextra fields in are left out if the layout is smaller")))))))))) ()))