Digest #297 2025-07-03

Contributions

[382] 2025-07-02 03:31:11 EricBlake wrote:

requestClarification - Wording on ccc prohibits \" inside S\"

Table 2.1 in 2.2.3 Parsed text notation states

 ccc        a parsed sequence of arbitrary characters, excluding the delimiter character 

Meanwhile, S" states that it parses: ( "ccc<quote>" -- )

By a strict reading of the former, a "ccc<quote>" cannot include a " character in the ccc portion of the word, and yet the specification of the latter requires " to be a supported escape sequence. A related question affects whether ( and .( can have nested () in comments: https://forth-standard.org/standard/core/p#contribution-380

Maybe all that is needed is adding a normative clarification that some definitions document context-dependent scenarios under which a given character does or does not act as a delimiter character. Then in the S" page, document that an odd number of \ followed by " is one such context where " is not a delimiter; and if nested comments are allowed in (, then document that for implementations that allow nested comments, ")" is not a delimiter if it balances out a "(" present earlier in the ccc text.

Replies

[r1449] 2025-07-02 05:14:37 MarcelHendrix replies:

proposal - Octal prefix

iForth uses '&' (and '^') as a prefix for single characters. It was certainly not my idea -- I guess it came from FysForth. As that was a quite popular Forth in the Netherlands I am sure more Forths uses '&' (and, with a twist, '^') as single character prefixes. FORTH> &E ok [1]FORTH> emit E ok FORTH> &^ . 94 ok FORTH> ^C . 3 ok FORTH>

-marcel


[r1450] 2025-07-02 11:24:32 ruv replies:

requestClarification - Can balanced () be nested inside ( and .( comments?

which at strict reading would state that a comment cannot contain ")"

Yes.

and therefore probably should not contain "(".

No. This character is not considered as a delimiter by the word "(".

in practice, it seems several Forth implementations have ALWAYS supported comments such as "( n -- n' (n modified by ...) )",

This is not standard. The following test case should be passed in a standard Forth system:

 t{ ( foo ( bar )  char )  ->  char ) }t

you can quickly add another layer of () around large blocks of code

Just introduce another word for comments, which supports nesting. For example, these are encountered in practice (: ... :), (* ... *), (( ... ))

if "(" automatically refills the input buffer

BTW, it does refilling if the input source is a file (according to 11.6.1.0080). In some systems it does refilling when the input source is the user input device too — since when you copy-n-paste a fragment of code or definition from a file to the console, you expect comments to be interpreted the same way as in a file.

should probably document that it is ambiguous behavior if "(" appears in the "ccc)" word.

This makes some standard programs non-standard. A better way is to use a different (and longer) word for nested comments.


[r1451] 2025-07-02 12:09:00 ruv replies:

requestClarification - Wording on ccc prohibits \" inside S\"

By a strict reading of the former, a "ccc<quote>" cannot include a " character in the ccc portion of the word

Yes.

Probably, the glossary entry 6.2.2266 S\" should introduce and use another notation instead of ccc. Or use a more complicated definition for the delimiter character.