title: Delphi: Records in Classes
body: <p>Following situation:</p>
  
  <pre><code>type
    TRec = record
      Member : Integer;
    end; 
  
    TMyClass = class
    private
      FRec : TRec;
    public
      property Rec : TRec read FRec write FRec;
    end;
  </code></pre>
  
  <p>The following doesn't work (left side cannot be assigned to), which is okay since <code>TRec</code> is a value type:</p>
  
  <pre><code>MyClass.Rec.Member := 0;
  </code></pre>
  
  <p>In D2007 though the following DOES work:</p>
  
  <pre><code>with MyClass.Rec do
    Member := 0;
  </code></pre>
  
  <p>Unfortunately, it doesn't work in D2010 (and I assume that it doesn't work in D2009 either). First question: why is that? Has it been changed intentionally? Or is it just a side effect of some other change? Was the D2007 workaround just a "bug"?</p>
  
  <p>Second question: what do you think of the following workaround? Is it safe to use?</p>
  
  <pre><code>with PRec (@MyClass.Rec)^ do
    Member := 0;
  </code></pre>
  
  <p>I'm talking about existing code here, so the changes that have to be made to make it work should be minimal.</p>
  
  <p>Thanks!</p>