diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-05-24 08:41:58 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-05-24 08:41:58 -0700 |
commit | f2f951350516e4b959ef28f220e31b91b466fa16 (patch) | |
tree | ee4958ffcac59dcfb909ca5e217d5a74a42b1569 /txr.1 | |
parent | 7b587fe3450c949f454778bfaf71870a5a872f6b (diff) | |
download | txr-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.1 | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -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 |