在 Forth 中打印双引号
Print double quotes in Forth
单词."
打印一个字符串。更准确地说,它编译 (.")
和当前编译单词中的下一个 "
字符串。
但是我怎么打印
That's the "question".
与 Forth?
在 Forth-2012 系统(例如 Gforth)中,您可以使用字符串文字并通过单词 s\"
转义为:
: foo ( -- ) s\" That's the \"question\"." type ;
在 Forth-94 系统(大多数标准系统)中,您可以使用任意解析,单词 sliteral
为:
: foo ( -- ) [ char | parse That's the "question".| ] sliteral type ;
字符串也可以提取到行尾(没有可打印的定界符);也可以提取多行字符串。
可以轻松定义针对特定情况的特定助手。
例如,对于由任意可打印字符分隔的字符串文字,请参见单词 s$
,例如:
s$ `"test" 'passed'` type
老派:
34 emit
输出:
"
使用gforth
:
: d 34 emit ;
cr ." That's the " d ." question" d ." ." cr
输出:
That's the "question".
单词."
打印一个字符串。更准确地说,它编译 (.")
和当前编译单词中的下一个 "
字符串。
但是我怎么打印
That's the "question".
与 Forth?
在 Forth-2012 系统(例如 Gforth)中,您可以使用字符串文字并通过单词 s\"
转义为:
: foo ( -- ) s\" That's the \"question\"." type ;
在 Forth-94 系统(大多数标准系统)中,您可以使用任意解析,单词 sliteral
为:
: foo ( -- ) [ char | parse That's the "question".| ] sliteral type ;
字符串也可以提取到行尾(没有可打印的定界符);也可以提取多行字符串。
可以轻松定义针对特定情况的特定助手。
例如,对于由任意可打印字符分隔的字符串文字,请参见单词 s$
,例如:
s$ `"test" 'passed'` type
老派:
34 emit
输出:
"
使用gforth
:
: d 34 emit ;
cr ." That's the " d ." question" d ." ." cr
输出:
That's the "question".