summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-24 08:41:58 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-24 08:41:58 -0700
commitf2f951350516e4b959ef28f220e31b91b466fa16 (patch)
treeee4958ffcac59dcfb909ca5e217d5a74a42b1569 /txr.1
parent7b587fe3450c949f454778bfaf71870a5a872f6b (diff)
downloadtxr-f2f951350516e4b959ef28f220e31b91b466fa16.tar.gz
txr-f2f951350516e4b959ef28f220e31b91b466fa16.tar.bz2
txr-f2f951350516e4b959ef28f220e31b91b466fa16.zip
matcher: allow hash pattern to omit values.
The @(hash ...) operator now allows key-only patterns like (42) or (@x), where x could be bound or unbound. This has separate semantics from when a value is present. * share/txr/stdlib/match.tl (compile-hash-match): Implement. * tests/011/patmatch.tl: Test. * txr.1: Document.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.124
1 files changed, 23 insertions, 1 deletions
diff --git a/txr.1 b/txr.1
index f0ff1866..85374e50 100644
--- a/txr.1
+++ b/txr.1
@@ -41159,7 +41159,7 @@ object's structure type: the type itself, rather than its symbolic name.
.coNP Pattern operator @ hash
.synb
-.mets @(hash >> {( key-pattern << value-pattern )}*)
+.mets @(hash >> {( key-pattern <> [ value-pattern ])}*)
.syne
.desc
The
@@ -41188,6 +41188,9 @@ pair against that object as described below. Each of
the pairs must successfully match, otherwise the overall
match fails.
+The following requirements apply to key-value pattern pairs in which
+the value pattern is specified.
+
If
.meta key-pattern
is a trivial pattern, then the semantics of the match is that
@@ -41267,6 +41270,25 @@ such that the semantics can then be understood in terms of the
.code coll
operator matching against an association list.
+The following requirements apply when the
+.meta value-pattern
+is omitted.
+
+If
+.meta key-pattern
+is a nontrivial pattern other than a variable pattern
+for a variable which has an existing binding, then the pattern
+is applied against the list of keys from the hash table, which
+are retrieved as if using the
+.code hash-keys
+function.
+
+If
+.meta key-pattern
+is a variable pattern referring to an existing binding, then that pattern is
+taken as a literal object. The match is successful if that object occurs as a
+key in the hash table.
+
.TP* Example:
.verb