[R] if/else at 1.3.1
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Oct 18 04:23:20 CEST 2001
On Wed, 17 Oct 2001, HEUMANN,JOHN (A-Loveland,ex1) wrote:
> Under NT with 1.3.1
>
> if (x == 1) {
> cat("Saw x=1\n");
> } else {
> cat("Saw x!=1\n");
> }
>
> works as expected, but
>
> if (x == 1) {
> cat("Saw x=1\n");
> }
> else {
> cat("Saw x!=1\n");
> }
>
> is currently giving me a syntax error on the "else" line.
> Apparently the parser considers the if statement to have
> ended as soon as it sees first closing brace, unless
> there's an else on the same line.
Right, that is as described in the R Language Reference Manual, e.g.
in section 10.2.5.
All R statements are considered ended at the first new line at which they
are syntactically complete.
> IIRC, both forms were accepted at 1.3.0. Is this a bug,
If it worked in 1.3.0, that was a bug, as it was documented otherwise in
that version too.
> or intentional? I don't see any mention of this
> change in the "What's New" notes. BTW, I didn't notice
> this behavior until after a crash (caused by a known
> package bug) which blew me all the way out of RGui,
> so its possible I've corrupted my installation...
I've never seen a syntax error crash RGui. If that is all that there is
to this, please file a bug report.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list