[R] Blank commands
Stavros Macrakis
macrakis at alum.mit.edu
Wed Dec 31 19:10:58 CET 2008
On Tue, 30 Dec 2008, m.u.r. wrote in thread [R] plot.stepfun xlim:
> foo <- stepfun(0.5, c(1, 0));
On Wed, Dec 31, 2008 at 4:18 AM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> replied:
> Why are you adding two blank commands via the semicolons?
The R parser (2.8.0 Windows) does not seem to have the concept of
blank commands. After all:
(using <NL> to represent Newlines below)
1 => 1
1; => 1 (wouldn't a blank command return NULL?)
1;; => ERROR (hmm... seems inconsistent...)
{1} => 1
{1 <NL> } => 1
{1;} => 1
{1;;} => 1
{;;;1;;;} => 1
So the extra semi-colons seem to have no semantic effect. The
following examples show that there are no blank commands in the
abstract (deep) syntax, either:
identical(quote({a}),quote({a;})) => TRUE
identical(quote({a}),quote({;a})) => TRUE
identical(quote({a <NL> b}),quote({a; b})) => TRUE
identical(quote({a <NL> b}),quote({a; <NL> b})) => TRUE
identical(quote({}), quote({;;;;; <NL><NL> ;;;;;})) => TRUE
Unless this is a bug, or I'm missing some subtlety, R's ";" is just
concrete (surface) syntax. Why, then, shouldn't users use it any way
they like, just like whitespace and comments? It is just a matter of
style, isn't it? Are there any good *stylistic* arguments for
preferring one to the other?
-s
More information about the R-help
mailing list