R 4.0.0 brings in a new syntax for raw strings:
r"(raw string here can contain anything except the closing sequence)"
But this same construct in R 3.x.x produced a syntax error:
Error: unexpected string constant in "r"(asdasd)""
Does it mean that the interpreter was changed in R 4.0.0. ?
And if so - does R 4.0.0. provide a mechanism to define custom functions like foo"()"
?
No, that's not possible at the moment (nor would I anticipate it becoming possible anytime soon).
Here's the NEWS item:
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
Then from ?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
Here's the (git
mirror of the SVN patch of the) commit where this functionality was added:
https://github.com/wch/r-source/commit/8b0e58041120ddd56cd3bb0442ebc00a3ab67ebc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With