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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,72a0bc6240d264e3 X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: Access and alias Date: 2000/04/05 Message-ID: <38EBBBBE.87C93900@acm.org>#1/1 X-Deja-AN: 607300015 Content-Transfer-Encoding: 7bit References: <86d7o5ae23.fsf@ppp-169-201.villette.club-internet.fr> <86aej9aa8y.fsf@ppp-169-201.villette.club-internet.fr> <38EB55AE.D4A241FD@icn.siemens.de> <8cfnpd$3h7$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 954976759 63.10.53.62 (Wed, 05 Apr 2000 16:19:19 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 Reply-To: jrcarter@acm.org NNTP-Posting-Date: Wed, 05 Apr 2000 16:19:19 PDT Newsgroups: comp.lang.ada Date: 2000-04-05T00:00:00+00:00 List-Id: Ted Dennison wrote: > > In article <38EB55AE.D4A241FD@icn.siemens.de>, > Alfred Hilscher wrote: > > If you write your own bindings, you shouldn't work with 'address. Use > > an in out parameter instead. > > E.g. proc (ref : SYSTEM.ADDRESS); --> proc (ref : in out X); > > ...unless you are writing a binding to a function, in which case you are > back to using addresses. If you have to pass null, access types (with convention C) work fine. If you don't have to pass null, in out works for procedures, and access parameters work for functions. All keep the type checking that addresses lose: -- int func (int* I); function F1 (I : System.Address) return Int; pragma Import (C, F1, "func"); function F2 (I : access Int) return Int; pragma Import (C, F2, "func"); I : aliased Int; J : Int; S : String := Get; ... J := F1 (I'Address); -- works as intended J := F1 (S'Address); -- works as not intended J := F2 (I'access); -- works as intended J := F2 (S'access); -- compilation error -- Jeff Carter "You couldn't catch clap in a brothel, silly English K...niggets." Monty Python & the Holy Grail