Dick van Oudheusden <dvoudheus...@gmail.com> writes:
>On 30 Oct, 22:16, Peter Knaggs <pkna...@bournemouth.ac.uk> wrote:
>> : parse\" \ caddr len dest -- caddr' len' ... >Perhaps it is also a good idea to standardize the underlying word
> parse\" ( -- c-addr u)
>in this proposal so that programmers can use it for other words, like >.\" and ,\" and so on?
Yes, such a word would be useful, especially if S\" has no interrpetation semantics (as currently proposed) or if it has interpretation semantics, but cannot be ticked or POSPONEd to allow state-smart implementations (as I suggested).
However, the word with the ( "string<">" -- c-addr u ) stack effect is called READESCAPED in the reference implementation.
A lower-level word like the PARSE\" ( c-addr1 u1 c-addr2 -- c-addr2 u2 ) from the reference implementation might be useful in a few additional cases and thus might be a better choice. One thing that has to be considered is the length of the buffer at c-addr2. With the current escape sequences it is good enough if the buffer has length u1, and that will also be the case for any likely candidates for escape sequences, so the stack effect above may be ok.
An advantage of standardizing a word that passes the destination buffer rather than a word that writes to a system-supplied buffer is that we don't need to specify the lifetime of the result. The disadvantage is that we need to consider the buffer length, what happens on overflow (not an issue here), and the programmer can make a mistake and supply buffer smaller than the specified length, leading to a buffer overflow.