[Rd] Strange parse behavior
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Apr 27 21:06:18 CEST 2006
Hi,
I discovered the following strange behavior in parse () on syntactically
incorrect statements. This is on R 2.3.0 (linux). It may or may not have been
present earlier than 2.3.0, but I only discovered it recently. I can see no
mention of it in the NEWS file from trunk.
Consider these statements (the output I get is shown commented below each
statement):
bad.syntax <- ")\nprint (\"hello\")\nprint (\"world\")"
try (parse (text=bad.syntax, n=-1)) # OK
# Error in parse(file, n, text, prompt) : syntax error in ")"
try (parse (text=bad.syntax, n=1)) # OK
# Error in parse(file, n, text, prompt) : syntax error in ")"
try (parse (text=bad.syntax, n=2)) # No error!
# NULL
try (parse (text=bad.syntax, n=3)) # No error!
# NULL
try (parse (text=bad.syntax, n=4)) # Misleading message
# Error in parse(file, n, text, prompt) : syntax error in:
# "print ("hello")
# print ("world")"
Probably there are not too many use cases of parse (n=x) with x not either -1
or 1, so it should not be a grave problem, but it just doesn't look right.
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-devel/attachments/20060427/c6066d72/attachment.bin
More information about the R-devel
mailing list