R 4.0.0。是否可以定义 foo"(...)" 运算符,类似于新引入的 r"(...)" 语法?
Does R 4.0.0. make it possible to define foo"(...)" operators, similar to the newly introduced r"(...)" syntax?
R 4.0.0 为原始字符串引入了新语法:
r"(raw string here can contain anything except the closing sequence)"
但是 R 中的相同构造 3.x.x 产生了语法错误:
Error: unexpected string constant in "r"(asdasd)""
这是否意味着解释器在 R 4.0.0 中已更改。 ?
如果是这样 - R 4.0.0。提供一种机制来定义自定义函数,例如 foo"()"
?
不,目前还不可能(我也不认为它很快就会成为可能)。
这是新闻项目:
There is a new syntax for specifying raw character constants similar to the one used in C++: r"(...)"
with ...
any character sequence not containing the sequence )"
. This makes it easier to write strings that contain backslashes or both single and double quotes. For more details see ?Quotes
.
https://cran.r-project.org/doc/manuals/r-devel/NEWS.html
然后从?Quotes
:
Raw character constants are also available using a syntax similar to
the one used in C++: r"(...)"
with ...
any character
sequence, except that it must not contain the closing sequence
)"
. The delimiter pairs []
and {}
can also be
used, and R
can be used in place of r
. For additional
flexibility, a number of dashes can be placed between the opening quote
and the opening delimiter, as long as the same number of dashes appear
between the closing delimiter and the closing quote.
https://github.com/wch/r-source/blob/trunk/src/library/base/man/Quotes.Rd
这是添加此功能的(git
的 SVN 补丁的镜像)提交:
https://github.com/wch/r-source/commit/8b0e58041120ddd56cd3bb0442ebc00a3ab67ebc
R 4.0.0 为原始字符串引入了新语法:
r"(raw string here can contain anything except the closing sequence)"
但是 R 中的相同构造 3.x.x 产生了语法错误:
Error: unexpected string constant in "r"(asdasd)""
这是否意味着解释器在 R 4.0.0 中已更改。 ?
如果是这样 - R 4.0.0。提供一种机制来定义自定义函数,例如 foo"()"
?
不,目前还不可能(我也不认为它很快就会成为可能)。
这是新闻项目:
There is a new syntax for specifying raw character constants similar to the one used in C++:
r"(...)"
with...
any character sequence not containing the sequence)"
. This makes it easier to write strings that contain backslashes or both single and double quotes. For more details see?Quotes
.
https://cran.r-project.org/doc/manuals/r-devel/NEWS.html
然后从?Quotes
:
Raw character constants are also available using a syntax similar to the one used in C++:
r"(...)"
with...
any character sequence, except that it must not contain the closing sequence)"
. The delimiter pairs[]
and{}
can also be used, andR
can be used in place ofr
. For additional flexibility, a number of dashes can be placed between the opening quote and the opening delimiter, as long as the same number of dashes appear between the closing delimiter and the closing quote.
https://github.com/wch/r-source/blob/trunk/src/library/base/man/Quotes.Rd
这是添加此功能的(git
的 SVN 补丁的镜像)提交:
https://github.com/wch/r-source/commit/8b0e58041120ddd56cd3bb0442ebc00a3ab67ebc