[Rd] Line-terminal \ in character consants -- missing from ?Quotes ?

Michael Chirico ch|r|com @end|ng |rom goog|e@com
Sun Feb 12 06:07:39 CET 2023


I'm coming across some code that uses the fact the parser ignores a
line-terminal '\', e.g.

identical("\
", "\n")
# [1] TRUE

x = "abc \
def"
y = "abc \ndef"
identical(x, y)
# [1] TRUE

However:
identical("\\n", "\n")
# [1] FALSE

This appears to be undocumented behavior; the closest thing I see in
?Quotes suggests it should be an error:

> Escaping a character not in the following table is an error.

('\n' is in the table, but my understanding is the 'n' is what's being
escaped v-a-v the "error", which seems confirmed by the third, FALSE,
example above)

Is this a bug, is the omission from ?Quotes a bug, or is this just
undocumented behavior?

Mike C



More information about the R-devel mailing list