title: Does R copy unevaluated slots in S4 classes on assignment?
body: <p>Suppose I have an S4 class with two slots. I then create a method that sets one of the slots to something and returns the result. Will the other slot also be copied on assignment?</p>
  
  <p>For example,</p>
  
  <pre><code>setClass('foo', representation(first.slot = 'numeric', second.slot = 'numeric'))
  setGeneric('setFirstSlot', function(object, value) {standardGeneric('setFirstSlot')})
  setMethod('setFirstSlot', signature('foo', 'numeric'), function(object, value) {
   object@first.slot = value
   return(object)
   }) 
  
   f &lt;- new('foo')
   f@second.slot &lt;- 2
   f &lt;- setFirstSlot(f, 1)
  </code></pre>
  
  <p>On the last line, will the values of both the first and second slot be copied or will there be some sort of optimization? I have a class with a field holding a gigabyte of data and a few fields with small numeric vectors, I'd like to have a setter function for the numeric fields that doesn't waste time needlessly copying the data every time it's used.</p>
  
  <p>Thanks :)</p>