((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/typed-records" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg") (toc)) (section 2 "typed-records" (section 3 "Introduction" (p "Alternative record-definition forms that allow specifying slot types, giving more opportunities for type-analysis and type-based optimization. Specifying slot types also is useful for documentation.") (p "The record-definition forms " (tt "define-record") " and " (tt "define-record-type") " from the core system, and " (tt "defstruct") " from the egg of the same name are shadowed and provide the extended type-specification syntax.")) (section 3 "Requirements" (p (int-link "defstruct")) (p "This extension requires CHICKEN 4.7.5 or later.")) (section 3 "Usage" (highlight scheme "(require-extension typed-records)")) (section 3 "Documentation" (section 4 "define-record" (def (sig (syntax "(define-record NAME SLOT ...)" (id define-record))) (p "Equivalent to " (tt "define-record") " where " (tt "SLOT") " slot may optionally be of the form") (pre " (SLOTNAME : TYPE)") (p "or") (pre " ((setter SLOTNAME) : TYPE)") (p (tt "define-record") " adds the following type-declarations:") (highlight scheme "(: make-NAME (TYPE1 ... -> (struct NAME)))\n(: NAME? (* -> boolean : (struct NAME)))\n(: NAME-SLOTNAME ((struct NAME) -> TYPE))\n(: NAME-SLOTNAME-set! ((struct NAME) TYPE -> undefined))") (p "Additionally, specializations are enabled that rewrite slot-accessors to very efficient code, if the compiler can prove that the arguments are of the correct type."))) (section 4 "define-record-type" (def (sig (syntax "(define-record-type NAME (CTOR FIELDNAME ...) PRED FIELD ...)" (id define-record-type))) (p "Defines a SRFI-9 record type. FIELD may be any of") (pre " (FIELDNAME GETTER)\n (FIELDNAME GETTER : TYPE)\n (FIELDNAME GETTER SETTER)\n (FIELDNAME GETTER SETTER : TYPE)") (p "Declares:") (highlight scheme "(: CTOR (TYPE1 ... -> (struct NAME)))\n(: PRED (* -> boolean : (struct NAME)))\n(: GETTER ((struct NAME) -> TYPE))\n(: SETTER ((struct NAME) TYPE -> undefined))") (p "Specializations are added here as well."))) (section 4 "defstruct" (def (sig (syntax "(defstruct NAME SLOT ...)" (id defstruct))) (p "Alternative form of " (tt "defstruct") ". " (tt "SLOT") " may be any of") (pre " SLOTNAME \n (SLOTNAME DEFAULT)\n (SLOTNAME : TYPE)\n ((SLOTNAME DEFAULT) : TYPE)") (p "Declares:") (highlight scheme "(: make-NAME (#!rest * -> (struct NAME)))\n(: NAME? (* -> boolean : (struct NAME)))\n(: NAME-SLOTNAME ((struct NAME) -> TYPE))\n(: NAME-SLOTNAME-set! ((struct NAME) TYPE -> undefined))\n(: set-NAME! ((struct name) #!rest * -> (struct name)))\n(: update-NAME ((struct name) #!rest * -> (struct name)))") (p "Adds specializations as appropriate.")))) (section 3 "Author" (p (int-link "/user/felix-winkelmann" "Felix Winkelmann"))) (section 3 "License" (pre " Copyright (c) 2011, Felix L. Winkelmann\n All rights reserved.") (pre " Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n    notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n    notice, this list of conditions and the following disclaimer in the\n    documentation and/or other materials provided with the distribution.\n 3. The name of the authors may not be used to endorse or promote products\n    derived from this software without specific prior written permission.") (pre " THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")) (section 3 "Version History" (dl (dt "0.1") (dd "initial release") (dt "0.2") (dd "shadow original definition forms") (dt "0.5") (dd "various bugfixes")))))