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

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Tue 08 Mar 2005 - 04:42:52 EST

Gabor Grothendieck <ggrothendieck@myway.com> writes:

> Jan T. Kim <jtk <at> cmp.uea.ac.uk> 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
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
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