Skip to content
Back to formatted view

Raw Message

Message-ID: <x2y8cz4ajn.fsf@biostat.ku.dk>
Date: 2005-03-07T17:42:52Z
From: Peter Dalgaard
Subject: simple if...else causes syntax error
In-Reply-To: <loom.20050307T171450-177@post.gmane.org>

Gabor Grothendieck <ggrothendieck at 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 at biostat.ku.dk)             FAX: (+45) 35327907