From d499b2062a0f88be35a3ebb2e75c99c695f9f383 Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Wed, 12 Oct 2016 19:58:58 -0700
Subject: Include user data in hash read syntax.

* hash.c (userdata_k): New keyword symbol variable.
(hash_print_op): Print the userdata together with
the hash flags as :userdata obj.
(hashv): Parse out :userdata obj syntax from
the argument list. This takes care of supporting
it in the read notation and in the hash function.
(hash_init): Initialize userdata_k.

* txr.1: Documenting :userdata in hash
read notation and hash function.
---
 txr.1 | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

(limited to 'txr.1')

diff --git a/txr.1 b/txr.1
index 095fa482..c6842dd4 100644
--- a/txr.1
+++ b/txr.1
@@ -10414,9 +10414,19 @@ The first item in the syntax is a list of keywords. These are the same
 keywords as are used when calling the function hash to construct
 a hash table. Allowed keywords are:
 .codn :equal-based ,
-.code :weak-keys
+.codn :weak-keys ,
+.codn :weak-values ,
 and
-.codn :weak-values .
+.codn :userdata .
+If the
+.code :userdata
+keyword is present,
+it must be followed by an object; that object
+specifies the hash table's user data, which
+can be retrieved using the
+.code get-hash-userdata
+function.
+
 An empty list can be specified as
 .code nil
 or
@@ -33159,7 +33169,8 @@ and
 .coNP Functions @ make-hash and @ hash
 .synb
 .mets (make-hash < weak-keys < weak-vals << equal-based )
-.mets (hash { :weak-keys | :weak-vals | :equal-based }*)
+.mets (hash {:weak-keys | :weak-vals | :equal-based |
+.mets \ \ \ \ \ \  :userdata << obj }*)
 .syne
 .desc
 These functions construct a new hash table.
@@ -33190,15 +33201,22 @@ It is an error to attempt to construct an
 hash table which has weak keys.
 
 The hash function provides an alternative interface. It accepts optional
-arguments which are keyword symbols. Any combination of the three symbols
+arguments which are keyword symbols. Any combination of the four symbols
 .codn :weak-keys ,
-.code :weak-vals
-and
+.codn :weak-vals ,
 .code :equal-based
+and
+.code :userdata
 can be specified in any order
 to turn on the corresponding properties in the newly constructed hash table.
 If any of the keywords is not specified, the corresponding property defaults to
 .codn nil .
+If
+.code :userdata
+is present, it must be followed by an argument value; that value
+specifies the user data for the hash table, which can be retrieved using the
+.code get-hash-userdata
+function.
 
 If a hash table has weak keys, this means that from the point of view
 of garbage collection, that table holds only weak references to the keys
-- 
cgit v1.2.3