From d7bb2a1b7b6665667f6b49220b7525caa8482a71 Mon Sep 17 00:00:00 2001 From: Alexey Radul Date: Sun, 29 May 2011 21:48:27 +0100 Subject: [PATCH] Relocate and update the examples of defining hash table contructors. Now in terms of HASH-TABLE/CONSTRUCTOR and entry types. --- doc/ref-manual/associations.texi | 47 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/doc/ref-manual/associations.texi b/doc/ref-manual/associations.texi index fb1ba249e..a2fb0667d 100644 --- a/doc/ref-manual/associations.texi +++ b/doc/ref-manual/associations.texi @@ -589,6 +589,31 @@ collected if there are strong references to its datum or key, respectively. @end defvr +Some examples showing how some standard hash-table constructors could have +been defined: + +@findex eq-hash-mod +@findex eq? +@findex equal-hash-mod +@findex equal? +@findex string-hash-mod +@findex string=? +@example +@group +(define make-weak-eq-hash-table + (hash-table/constructor eq-hash-mod eq? #t + hash-table-entry-type:key-weak)) + +(define make-equal-hash-table + (hash-table/constructor equal-hash-mod equal? #t + hash-table-entry-type:strong)) + +(define make-string-hash-table + (hash-table/constructor string-hash-mod string=? #f + hash-table-entry-type:strong)) +@end group +@end example + The next two procedures are used to create new hash-table constructors. All of the above hash table constructors, with the exception of @code{make-eqv-hash-table}, could have been created by calls to these @@ -619,28 +644,6 @@ hash tables that hold their keys strongly. The constructors returned by weakly. @end deffn -Some examples showing how some standard hash-table constructors could have -been defined: - -@findex eq-hash-mod -@findex eq? -@findex equal-hash-mod -@findex equal? -@findex string-hash-mod -@findex string=? -@example -@group -(define make-weak-eq-hash-table - (weak-hash-table/constructor eq-hash-mod eq? #t)) - -(define make-equal-hash-table - (strong-hash-table/constructor equal-hash-mod equal? #t)) - -(define make-string-hash-table - (strong-hash-table/constructor string-hash-mod string=? #f)) -@end group -@end example - The following procedure is sometimes useful in conjunction with weak hash tables. Normally it is not needed, because such hash tables clean themselves automatically as they are used. -- 2.25.1