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,fa22a73e140a6fd1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.129.169 with SMTP id nx9mr3089897pbb.8.1326032296772; Sun, 08 Jan 2012 06:18:16 -0800 (PST) Path: lh20ni156447pbb.0!nntp.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Object-Oriented style question Date: Sun, 08 Jan 2012 09:18:16 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4f098fcb$0$6577$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1326032296 30810 192.74.137.71 (8 Jan 2012 14:18:16 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 8 Jan 2012 14:18:16 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:XAsW6O7NzvFljLGD7nlZQ+htaAg= Content-Type: text/plain; charset=us-ascii Date: 2012-01-08T09:18:16-05:00 List-Id: Georg Bauhaus writes: > function Info (Item : in T) return Value; This is the right way to do it. Don't use access types when you don't need to. That goes double for anonymous access types, and triple for cases involving run-time accessibility checks, as the cases below do. I can't think of any good reason to use access parameters in Ada. Note: "access parameter" does not mean "parameter of an access type", it means "parameter of an ANONYMOUS access type". The "in" is just noise; I suggest you leave it out. > function Info_1 (Item_Doubly_Indirect : access T) return Value; > function Info_2 (Item_Doubly_Indirect : access constant T) return Value; > function Info_3 (Item_Doubly_Indirect : not null access constant T) return Value; All of the above exclude null. That is, "not null" is implicit for Info_1 and Info_2. Calling any of these three with "null" will raise Constraint_Error. That's necessary, because they're dispatching on a Tag, and if the actual is null, there is no tag. So Info_2 and Info_3 have identical semantics. - Bob