((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/callable-data-structures" "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" "callable-data-structures")) (section 2 "callable-data-structures " (toc) (section 3 "Introduction" (p "This egg provides \"callable\" data structures (lists, alists, vectors, hash tables and strings).  \"Callable\" data structures are actually special procedures that internally hold a data structure.") (p "Here's an example:") (highlight scheme "#;1> (use callable-alists)\n#;2> (define alist (make-callable-alist))\n#;3> alist\n#<procedure callable-alist>\n#;4> (alist 'foo)\n#f\n#;5> (alist 'foo 'not-set)\nnot-set\n#;6> (set! (alist 'foo) 42)\n#;7> (alist 'foo)\n42") (p "When called without arguments, \"callable\" data structures return their internal data structure, so you can apply any accessor compatible with them.  Example:") (highlight scheme "#;1> (use callable-hash-tables)\n#;2> (define hash-table (make-callable-hash-table))\n#;3> (hash-table-exists? (hash-table) 'foo)\n#f\n#;4> (set! (hash-table 'foo) 42)\n#;5> (hash-table-exists? (hash-table) 'foo)\n#t\n#;6> (hash-table 'foo)\n42")) (section 3 "Author" (p (link "http://wiki.call-cc.org/users/mario-domenech-goulart" "Mario Domenech Goulart"))) (section 3 "Repository" (p (link "https://github.com/mario-goulart/callable-data-structures" "https://github.com/mario-goulart/callable-data-structures"))) (section 3 "Requirements" (p "None")) (section 3 "API" (p "This extension provides a separate module for each supported data structure.  So, the following modules are available:") (ul (li (tt "callable-alists")) (li (tt "callable-hash-tables")) (li (tt "callable-lists")) (li (tt "callable-strings")) (li (tt "callable-vectors"))) (p "It also provides a " (tt "callable-data-structures") " which exports all symbols from all modules.") (section 4 ("Module " (tt "callable-alists")) (section 5 (tt "make-callable-alist") (def (sig (procedure "(make-callable-alist #!optional (alist '()) #!key (test eqv?))" (id make-callable-alist))) (p "Return a callable alist object.  The initial alist is optional if the " (tt "test") " keyword parameter is not given.") (p "The " (tt "test") " keyword parameter specifies the key comparison procedure (default: " (tt "eqv?") ").") (p "Besides the alist key, the callable alist object accepts the " (tt "default") " keyword parameter, which specifies the default value for when the given key doesn't exist (default: " (tt "#f") ").") (p "Examples:") (highlight scheme "#;1> (use callable-alists)\n#;2> (define symbols (make-callable-alist))\n#;3> symbols\n#<procedure callable-alist>\n#;4> (symbols)\n()\n#;5> (set! (symbols 'foo) 42)\n#;6> (symbols 'foo)\n42\n#;7> (symbols)\n((foo . 42))\n#;8> (define strings (make-callable-alist '() test: equal?))\n#;9> strings\n#<procedure callable-alist>\n#;10> (strings)\n()\n#;11> (set! (strings \"foo\") 42)\n#;12> (strings \"foo\")\n42\n#;13> (strings)\n((\"foo\" . 42))"))) (section 5 (tt "callable-alist?") (def (sig (procedure "(callable-alist? obj)" (id callable-alist?))) (p "Type predicate.  Return " (tt "#t") " if " (tt "obj") " is a callable alist or " (tt "#f") " if it is not.")))) (section 4 ("Module " (tt "callable-hash-tables")) (section 5 (tt "make-callable-hash-table") (def (sig (procedure "(make-callable-hash-table . args)" (id make-callable-hash-table))) (p "Return a callable hash table object.  The initial value is an alist, and it is optional if no other keyword parameter is provided.") (p "All the keyword parameters for " (link "http://wiki.call-cc.org/man/4/Unit%20srfi-69#make-hash-table" ((tt "make-hash-table"))) " are valid for " (tt "make-callable-hash-table") ".") (p "Examples:") (highlight scheme "#;1> (use callable-hash-tables)\n#;2> (define hash-table (make-callable-hash-table))\n#;3> hash-table\n#<procedure callable-hash-table>\n#;4> (hash-table)\n#<hash-table (0)>\n#;5> (set! (hash-table 'foo) 42)\n#;6> (hash-table 'foo)\n42") (highlight scheme "#;1> (use callable-hash-tables)\n#;2> (define hash-table (make-callable-hash-table '((foo . 42) (bar . 0))))\n#;3> (hash-table 'foo)\n42\n#;4> (hash-table 'bar)\n0") (highlight scheme "#;1> (use callable-hash-tables)\n#;2> (define hash-table (make-callable-hash-table '((\"foo\" . 42) (\"bar\" . 0)) test: equal?))\n#;3> (hash-table \"foo\")\n42\n#;4> (hash-table \"bar\")\n0"))) (section 5 (tt "callable-hash-table?") (def (sig (procedure "(callable-hash-table? obj)" (id callable-hash-table?))) (p "Type predicate.  Return " (tt "#t") " if " (tt "obj") " is a callable hash table or " (tt "#f") " if it is not.")))) (section 4 ("Module " (tt "callable-lists")) (section 5 (tt "make-callable-list") (def (sig (procedure "(make-callable-list . items)" (id make-callable-list))) (p "Return a callable list object.  It accepts an arbitrary number if items.") (p "Example:") (highlight scheme "#;1> (use callable-lists)\n#;2> (define l (make-callable-list \"foo\" \"bar\" \"baz\"))\n#;3> l\n#<procedure callable-list>\n#;4> (l)\n(\"foo\" \"bar\" \"baz\")\n#;5> (l 2)\n\"baz\"\n#;6> (set! (l 1) \"quux\")\n#;7> (l)\n(\"foo\" \"quux\" \"baz\")"))) (section 5 (tt "callable-list?") (def (sig (procedure "(callable-list? obj)" (id callable-list?))) (p "Type predicate.  Return " (tt "#t") " if " (tt "obj") " is a callable list or " (tt "#f") " if it is not.")))) (section 4 ("Module " (tt "callable-strings")) (section 5 (tt "make-callable-string") (def (sig (procedure "(make-callable-string . chars)" (id make-callable-string))) (p "Return a callable string object.  It accepts an arbitrary number of characters.") (p "Example:") (highlight scheme "#;1> (use callable-strings)\n#;2> (define s (make-callable-string #\\f #\\o #\\o))\n#;3> s\n#<procedure callable-string>\n#;4> (s)\n\"foo\"\n#;5> (s 1)\n#\\o\n#;6> (set! (s 0) #\\d)\n#;7> (s)\n\"doo\""))) (section 5 (tt "callable-string?") (def (sig (procedure "(callable-string? obj)" (id callable-string?))) (p "Type predicate.  Return " (tt "#t") " if " (tt "obj") " is a callable string or " (tt "#f") " if it is not.")))) (section 4 ("Module " (tt "callable-vectors")) (section 5 (tt "make-callable-vector") (def (sig (procedure "(make-callable-vector . items)" (id make-callable-vector))) (p "Return a callable vector object.  It accepts an arbitrary number of items.") (p "Example:") (highlight scheme "#;1> (use callable-vectors)\n#;2> (define v (make-callable-vector 'foo \"bar\" 42))\n#;3> v\n#<procedure callable-vector>\n#;4> (v)\n#(foo \"bar\" 42)\n#;5> (v 1)\n\"bar\"\n#;6> (set! (v 1) \"quux\")\n#;7> (v)\n#(foo \"quux\" 42)"))) (section 5 (tt "callable-vector?") (def (sig (procedure "(callable-vector? obj)" (id callable-vector?))) (p "Type predicate.  Return " (tt "#t") " if " (tt "obj") " is a callable vector or " (tt "#f") " if it is not."))))) (section 3 "Limitations" (p "Callable data strucutures are special procedures, but still procedures, which means the procedure predicate returns " (tt "#t") " when given a callable data structure object:") (highlight scheme "#;1> (use callable-alists)\n#;2> (define alist (make-callable-alist))\n#;3> (procedure? alist)\n#t\n#;4> (callable-alist? alist)\n#t")) (section 3 "License" (pre " Copyright (c) 2013-2021, Mario Domenech Goulart\n All rights reserved.\n \n 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.\n \n THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS\n OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\n IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")) (section 3 "Version history" (section 4 "Version 1.0.3 (2021-04-17)" (ul (li "Fix component build dependencies for the build system of CHICKEN 5 (irrelevant for CHICKEN 4)"))) (section 4 "Version 1.0.2" (ul (li "CHICKEN 5 support"))) (section 4 "Version 1.0.1" (ul (li "Bug fix: reexport " (tt "callable-alists") " from " (tt "callable-data-structures")))) (section 4 "Version 1.0" (ul (li "Initial release"))))))