comp.lang.ada
 help / color / mirror / Atom feed
* Access types vs. Record types as procedure parameters
@ 1999-08-19  0:00 Andrew L Moore {66003}
  1999-08-19  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrew L Moore {66003} @ 1999-08-19  0:00 UTC (permalink / raw)


I am debating on whether to pass a record object to a procedure or an access type to that record object.

For example I have:

     package body X is
     type Record_Type;
     type Array_Type is array (1 .. n) of Record_Type;
     Array_Object : Array_Type;
     procedure One;
     procedure Two (Parameter : in Record_Type);
     ---More procedures and functions
     end X;
     procedure One is
     begin
     for I in range 1 .. n loop
           procedure Two(Parameter => Array_Object (I));
     end loop;
     end One;
     --------------------------------------------------------------------------------------
     OR:
     package body X is
     type Record_Type;
     type Array_Type is array(1 .. n) of Record_Type;
     type Access_Type is access Record_Type;
      Array_Object : Array_Type;
     function Address_To_Pointer is new
Ada.Unchecked_Conversion(System.Address, Access_Type);
     procedure One;
     procedure Two (Parameter : in Access_Type);
     --More procedures and functions
     end X;
     procedure One is
     Object_Ptr : Access_Type := null;
     begin
     for I in range 1 .. n loop

         Object_Ptr := Address_To_Pointer(Array_Object(I)'Address)
          procedure Two (Parameter => Object_Ptr);
     end loop;
     end One;

I am looking for the way that would provide the greatest speed of
execution.  I know that passing a pointer to an object of a record type
is more efficient that passing the record itself, but would that be
negated by repeated calls to Unchecked_Conversion.  Basically, are there
any advantages to using Unchecked_Conversion to get an access value to
an object to then pass it to a procedure.

Any assistance you could provide would be greatly appreciated.







^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-08-19  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-19  0:00 Access types vs. Record types as procedure parameters Andrew L Moore {66003}
1999-08-19  0:00 ` Robert Dewar
1999-08-19  0:00 ` Larry Kilgallen
1999-08-19  0:00 ` Matthew Heaney
1999-08-19  0:00   ` Tucker Taft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox