Re: [R] simple if...else causes syntax error

From: Peter Dalgaard <>
Date: Tue 08 Mar 2005 - 04:42:52 EST

Gabor Grothendieck <> writes:

> Jan T. Kim <jtk <at>> writes:

> : Out of personal interest: Does anyone here know why the R parser was
> : designed this way? Personally, I have been coding in R for years in the
> : belief that newline is whitespace, and never even noticed any problems
> : because all my ifs with elses were within functions and thus enclosed
> : in curly braces.
> :
> If it did not work that way it would require console lookahead. That is
> it would not know that the if statement was finished and would have
> to wait for the following statement to be completely typed in before
> it could process the if. The way it works now the if statement can
> be processed immediately.

Or put differently, the language designers were not quite aware of the reason that other command-line languages tend to use explicit construct terminators like "endif" or "fi".... (I think that is almost a quote from one of the prominent language experts inside R core, but I can't pinpoint the details.)

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (             FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Tue Mar 08 04:55:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:41 EST