Re: [S] enclosing commands in braces { }

Prof Brian D Ripley (
Wed, 21 Oct 1998 20:00:08 +0100 (BST)

On Wed, 21 Oct 1998 wrote:

> Dear colleagues,
> A few days ago someone posted a "helpful hint"
> that enclosing a block of commands in braces and then
> pasting into the commands window results in faster processing.
> i.e. pasting
> function1( )
> function2( )
> function3( )
> is slower than pasting
> {function1( )
> function2( )
> function3( )}
> I have also found this to be true and have been "bracing"
> every block of code that I paste into the commands
> window prior to pasting it.
> Can someone explain why this is faster and whether or not
> it is a good idea for me to be "bracing" everything prior
> to pasting?
> I operate in the windows NT environment and I use the
> Wordpad as an editor, copying blocks of S code from it and
> pasting them into the commands window.
> I apologize if this is a dumb question with an obvious answer.
> Perhaps someone can give me a page number to look at
> in the Splus 4.0 manuals, or a page number in V&R (old edition).

You won't find it there, definitely not in V&R1, as it is a `feature' of
S-PLUS 4.x only which was not even released when V&R2 appeared. The
underlying reason appears to be that communication between the command line
and the S-PLUS engine in 4.x has very considerable overheads, and is done
an expression at a time. `Bracing' commands makes them into an expression.
Even pasting in a function assignment, e.g.

foo <- function(blah) {

which is a single expression, seems very slow to me on 4.x. Perhaps
someone in MathSoft DAPD can explain how they managed to slow this down so
much from 3.3 to 4.0! (Not by as much as re-plotting on an existing
graph though.)

Is `bracing' a good idea? First, if any command fails, all the work is
lost, and because of this backout requirement, the memory requirements may
be much larger. Second, under the default setting of a graphsheet you will
get graphs on multiple pages, which may be what you want. Third,
grouping expressions does have advantages on any system, as the use of
grain.size in For() loops shows (that groups iterations into single

The reason I know this is that the easiest way I find to work when
demonstrating with 4.5 is to have commands in a script window, highlight
them and submit them. That does submit them as a single expression. I
would think a script window is at least as useful an editor for S source as
Wordpad (if not as useful as ESS mode in NTemacs, since that gives syntax
highlighting). As a new feature, script windows are probably still highly

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

----------------------------------------------------------------------- This message was distributed by To unsubscribe send e-mail to with the BODY of the message: unsubscribe s-news