title: Ada initialization of controlled singleton variable
body: <p>I am trying to create a package with a singleton variable that is auto initialized.  If the singleton variable is not a controlled type, then the compiler doesn't complain, but when I make it controlled, I get the warning:"cannot call Initialize before body seen"</p>
  
  <p>Followed by:
  "Program error will be raised at run time."</p>
  
  <p>So, I think the compiler wants the singleton variable to be hidden from child objects, but this is not what I want.  Here's my code:</p>
  
  <pre><code>with Ada.Finalization;
  
  package static_member is
     type singleton_type is tagged limited private;
  
  private
     type singleton_type is new Ada.Finalization.Limited_Controlled with record
        data_to_init: Natural;
     end record;
  
     overriding procedure Initialize(data: in out singleton_type);
     overriding procedure Finalize(data: in out singleton_type);
  
     --This is where I get the warnings.
     --I want singleton to be visible to child objects.
     singleton: singleton_type;
  end static_member;
  </code></pre>
  
  <p>Then the package body is:</p>
  
  <pre><code>package body static_member is
     overriding procedure Initialize(data: in out singleton_type) is
     begin
        data.data_to_init := 0;
     end Initialize;
  
     overriding procedure Finalize(data: in out singleton_type) is null;
  end static_member;
  </code></pre>
  
  <p>How would I create a singleton variable that is initialized, and ready to use by the time object instances begin to be created? Thanks in advance.</p>