AdaPower Logged in as Guest
Ada Tools and Resources

Ada 95 Reference Manual
Ada Source Code Treasury
Bindings and Packages

Join >
Home >
Articles >
Getting Started >
Ada FAQ >
Source Treasury >
Books & Tutorials >
Packages for Reuse >
Latest Additions >
Ada Projects >
Press Releases >
Ada Audio / Video >
Home Pages >
Links >
Contact >
About >
Login >
Modifiying the Contents of Limited Types Passed as "in" Parameters (Jean-Pierre Rosen)

The Contents of Limited Types Passed as "in" Parameters
can be modified using the following technique:

with Ada.Text_IO; use Ada.Text_IO;

procedure Rosen_Trick is

   type T;

   type Relay_Type (Reference : access T) is limited null record;

   type T is limited
         Relay : Relay_Type (T'Access);
         Data  : Natural := 0;
      end record;

   function Next (X : in T) return Integer is
      Data : Natural renames X.Relay.Reference.Data;
      Data := Data+1;
      return Data;
   end Next;

   Test_T : T;


   for N in 1 .. 10 loop
   end loop;

end Rosen_Trick;

(c) 1998-2004 All Rights Reserved David Botton