From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a6449b2443dcdda1 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!postnews.google.com!m1g2000pre.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Access keyword Date: Tue, 29 Apr 2008 10:37:05 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2fac581b-8361-486b-a139-603482e9b86f@m1g2000pre.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1209490626 25013 127.0.0.1 (29 Apr 2008 17:37:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 29 Apr 2008 17:37:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m1g2000pre.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:21118 Date: 2008-04-29T10:37:05-07:00 List-Id: On Apr 29, 6:55 am, S=E9bastien 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