Skip to content
Prev 78599 / 398502 Next

Assign references

Seeliger.Curt at epamail.epa.gov wrote:

            
I think Tony's reply has the main part of the answer.  R is
designed as a functional language -- meaning, essentially,
that side effects don't happen except for assignment.  The
"<<-" operator (and 'assign') are compromises from that
ideal. 

In C it is standard practice to pass by reference and that is
a great deal of its power.  In R it is standard practice not to
have to worry about objects being changed behind your
back -- that freedom is a part of the power of R.

On the surface this looks contradictory -- one of the two
approaches must be the better way.  But the two languages
have different uses.  C computes extremely efficiently in terms
of having operations that closely match the machine.  R computes
efficiently by having operations that closely match how people
think.

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")