Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Access keyw...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 24 Topic 5675 of 5827
Post > Topic >>

Re: Access keyword

by Adam Beneschan <adam@[EMAIL PROTECTED] > Apr 29, 2008 at 10:37 AM

On Apr 29, 6:55 am, S=E9bastien <seb.mor...@[EMAIL PROTECTED]
> wrote:
> Hi,
>
> I'd like to know if there is performance issue using the access keyword?
>
> for instance the following code:
>
> package MonTest is
>
>    type Vecteur is
>      record
>        x: Integer;
>        y: Integer;
>      end record;
>
>    function Norme(v: in Vecteur) return integer;
>    function NormeAccess(v: access Vecteur) return integer;
>
> end MonTest;
>
> package body MonTest is
>
>    function Norme(v: in Vecteur) return integer is
>      n: Integer :=3D v.x*v.x + v.y*v.y;
>    begin
>      return n;
>    end Norme;
>
>    function NormeAccess(v: access Vecteur) return integer is
>      n: Integer :=3D v.x*v.x + v.y*v.y;
>    begin
>      return n;
>    end NormeAccess;
>
> end MonTest;
>
> Is NormeAccess faster because I'm using access keyword?

Something to keep in mind is that "access" parameters require
additional information to be passed, in order to do accessibility
level checking.  For example, suppose the body looked like this:

   type Vec_Acc is access all Vecteur;
   Save_Vec_Acc : Vec_Acc;
   function NormeAccess(v: access Vecteur) return integer is
     n : Integer :=3D v.x*v.x + v.y*v.y;
   begin
     Save_Vec_Acc :=3D Vec_Acc(v);
   end NormeAccess;

Since you can't have a global access variable pointing to a local
variable belonging to some procedure, the program will have to check,
at run time, whether the "v" you passed in points to a global or
local; and this means that whoever calls NormeAccess will also have to
tell it the "accessibility level" of the access that it's passing in.
Now I realize that your NormeAccess doesn't actually do anything like
this with the access, but the compiler isn't going to know that when
it compiles the specification of MonTest, so the accessibility level
will need to be passed in somehow, regardless of whether it will be
used.  This will almost certainly use up a few extra cycles.

                                  -- Adam
 




 24 Posts in Topic:
Access keyword
=?ISO-8859-1?Q?S=E9bastie  2008-04-29 13:55:17 
Re: Access keyword
Peter Hermann <ica2ph@  2008-04-29 14:35:33 
Re: Access keyword
Ludovic Brenta <ludovi  2008-04-29 07:43:18 
Re: Access keyword
stefan-lucks@[EMAIL PROTE  2008-04-29 17:16:42 
Re: Access keyword
=?ISO-8859-1?Q?S=E9bastie  2008-04-29 16:31:09 
Re: Access keyword
Gautier <gautier@[EMAI  2008-04-29 21:55:56 
Re: Access keyword
=?ISO-8859-1?Q?S=E9bastie  2008-04-30 14:26:18 
Re: Access keyword
Gautier <gautier@[EMAI  2008-04-30 19:13:23 
Re: Access keyword
Adam Beneschan <adam@[  2008-04-29 10:37:05 
Re: Access keyword
"Jeffrey R. Carter&q  2008-04-29 19:08:33 
Re: Access keyword
Maciej Sobczak <see.my  2008-04-29 14:03:18 
Re: Access keyword
"Randy Brukardt"  2008-04-29 16:32:47 
Re: Access keyword
Gautier <gautier@[EMAI  2008-04-30 06:36:16 
Re: Access keyword
Maciej Sobczak <see.my  2008-04-30 00:15:47 
Re: Access keyword
"Dmitry A. Kazakov&q  2008-04-30 09:56:44 
Re: Access keyword
Georg Bauhaus <rm.tsoh  2008-04-30 11:21:06 
Re: Access keyword
=?ISO-8859-1?Q?S=E9bastie  2008-04-30 14:32:40 
Re: Access keyword
Adam Beneschan <adam@[  2008-04-30 08:16:42 
Re: Access keyword
Adam Beneschan <adam@[  2008-04-30 08:20:17 
Re: Access keyword
"Randy Brukardt"  2008-04-30 18:40:43 
Re: Access keyword
Maciej Sobczak <see.my  2008-04-30 14:32:13 
Re: Access keyword
Adam Beneschan <adam@[  2008-04-30 14:58:41 
Re: Access keyword
Adam Beneschan <adam@[  2008-04-30 18:10:22 
Re: Access keyword
Ludovic Brenta <ludovi  2008-04-30 22:44:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:15:31 CDT 2008.