Blank commands

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Blank commands

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
<[hidden email]> 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?


[hidden email] mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.