Re: R-alpha: assignment scoping

Ross Ihaka (
Wed, 29 May 1996 16:19:09 +1200

Date: Wed, 29 May 1996 16:19:09 +1200
From: Ross Ihaka <>
Message-Id: <>
To: Bill Venables <>
Subject: Re: R-alpha: assignment scoping
In-Reply-To: <>

Bill Venables writes:

 > Is there any dramatic differernce between 1. and 2.?

Yes.  1) copies on every mutation whereas 2) copies once to make the
local copy.  This is dramatic with

	for(i in 1:1000) x[i] <- i

You save 999 copies.

We do something like this with objects which come in as function
arguments.  We have simple examples where we get a speed up of 10x
over S.  (On the other hand it is not hard to construct examples where S
beats the snot out of R).

> (While you are at it, I would personally favour outlawing, or at
> least not implementing, the <<- operator.  If people are so
> determined to write code with hideous side effects we shouldn't
> make it easy for them!  Let them use "assign" and be done with
> it.  Oh, and while you are at it, ditch the `_' assignment
> operator.  I hate that too...:-)

Sheesh!  We originally left _ out for very much the reasons you
mention and we got yelled at coz it was "missing".

We need the <<- operator (at least in the absence of declarations)
because we do some stuff with mutable state which uses it.  See the
file demo/scoping for a simple example.

I agree on the S compatibility front.  I basically want something we
can use for teaching from year one to the end of a masters degree.
I'd very much like to be out of the business of maintaining computing
labs and want some software which I can give to the kiddies to run
at home or on a laptop.  It would be nice if this resembled something
which they could get commercial support for when they graduate
(if they choose to).

> S version 4 will be a kind of a watershed, though, and will break
> many things.  The entire OOP mechanism is radically different and
> even the syntax will look different.  For example `=' will become
> an allowed (in fact preferred) assignment operator, a la C.

I think we need to recognise that the technology in S (even version 4)
and R is seriously flawed.  We need compilation and efficient use of
memory rather desperately.  From what I've seen of Sv4 we aren't
going to get them.  Building a clos-like object system on top of a
flawed substrate is likely to be fairly unsatisfactory when it comes
to serious production work.
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: