From f26f5d54d91a6fe3f87f5ffb1ec87cd7fbb816b7 Mon Sep 17 00:00:00 2001 From: crc Date: Thu, 31 Jan 2019 21:37:28 +0000 Subject: [PATCH] new example: naming quotes FossilOrigin-Name: b7cb708ed7e5c798fddf0c30e9ac2eaf7f2951a958b17599e62e81c20987d9d5 --- RELEASE_NOTES.md | 7 +++++++ example/Naming_Quotes.forth | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 example/Naming_Quotes.forth diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6db17a7..bdcb93b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,9 @@ # RETRO 12.2019.6 +This is the changelog for the development builds of Retro. +I am currently planning to have the next release occur in +June 2019. + ## Bug Fixes ## Build @@ -70,11 +74,13 @@ - retro-extend: allow multiple files - retro-extend: reduce memory usage - retro-extend: fix potential buffer overrun +- muri: remove the unused `c` directive ## Other ## Documentation +- add a collection of papers - refactor glossary tool - add HTML version of the Glossary - add more concise text copies of the Glossary @@ -88,6 +94,7 @@ - add HTML.forth - add KeyValueStore.forth - add Marker.forth +- add Naming_Quotes.forth - add net_fetch.forth - add paste.forth - add Paste_to_Sprunge.forth diff --git a/example/Naming_Quotes.forth b/example/Naming_Quotes.forth new file mode 100644 index 0000000..e0e793a --- /dev/null +++ b/example/Naming_Quotes.forth @@ -0,0 +1,38 @@ +# Naming Quotes + +Anonymous functions called quotes are used heavily by Retro. +This shows a way to attach names to them. + +In a classic Forth, words are created using `:`, which is +one of numerous parsing words. So a named function looks +like: + + : foo ... ; + +In Retro, there are no parsing words. There is a prefix +handler `:`, yielding: + + :foo ... ; + +Quotes start with `[` and end with `]`. So they look like: + + [ ... ] + +If we want to name a quote, we need to: + +- create a header +- assign the xt field to the quote address +- set the class handler + +This word, `def`, does these. + +~~~ +:def (as-) d:create d:last d:xt store &class:word reclass ; +~~~ + +An example of using this: + +``` +[ 'Hello_%s!\n s:format s:put ] 'hello def +'#forth hello +```