,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2021-09-08 10:15:49 StephenPelc wrote: | proposal - Tick and undefined execution semantics - 2 | see: https://forth-standard.org/proposals/tick-and-undefined-execution-semantics-2#contribution-212 `------------------------------------------ # Tick and undefined execution semantics Proposal
8 September 2021
Stephen Pelc ## Change Log 2021-09-08 Initial version ## Problem The value (xt) returned by ' (`tick`) may not be useful for words with no defined execution semantics. Since the development of the ANS-94 standard, two common system behaviors have emerged. Systems based on classical Forth provide some execution semantics for all words and may provide additional functionality, e.g. LOCATE or XREF. A more recent approach is for ' and friends to have an ambiguous condition (or error) for all words without execution semantics. Previous proposals to modify ' have focused on ' itself. This proposal focuses on the use of the returned xt. ## Solution An implementation dependent result is returned by ' for words with undefined execution semantics. No current system is disenfranchised. It can continue doing what it already does. It can continue to error, to declare an ambiguous condition or to carry on. However, an ambigous condition may occur when a value returned by ' for a word with no execution semantics is used. ## Proposal In the glossary entries 6.1.0070 ' (Tick) and 6.1.2510 ['] (BracketTick) Replace the phrase: An ambiguous condition exists if name is not found. by If *name* has no execution semantics, the behavior of *xt* is implementation dependent and may lead to an ambiguous condition. In the glossary entries 6.2.2295 TO, 6.2.1725 IS, 6.2.0698 ACTION-OF, replace the phrase: An ambiguous condition exists if any of POSTPONE, [COMPILE], ' or ['] are applied to TO. by the phrase: An ambiguous condition exists if POSTPONE or [COMPILE] are applied to TO. In the section 4.1.2 Ambiguous conditions replace the phrase: attempting to obtain the execution token, (e.g., with 6.1.0070 ', 6.1.1550 FIND, etc. of a definition with undefined interpretation semantics; by the phrase: attempting to use the execution token, (e.g., returned by 6.1.0070 ', 6.1.1550 FIND, etc. of a definition with undefined interpretation semantics; ,---------. | Replies | `---------´ ,------------------------------------------ | 2021-09-03 03:30:03 MitraArdron replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-723 `------------------------------------------ I really don't think a reference implementation in one optional set should be dependent on a word from a different set {: :} are not part of the core standard. ,------------------------------------------ | 2021-09-03 09:26:00 ruv replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-724 `------------------------------------------ Actually, a reference implementation may even depend on specific system implementation details (it's impossible to avoid such dependencies). Hence, the more it may depend on any standard word set. And even more, reference implementations may have recursive "dependencies" — when several words uses each other (directly or indirectly). A reference implementation for a word is just an *illustration* how this word can be implemented, or what algorithm can be used for that. There is no such a purpose as mutual consistency of all reference implementations that allows to unite them all and get a ready system. See also **E.1 Introduction** to [Annex E. Reference Implementations](https://forth-standard.org/standard/implement) and the proposal [Reference implementations are not normative](https://forth-standard.org/proposals/reference-implementations-are-not-normative). ,------------------------------------------ | 2021-09-03 11:12:27 AntonErtl replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-725 `------------------------------------------ If you prefer a version without locals, this one is based on work by dxforth <[sgqdpg$1jsg$1@gioia.aioe.org](http://al.howardknight.net/?ID=163066718500)>, but I have not tested it: ``` : cmove ( afrom ato u -- ) >r 2dup swap - r@ u< if \ overlapping case over - r@ ( u) over + begin ( u1) >r over ( afrom) dup 2 pick + 2 pick r@ over - min move 2* r> over r@ ( u) u< not until r> 2drop 2drop else \ the usual non-pattern case r> ( afrom ato u) move then ; ``` ,------------------------------------------ | 2021-09-04 07:48:45 AntonErtl replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-726 `------------------------------------------ Rewrite after a bug report from dxforth; this implementation violates 13.3.3.2 d, so it will not run on systems that rely on this restriction. ``` : cmove {: afrom ato u -- :} ato afrom - u u< if \ pattern propagation case ato afrom - >r ato u begin 2dup r@ min afrom -rot move dup r@ u> while r@ /string r> 2* >r repeat r> drop 2drop else \ non-pattern case afrom ato u move then ; ``` This is not as simple as copying byte by byte, but significantly more efficient (e.g., factor >10 for 32-bit VFX 4.71 with patterns of length 2) for both cases if MOVE is implemented efficiently. ,------------------------------------------ | 2021-09-04 13:05:38 AntonErtl replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-727 `------------------------------------------ Rewrite after better testing revealed bugs appearing in corner cases: ``` : cmove ( afrom ato u -- ) dup 0= ?exit begin {: afrom ato u :} ato afrom - {: u1 :} afrom ato u1 u umin move u1 1 u within while afrom ato u u1 /string repeat ; ``` Few systems can handle the locals usage above, so here is a no-locals version: ``` : cmove ( afrom ato u -- ) dup 0= if exit then begin ( afrom1 ato1 u1 ) over 3 pick - 2>r 2dup 2r@ umin move 2r@ 1 rot within while 2r> /string repeat 2r> 2drop 2drop ; ``` This is not as simple as copying byte by byte, but significantly more efficient (e.g., factor >10 for 32-bit VFX 4.71 with patterns of length 2) for both cases if MOVE is implemented efficiently. ,------------------------------------------ | 2021-09-07 06:32:09 AntonErtl replies: | proposal - 2021 Standards meeting agenda | see: https://forth-standard.org/proposals/2021-standards-meeting-agenda#reply-728 `------------------------------------------ Thanks to Gerald Wodni we can find links to all open contributions except proposals on the [main page](/) below the 4 shown contributions, and there is als a [link to all proposals](/proposals) (unfortunately there is not yet a way to exclude accepted, retracted, and retired proposals). These links are probably helpful for the discussion participants, but unfortunately not in the order of the current agenda. I suggest that we work through contributions with the help of these links rather than the list of contribution titles given in the Agenda. For those taking notes, on each page for open contributions, there is also a link to a list of open contributions in markdown format. For the proposals here is a list (derived from [the list of all contributions in markdown format](https://forth-standard.org/contributions/markdown)). ``` ## 2021 Standards meeting agenda ([2021-standards-meeting-agenda #210](https://forth-standard.org/proposals/2021-standards-meeting-agenda#contribution-210)) ## PLACE +PLACE ([place-place #206](https://forth-standard.org/proposals/place-place#contribution-206)) ## Wording change for "COMPILE,": harmonization with terms ([wording-change-for-compile-harmonization-with-terms #200](https://forth-standard.org/proposals/wording-change-for-compile-harmonization-with-terms#contribution-200)) ## Reference implementations are not normative ([reference-implementations-are-not-normative #187](https://forth-standard.org/proposals/reference-implementations-are-not-normative#contribution-187)) ## EMIT and non-ASCII values ([emit-and-non-ascii-values #184](https://forth-standard.org/proposals/emit-and-non-ascii-values#contribution-184)) ## Query re status; and minor comments ([multi-tasking-proposal #167](https://forth-standard.org/proposals/multi-tasking-proposal#contribution-167)) ## Tick and undefined execution semantics ([tick-and-undefined-execution-semantics #163](https://forth-standard.org/proposals/tick-and-undefined-execution-semantics#contribution-163)) ## Common terminology for recognizers discurse and specifications ([common-terminology-for-recognizers-discurse-and-specifications #161](https://forth-standard.org/proposals/common-terminology-for-recognizers-discurse-and-specifications#contribution-161)) ## minimalistic core API for recognizers ([minimalistic-core-api-for-recognizers #160](https://forth-standard.org/proposals/minimalistic-core-api-for-recognizers#contribution-160)) ## An alternative to the RECOGNIZER proposal ([an-alternative-to-the-recognizer-proposal #159](https://forth-standard.org/proposals/an-alternative-to-the-recognizer-proposal#contribution-159)) ## Licence to use reference implementations ([licence-to-use-reference-implementations #158](https://forth-standard.org/proposals/licence-to-use-reference-implementations#contribution-158)) ## Reword the term "execution token" ([reword-the-term-execution-token- #157](https://forth-standard.org/proposals/reword-the-term-execution-token-#contribution-157)) ## Interpretation semantic for locals are undefined ([interpretation-semantic-for-locals-are-undefined #156](https://forth-standard.org/proposals/interpretation-semantic-for-locals-are-undefined#contribution-156)) ## Call for Vote - Ambiguous condition in 16.3.3 ([call-for-vote-ambiguous-condition-in-16-3-3 #155](https://forth-standard.org/proposals/call-for-vote-ambiguous-condition-in-16-3-3#contribution-155)) ## XML Forth Standard - migration from LaTeX to DocBook ([xml-forth-standard-migration-from-latex-to-docbook #154](https://forth-standard.org/proposals/xml-forth-standard-migration-from-latex-to-docbook#contribution-154)) ## Traverse-wordlist does not find unnamed/unfinished definitions ([traverse-wordlist-does-not-find-unnamed-unfinished-definitions #153](https://forth-standard.org/proposals/traverse-wordlist-does-not-find-unnamed-unfinished-definitions#contribution-153)) ## Nestable Recognizer Sequences ([nestable-recognizer-sequences #149](https://forth-standard.org/proposals/nestable-recognizer-sequences#contribution-149)) ## OPTIONAL IEEE 754 BINARY FLOATING-POINT WORD SET ([optional-ieee-754-binary-floating-point-word-set #148](https://forth-standard.org/proposals/optional-ieee-754-binary-floating-point-word-set#contribution-148)) ## 2020 Forth Standards meeting agenda ([2020-forth-standards-meeting-agenda #146](https://forth-standard.org/proposals/2020-forth-standards-meeting-agenda#contribution-146)) ## Recognizer ([recognizer #142](https://forth-standard.org/proposals/recognizer#contribution-142)) ## Same name token for different words ([same-name-token-for-different-words #136](https://forth-standard.org/proposals/same-name-token-for-different-words#contribution-136)) ## Wording: declare undefined interpretation semantics for locals ([wording-declare-undefined-interpretation-semantics-for-locals #133](https://forth-standard.org/proposals/wording-declare-undefined-interpretation-semantics-for-locals#contribution-133)) ## Recognizer RfD rephrase 2020 ([recognizer-rfd-rephrase-2020 #131](https://forth-standard.org/proposals/recognizer-rfd-rephrase-2020#contribution-131)) ## NAME>INTERPRET wording ([name-interpret-wording #129](https://forth-standard.org/proposals/name-interpret-wording#contribution-129)) ## Better wording for Colon ([better-wording-for-colon #128](https://forth-standard.org/proposals/better-wording-for-colon#contribution-128)) ## Input values other than true and false ([input-values-other-than-true-and-false #126](https://forth-standard.org/proposals/input-values-other-than-true-and-false#contribution-126)) ## Clarify FIND, more classic approach ([clarify-find-more-classic-approach #122](https://forth-standard.org/proposals/clarify-find-more-classic-approach#contribution-122)) ## VOCABULARY ([vocabulary #117](https://forth-standard.org/proposals/vocabulary#contribution-117)) ## Remove the “rules of FIND” ([remove-the-rules-of-find- #115](https://forth-standard.org/proposals/remove-the-rules-of-find-#contribution-115)) ## Case insensitivity ([case-insensitivity #114](https://forth-standard.org/proposals/case-insensitivity#contribution-114)) ## CS-DROP (revised 2019-08-22) ([cs-drop-revised-2019-08-22- #113](https://forth-standard.org/proposals/cs-drop-revised-2019-08-22-#contribution-113)) ## Right-justified text output ([right-justified-text-output #101](https://forth-standard.org/proposals/right-justified-text-output#contribution-101)) ## Searching for ] (right-bracket) doesn't return ] ([searching-for-right-bracket-doesn-t-return- #100](https://forth-standard.org/proposals/searching-for-right-bracket-doesn-t-return-#contribution-100)) ## Executing compilation semantics ([executing-compilation-semantics #94](https://forth-standard.org/proposals/executing-compilation-semantics#contribution-94)) ## Revise Rationale of Buffer: ([revise-rationale-of-buffer- #90](https://forth-standard.org/proposals/revise-rationale-of-buffer-#contribution-90)) ## F>R and FR> to support dynamically-scoped floating point variables ([f-r-and-fr-to-support-dynamically-scoped-floating-point-variables #75](https://forth-standard.org/proposals/f-r-and-fr-to-support-dynamically-scoped-floating-point-variables#contribution-75)) ## Case sensitivity ([case-sensitivity #73](https://forth-standard.org/proposals/case-sensitivity#contribution-73)) ## Revised Proposal Process ([revised-proposal-process #71](https://forth-standard.org/proposals/revised-proposal-process#contribution-71)) ## Multi-Tasking Proposal ([multi-tasking-proposal #67](https://forth-standard.org/proposals/multi-tasking-proposal#contribution-67)) ## CS-DROP (revised 2018-08-20) ([cs-drop-revised-2018-08-20- #66](https://forth-standard.org/proposals/cs-drop-revised-2018-08-20-#contribution-66)) ## S( "Request for Discussion" (revised 2018-08-16) ([s-request-for-discussion-revised-2018-08-16- #65](https://forth-standard.org/proposals/s-request-for-discussion-revised-2018-08-16-#contribution-65)) ## Let us adopt the Gerry Jackson test suite as part of Forth 200x ([let-us-adopt-the-gerry-jackson-test-suite-as-part-of-forth-200x #63](https://forth-standard.org/proposals/let-us-adopt-the-gerry-jackson-test-suite-as-part-of-forth-200x#contribution-63)) ## Tighten the specification of SYNONYM (version 1) ([tighten-the-specification-of-synonym-version-1- #60](https://forth-standard.org/proposals/tighten-the-specification-of-synonym-version-1-#contribution-60)) ## find-name ([find-name #58](https://forth-standard.org/proposals/find-name#contribution-58)) ## Clarify FIND ([clarify-find #55](https://forth-standard.org/proposals/clarify-find#contribution-55)) ## EXCEPTION LOCALs ([exception-locals #36](https://forth-standard.org/proposals/exception-locals#contribution-36)) ## BL rationale is wrong ([bl-rationale-is-wrong #34](https://forth-standard.org/proposals/bl-rationale-is-wrong#contribution-34)) ## The value of STATE should be restored ([the-value-of-state-should-be-restored #32](https://forth-standard.org/proposals/the-value-of-state-should-be-restored#contribution-32)) ## Core-ext S\" should reference File-ext S\" ([core-ext-s-should-reference-file-ext-s- #29](https://forth-standard.org/proposals/core-ext-s-should-reference-file-ext-s-#contribution-29)) ## Implementations requiring BOTH 32 bit single floats and 64 bit double floats. ([implementations-requiring-both-32-bit-single-floats-and-64-bit-double-floats- #26](https://forth-standard.org/proposals/implementations-requiring-both-32-bit-single-floats-and-64-bit-double-floats-#contribution-26)) ## Directory experiemental proposal ([directory-experiemental-proposal #25](https://forth-standard.org/proposals/directory-experiemental-proposal#contribution-25)) ## DEFER this not :-) ([defer-this-not- #22](https://forth-standard.org/proposals/defer-this-not-#contribution-22)) ## WLSCOPE -- wordlists switching made easier ([wlscope-wordlists-switching-made-easier #20](https://forth-standard.org/proposals/wlscope-wordlists-switching-made-easier#contribution-20)) ``` ,------------------------------------------ | 2021-09-07 14:22:37 AntonErtl replies: | proposal - Interpretation semantic for locals are undefined | see: https://forth-standard.org/proposals/interpretation-semantic-for-locals-are-undefined#reply-729 `------------------------------------------ Accepted with vote #17 12Y:0:0 ,------------------------------------------ | 2021-09-08 16:18:38 StephenPelc replies: | requestClarification - Why "[" is specified using immediacy? | see: https://forth-standard.org/standard/core/Bracket#reply-730 `------------------------------------------ On behalf of the committee. The word `[` is immediate because of a historical accident. If you wish to make a proposal, we invite you to do so. The committee leans towards defining interpretation semantics. ,------------------------------------------ | 2021-09-08 16:39:19 BerndPaysan replies: | requestClarification - Implementation for «S"» via the immediacy mechanism | see: https://forth-standard.org/standard/file/Sq#reply-731 `------------------------------------------ On behalf of the committee,\ The original 94 TC very likely meant this (state-smart `S"`) to be standard, but failed to specify it that way. ,------------------------------------------ | 2021-09-08 16:48:46 GeraldWodni replies: | requestClarification - Web site problem? | see: https://forth-standard.org/standard/right-bracket#reply-732 `------------------------------------------ There is an [open issue on github](https://github.com/GeraldWodni/forth-standard.org/issues/21) regarding this problem. Feel free to investigate and submit a pull request. Otherwise please refer further discussion about this on github. I'll eventually fix it when I find time. ,------------------------------------------ | 2021-09-08 16:57:22 StephenPelc replies: | requestClarification - How many cells can be compared ? Must have any limit ? | see: https://forth-standard.org/standard/string/COMPARE#reply-733 `------------------------------------------ ,------------------------------------------ | 2021-09-08 16:57:55 StephenPelc replies: | requestClarification - How many cells can be compared ? Must have any limit ? | see: https://forth-standard.org/standard/string/COMPARE#reply-734 `------------------------------------------ Oops, I forgot to close the response again ,------------------------------------------ | 2021-09-08 17:04:25 AntonErtl replies: | requestClarification - ALLOT in ROMable systems | see: https://forth-standard.org/standard/core/ALLOT#reply-735 `------------------------------------------ Several committee members have given answers to this request. ,------------------------------------------ | 2021-09-08 17:14:00 AntonErtl replies: | requestClarification - Stack effect of LEAVE during compilation | see: https://forth-standard.org/standard/core/LEAVE#reply-736 `------------------------------------------ On behalf of the committee: Is such a LEAVE implementation standard-compliant? No. Will this break any production programs? Most likely not. ,------------------------------------------ | 2021-09-08 17:20:31 AntonErtl replies: | requestClarification - Size of implementation dependent data types | see: https://forth-standard.org/standard/usage#reply-737 `------------------------------------------ On behalf of the committee: None of the committee think that a given system-dependent type always must have the same size. However, it's then up to the system to deal with the consequences. ,------------------------------------------ | 2021-09-08 17:28:20 AntonErtl replies: | requestClarification - Is a counted string limited to 255 chars? | see: https://forth-standard.org/standard/core/COUNT#reply-738 `------------------------------------------ The question has been answered. Closing. ,------------------------------------------ | 2021-09-08 17:30:28 AntonErtl replies: | requestClarification - Can `BLOCK` transfer from mass storage in the case when block u is already in a block buffer? | see: https://forth-standard.org/standard/block/BLOCK#reply-739 `------------------------------------------ Answered below, closing. ,------------------------------------------ | 2021-09-08 17:44:39 AntonErtl replies: | requestClarification - Return value of XC-WIDTH for control characters | see: https://forth-standard.org/standard/xchar/XC-WIDTH#reply-740 `------------------------------------------ On behalf of the committee: You are welcome to contribute an improved reference implementation. A quick poll among the committee members produced the result that several systems return -1 for control characters and no nominations for 0. ,------------------------------------------ | 2021-09-08 17:52:12 AntonErtl replies: | requestClarification - Is Tick Immediate? | see: https://forth-standard.org/standard/core/Tick#reply-741 `------------------------------------------ The question has been answered, closing. ,------------------------------------------ | 2021-09-08 18:00:46 AntonErtl replies: | proposal - Reword the term "execution token" | see: https://forth-standard.org/proposals/reword-the-term-execution-token-#reply-742 `------------------------------------------ ## Author: M. Anton Ertl ## Change Log: 2020-09-03 Hashed out the new wording in a committee meeting. 2021-09-03 Hashed out another wording in a committee meeting. ## Problem: The definition of the term "execution token" does not match its usage in FIND, ', ['], NAME>INTERPRET, NAME>COMPILE. ## Solution: Change the wording of the definition of the term to match the usage. ## Proposal: In [Section 2.1](https://forth-standard.org/standard/notation#section.2.1), change: > execution token: > A value that identifies the execution semantics of a definition. into > execution token: > A value that can be passed to EXECUTE (6.1.1370) ,------------------------------------------ | 2021-09-08 18:37:22 AntonErtl replies: | proposal - Clarify FIND | see: https://forth-standard.org/proposals/clarify-find#reply-743 `------------------------------------------ Over the course of the last year it has become clear that a significant number of systems don't support user-defined text interpreters based on FIND that are as capable as the system-defined text interpreter; e.g., in some systems FIND does not find locals (and there is no other standardized way to do that), and IIRC VFX5 handles S" other than intended in such a user-defined text interpreter. So basically, there is no common practice for a FIND-based user-defined text interpreter that can handle all of Forth. There is also no consensus that this is something that should be supported with FIND. So this proposal is based on wrong assumptions about the intentions of the committee and the community at large. Therefore I retract it. ,------------------------------------------ | 2021-09-08 18:43:45 AntonErtl replies: | proposal - Same name token for different words | see: https://forth-standard.org/proposals/same-name-token-for-different-words#reply-744 `------------------------------------------ A system is allowed to do it, but is not required to do it. The committee does not see a need to add such a clause to the standard. If you still want to go ahead with the proposal, you should make it more formal. ,------------------------------------------ | 2021-09-08 21:15:27 UlrichHoffmann replies: | proposal - PLACE +PLACE | see: https://forth-standard.org/proposals/place-place#reply-745 `------------------------------------------ # PLACE +PLACE request for discussion **Standardizing common use** ## Change History * 2021-09-08 remove conditional phrase from PLACE definition following committees comments * 2021-09-08 change reference imlementation for PLACE to avoid no overlapping issue, code by Wil Baden * 2020-07-29 improving Markdown formatting * 2020-07-28 revising historical description, correcting typos * 2021-07-26 adding history * 2021-07-22 initial version ## Problem Traditional Forth represents strings in memory as so called _counted strings_, a leading count byte giving the length of the string (0 to 255) followed by the characters of string. No character value plays a special role (in contrast to zero-terminated strings where the character NUL terminates the string). The limitation of a single count byte and thus a maximal string length of 255 characters imposes no restriction on a broad range of applications especially in embedded systems. Of course there are applications that require processing longer strings. The programmer should then best use another string representation (such as c-addr len) without the length restriction of counted strings. The advantage of counted strings is that they are identified by a single cell (the address of the count byte) on the data stack and so help minimizing stack rearrangements. The Forth-94 and Forth-2012 standards make use of counted strings and specify even core words which use counted string representation such as WORD FIND COUNT. The Informational Annex of Forth-94 says in A.3.1.3.4 about counted strings Counted strings remain useful as a way to store strings in memory. This use is not discouraged, but when references to such strings appear on the stack, it is preferable to use the “_c-addr u_” representation. What is missing is an easy way to place a sequence of characters into memory using the counted string representation and also appending a sequence of characters to an already existing counted string in memory. ## Solution The Forth community already has a solution for placing strings as counted strings into memory and appending characters to counted strings by means of the words PLACE and +PLACE. PLACE appeared around 1984 e.g. in F83. +PLACE has been proposed by Wil Baden in his Tool Belt Extensions (latest version at [1], also with the name APPEND)[^1]. Since then many systems have adopted PLACE and +PLACE with exactly the same behaviour. So, we are proposing PLACE and +PLACE here for standardization. ## Proposal Please add the following specifications to the string extension word set. --- **PLACE** STRING EXT ( c-addr1 u c-addr2 -- ) Store u as a length character at c-addr2. Only the number of low-order bits corresponding to character size are transferred. If u is greater than zero, copy u consecutive characters from the data space starting at c-addr1 to that starting at c-addr2+1, proceeding character-by-character from lower addresses to higher addresses. **+PLACE** "plus place" STRING EXT ( c-addr1 u1 c-addr2 -- ) Read the length character at c-addr2 as u2. Store u1+u2 as a count character at c-addr2. When character size is smaller than cell size, only the number of low-order bits corresponding to character size are transferred. If u1 is greater than zero, copy u1 consecutive characters from the data space starting at c-addr1 to that starting at c-addr2+u2+1, proceeding character-by-character from lower addresses to higher addresses. --- end of proposal ## Rationale **PLACE** places the string identified by c-addr1 u as a counted string at c-addr2 managing the length character. Essentially PLACE converts from c-addr len representation to counted string representation. **PLACE** complements **COUNT** which essentially converts counted strings in memory to their c-addr u representations. **+PLACE** appends the string identified by c-addr1 u1 to the counted string at c-addr2 (with length u2) managing the updated string length in the length character at c-addr2. The application must take care of any string overflow situation where the length of the resulting string would exceed the maximal length that can be stored in a length character. Also it has to assure that the memory is available to store the resulting string. Note, that the proposal adds PLACE and +PLACE to the up to now empty string extensions word set. A compliant Forth system is free to provide or not to provide these words individually. If it chooses to provide them, they must have the above behaviour. Providing the words could be done by making the reference implementation available in source form or by means of an appropriate alias definition of an already provided word. ## Typical Use ``` S" The quick brown" PAD PLACE S" fox jumps over" PAD +PLACE S" the lazy dog." PAD +PLACE PAD COUNT TYPE ( The quick brown fox jumps over the lazy dog.) ``` ## Reference Implementation PLACE and +PLACE can be implemented in Forth-94 as follows: ``` : PLACE ( c-addr1 u c-addr2 -- ) 2DUP 2>R CHAR+ SWAP CHARS MOVE 2R> C! ; : +PLACE ( c-addr1 u c-addr2 -- ) DUP COUNT + >R 2DUP C@ + SWAP C! R> SWAP MOVE ; ``` Of course systems are expected to provide optimized implementations. ## Testing The following tests assure basic functionality of PLACE and +PLACE ``` CREATE buf 64 ALLOT T{ S" ABC" buf PLACE buf COUNT S" ABC" COMPARE -> 0 }T T{ S" ABC" buf PLACE buf C@ -> 3 }T T{ S" ABC" buf PLACE S" DEF" buf +PLACE buf COUNT S" ABCDEF" COMPARE -> 0 }T ``` ## Experience PLACE and +PLACE have been implemented in numerous systems with the proposed functionality. +PLACE is sometimes called APPEND. A non-exhaustive list is:
System PLACE +PLACE
gforth ?? ??
SwiftForth ?? provided as APPEND
VFX Forth ?? provided as APPEND in ToolBelt.fth
Win32Forth ?? ??
4th ?? ??
PFE ?? ??
F-PC ?? ??
F83 ??
volksForth-83 ??
DXForth ??
## Discussion ### Why standardize PLACE and +PLACE? Standard programs that deal with counted strings often also make use of PLACE and +PLACE. As these words are not known to be provided by the underlying system the standard program has to bring its own possibly less efficient implementation with it. This can be done with a prelude that uses the above reference implementation. Note that the typical phrase ``` [UNDEFINED] PLACE [IF] «reference implementation for PLACE» [THEN] [UNDEFINED] +PLACE [IF] «reference implementation for +PLACE» [THEN] ``` is not sufficient as the underlying system might provide PLACE or +PLACE, but with a different behaviour, rendering the rest of the standard program invalid. If PLACE and +PLACE are standardized, then a compliant system (if it decides to provide them) has to define them with the exact proposed behaviour. The above phrase would be sufficient and standard programs can leverage efficient system provided implementations. ### **Restriction on the Length of Counted Strings** Forth-94 and Forth-2021 both do not enforce characters to be of byte size so allow for systems with larger character sizes and by this also counted strings with a maximal length that exceeds 255 characters. For this reason both standards use the term “length character” and not “count byte”. Since then, in 2016 the Forth-200x committee in favour of eliminating ambiguous conditions has decided to require “1 CHARS = 1” thus making systems that have other character sizes than on not compliant to _future_ Forth-200x standards [2][3]. Requesting standard systems to have byte size characters limit counted strings to the known maximal length of 255 characters. ## References [1] “Toolbelt”, Wil Baden/Neil Bawd, [http://www.wilbaden.com/neil_bawd/tool2002.txt](http://www.wilbaden.com/neil_bawd/tool2002.txt) [2] http://www.forth200x.org/rfds.html [3] http://www.forth200x.org/char-is-1.html ## Authors Hans Bezemer <[thebeez@xs4all.nl](mailto:thebeez@xs4all.nl)> Ulrich Hoffmann <[uho@xlerb.de](mailto:uho@xlerb.de)> ## Notes [^1]: If the reader is aware of the detailed history of +PLACE aka APPEND, the authors would be happy to learn about that.