((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/define-structure" "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" "lang-exts") (toc) (p "This page is maintained in the package's " (link "https://github.com/abarbu/define-structure" "github repository") ".") (p "= define-structure") (p "This is a Chicken Scheme egg which implements a QobiScheme-compatible " (i "define-structure") " macro. The resulting object is implemented as a chicken record. It automatically sets up reader syntax for reading and writing the object. It also integrates with the nondeterminism egg, see " (i "local-set-{name}-{field}!") ".") (section 4 "Creation" (def (sig (syntax "(define-structure name . fields)" (id define-structure)) (syntax "(define-public-structure name . fields)" (id define-public-structure)) (syntax "(define-private-structure name . fields)" (id define-private-structure))) (p "Creates a new structure. By default all structures are public, generate an export form, making define-structure an alias for define-public-structure."))) (section 4 "Use" (p "The following functions are generated when creating a structure.") (def (sig (procedure "(make-{name} {field0-value} {field1-value} ...)" (id make-)) (procedure "(make-keywords-{name} {field-name}: {field-value} ...)" (id make-keywords-))) (p "Any fields not defined in " (i "make-keywords-{name}") " will be uninitialized.")) (def (sig (procedure "({name}? obj)" (id name))) (p "Tests if " (i "obj") " is of a " (i "{name}") " record.")) (def (sig (procedure "({name}-{field} obj)" (id name))) (p "Accesses the field.")) (def (sig (procedure "({name}-{field}-set! obj val)" (id name)) (procedure "(set-{name}-{field}! obj val)" (id set-))) (p "The former is created by chicken's " (i "define-record") ", the latter is added for compatbility with QobiScheme.")) (def (sig (procedure "({name}-{field}-setp! obj proc)" (id name)) (procedure "(setp-{name}-{field}! obj proc)" (id setp-))) (p "Like " (i "set-") " but calls " (i "proc") " witht he current value and updates it to what " (i "proc") " returns.")) (def (sig (procedure "(local-set-{name}-{field}! obj val)" (id local-set-)) (procedure "(local-setp-{name}-{field}! obj proc)" (id local-setp-))) (p "This set! will be undone when backtracking with the nondeterminism egg.")) (def (sig (procedure "({name}-{field}-update obj val)" (id name)) (procedure "(update-{name}-{field} obj val)" (id update-)) (procedure "({name}-{field}-updatep obj proc)" (id name)) (procedure "(updatep-{name}-{field} obj proc)" (id updatep-))) (p "like the " (i "set") " and " (i "setp") " versions but these return a new copy of the object.")) (def (sig (procedure "(set-{name}! obj {field-key}: {field-value} ...)" (id set-)) (procedure "(setp-{name}! obj {field-key}: {field-value} ...)" (id setp-)) (procedure "(update-{name} obj {field-key}: {field-value} ...)" (id update-)) (procedure "(updatep-{name} obj {field-key}: {field-value} ...)" (id updatep-))) (p "As above but with keywords.")) (def (sig (procedure "(alist->{name} alist)" (id alist->)) (procedure "({name}->alist obj)" (id name))) (p "Convert to and back from an alist.")) (def (sig (procedure "(old-vector->{name} vector)" (id old-vector->))) (p "Reads in a vector of the form " (i "#({case-insensitive-name} {field0} ...)") ". This is only provided for compatibility with " (i "Scheme->C") ". Not yet implemented."))) (section 3 "License" (pre "  Copyright (c) 2013, Andrei Barbu, Purdue University\n  All rights reserved.") (pre "  Contact Andrei Barbu at andrei@0xab.com.") (pre "  This program is free software: you can redistribute it and/or modify\n  it under the terms of the GNU Lesser General Public License as published by\n  the Free Software Foundation, either version 3 of the License, or\n  (at your option) any later version.\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU Lesser General Public License for more details.\n  You should have received a copy of the GNU Lesser General Public License\n  along with this program.  If not, see http://www.gnu.org/licenses."))))