Digest #175 2022-03-07


[226] 2022-03-06 21:06:16 LSchmidt wrote:

requestClarification - c-addr used in stack diagrams

about representation of counted strings on stack, A. Counted strings says:

Forth 94 moved toward the consistent use of the "c-addr u" representation of strings on the stack.

While I like consistency, it appears that what was gained is a potential of confusion: c-addr appears to be used to indicate address of count byte, as it is done here. But elsewhere, for example with s" it represents the address of the first character. It isn't obvious from the stack diagrams that those identically looking c-addr refer to different kind of data.

When pointing to the leading count byte of a string, the "c" in "c-addr" makes sense. But when pointing to the first character, it doesn't really. Does it imply that there's a count byte at c-addr-1? Not necessarily, I think. Then what makes such a string of characters "counted"? Shouldn't, by similar reasoning, the source address of movenot also be "counted" - after all, there's also the count of items to move on stack, similar to the c-addr u representation of a string when c-addr points to the first character.

As I see it, there are three cases where c-addr is used to depict stack effects:

  • c-addr indicating the address of a leading count byte
  • c-addr indicating the address of first character in a string with a leading count byte at c-addr-1
  • c-addr indicating the address of first character in a string without a leading count byte.

It is my opinion that for these three different cases not the same stack symbol ought to be used.


[r802] 2022-03-06 07:21:10 AntonErtl replies:

comment - Using a . suffix to specify a double

The . suffix is specified in Section 8.3.1.