title: True C static local variable replacement?
body: <p>just trying to achieve similar functionality of C/C++ static local variables in ObjectPascal/Delphi.
  Let's have a following function in C:</p>
  
  <pre><code>bool update_position(int x, int y)
  {
      static int dx = pow(-1.0, rand() % 2);
      static int dy = pow(-1.0, rand() % 2);
  
      if (x+dx &lt; 0 || x+dx &gt; 640)
          dx = -dx;
      ...
      move_object(x+dx, y+dy);
      ...
  }
  </code></pre>
  
  <p>Equivalent ObjectPascal code using typed constants as a static variable replacement fails to compile:</p>
  
  <pre><code>function UpdatePosition(x,y: Integer): Boolean;
  const
    dx: Integer = Trunc( Power(-1, Random(2)) );  // error E2026
    dy: Integer = Trunc( Power(-1, Random(2)) );
  begin
    if (x+dx &lt; 0) or (x+dx &gt; 640) then
      dx := -dx;
    ...
    MoveObject(x+dx, y+dy);
    ...
  end;
  </code></pre>
  
  <p><strong>[DCC Error] test_f.pas(332): E2026 Constant expression expected</strong></p>
  
  <p>So is there some way for a one-time pass initialized <em>local</em> variable ?</p>