在 Forth 中,'expect' 读了多少个字符?
In Forth, how many characters does 'expect' read?
Forth-83 spec定义单词expect
如下:
EXPECT addr +n -- M,83
Receive characters and store each into memory. The transfer
begins at addr proceeding towards higher addresses one byte
per character until either a "return" is received or until
+n characters have been transferred. No more than +n
characters will be stored. The "return" is not stored into
memory. No characters are received or transferred if +n is
zero. All characters actually received and stored into
memory will be displayed, with the "return" displaying as a
space.
因此,它最多读取但不包括 RETURN 或 EOL。
但是没有终止符,也没有 return读取的字符数,我怎么知道字符串在哪里结束?
Leo Brodie 引用了一个词 accept
,它的作用非常相似,具有签名 ( addr +n -- +m )
。这确实 return 读取的字符数,这是我所期望的。但这不在规范中...
standard还定义了SPAN
,它告诉你读取的字符数。
另请注意,在新标准中此功能已过时,请改用 ACCEPT
。
Forth-83 spec定义单词expect
如下:
EXPECT addr +n -- M,83
Receive characters and store each into memory. The transfer
begins at addr proceeding towards higher addresses one byte
per character until either a "return" is received or until
+n characters have been transferred. No more than +n
characters will be stored. The "return" is not stored into
memory. No characters are received or transferred if +n is
zero. All characters actually received and stored into
memory will be displayed, with the "return" displaying as a
space.
因此,它最多读取但不包括 RETURN 或 EOL。
但是没有终止符,也没有 return读取的字符数,我怎么知道字符串在哪里结束?
Leo Brodie 引用了一个词 accept
,它的作用非常相似,具有签名 ( addr +n -- +m )
。这确实 return 读取的字符数,这是我所期望的。但这不在规范中...
standard还定义了SPAN
,它告诉你读取的字符数。
另请注意,在新标准中此功能已过时,请改用 ACCEPT
。