R-beta: 0.61.1 "if else" parse bug?

Ross Ihaka (ihaka@stat.auckland.ac.nz)
Wed, 14 Jan 1998 11:05:43 +1300 (NZDT)

Date: Wed, 14 Jan 1998 11:05:43 +1300 (NZDT)
Message-Id: <199801132205.LAA19391@stat1.stat.auckland.ac.nz>
From: Ross Ihaka <ihaka@stat.auckland.ac.nz>
To: "Buyukisik, Osman (GEAE)" <Osman.Buyukisik@ae.ge.com>
Subject: R-beta: 0.61.1 "if else" parse bug?
In-Reply-To: <0302875C631AD11198DE00600806C637479FFF@ev009msxaege.ae.ge.com>

Osman Buyukisik writes:
 > I was playing with porting "Hmisc" S-Lib. I am getting parse errors for:
 > if (xxx)  yyyy;else zzzz
 > I have to break this into:
 > if(xxx) yyyy
 > else    zzzz
 > Is this a known feature?

Hmmm.  Bug or feature?

Note that as you've written it, this does not parse in S either.
	{ if (xxx)  yyyy;else zzzz }

It works in S because the parser converts ";" immediately into "\n"
and within "{ ... }" a newline preceding preceding an "else" is not

There is a side-effect problem in S which comes out of this quick-fix.
E.g (in S)
	> 1;2
	[1] 1
	> [1] 2
Note the extra prompt printed before the second value.

It might be possible to "unfix" this in R, but it's not trivial.

I'd suggest that you make a quick pass through the code removing any
";"s which occur at the end of lines and converting any ";"
immediately before an "else" into a space (or newline).

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@stat.math.ethz.ch