diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5bf26a2..6b947b5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -29,6 +29,7 @@ Core Language: - renamed `getc` to `c:get` - renamed `gets` to `s:get` - renamed `words` to `d:words` +- add `d:words-with` Interfaces: diff --git a/doc/Glossary.txt b/doc/Glossary.txt index b6c1ea2..ac487b7 100644 --- a/doc/Glossary.txt +++ b/doc/Glossary.txt @@ -1782,6 +1782,18 @@ Class Handler: class:word | Namespace: global | Interface Layer: all ---------------------------------------------------------------- +d:words-with + + Data: s- + Addr: - + Float: - + +Display a list of all named items in the `Dictionary` that contain the provided substring. + +Class Handler: class:word | Namespace: global | Interface Layer: all + +---------------------------------------------------------------- + d:xt Data: d-a diff --git a/literate/RetroForth.md b/literate/RetroForth.md index 62bd629..5fb7b7a 100644 --- a/literate/RetroForth.md +++ b/literate/RetroForth.md @@ -1479,6 +1479,20 @@ I provide just a few debugging aids. :dump-stack (-) depth 0; drop push dump-stack pop dup n:put sp ; ~~~ +From Kiyoshi Yoneda, this is a variant of `d:words` which displays +words containing a specific substring. It's useful to see words in +a specific namespace, e.g., by doing `'s: d:words-with`, or words +that likely display something: `':puts d:words-with`. + +{{ + :display-if-matched (s-) + dup here s:contains-string? [ s:put sp ] [ drop ] choose ; +---reveal--- + :d:words-with (s-) + here s:copy [ d:name display-if-matched ] d:for-each ; +}} + + ~~~ :FREE (-n) STRINGS #1025 - here - ; ~~~ diff --git a/words.tsv b/words.tsv index 6335027..9517e9b 100644 --- a/words.tsv +++ b/words.tsv @@ -141,6 +141,7 @@ d:lookup s-d - - Lookup the specified name in the dictionary and return a pointe d:lookup-xt a-d - - Lookup the specified address in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found. class:word {n/a} {n/a} d all d:name d-s - - Given a dictionary header, return the name field. class:word {n/a} {n/a} d all d:words - - - Display a list of all named items in the `Dictionary`. class:word {n/a} {n/a} global all +d:words-with s- - - Display a list of all named items in the `Dictionary` that contain the provided substring. class:word {n/a} {n/a} global all d:xt d-a - - Given a dictionary header, return the xt field. class:word {n/a} {n/a} d all data - - - Change the class of the most recently defined word to `class:data`. class:word {n/a} {n/a} global all depth -n - - Return the number of items on the stack. class:word {n/a} {n/a} global all