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,8f802583e5c84fa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 05 Oct 2005 18:00:36 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1KednYZNMNxP8NzeRVn-3A@comcast.com> Subject: Re: String filtering Date: Wed, 5 Oct 2005 18:04:21 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4952.2800 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4952.2800 Message-ID: <2MydnS2z3bCJxtneRVn-qA@megapath.net> NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-3KHCPfb1S4PkPLg6FAKsYZX02avbmFZKQTUFJw73J/dDtPTWKzgLbN0rP69BVZx7Hvvl3osNfuO3kDg!S2MPiRkSi4FTA0RyzJFXl0bcODRLU1MNUrrbpJbQ9fhho7hESuYyaZIyBNXxh8uIMCTrhBN8ZmTl X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:5429 Date: 2005-10-05T18:04:21-05:00 List-Id: "Robert A Duff" wrote in message news:wccu0fya3c3.fsf@shell01.TheWorld.com... ... > And there's some run-time overhead for access parameters -- they carry > run-time accessibility-level info with them. That's not just an overhead issue, but also potentially a safety issue, as the accessibility checks are done at run-time. Sometimes you need that, but the result is that the location of the call determines whether or not Program_Error is raised -- which means that only testing (rather than the Ada compiler) will ferret out problems. Wheras the same code with an in out parameter would be illegal (and have no run-time overhead). Much better from a safety perspective. To give an example (using procedures so it's legal Ada code): type T is tagged ...; type AT is access all T; procedure P1 (O : in out T) is P : AT := O'access; -- Illegal, accessibility fails. begin .... end P1; procedure P2 (O : access T) is P : AT := O; -- Might raise Program_Error, depending on the point of the call. begin ... end P2; Obj : T; Obj2 : aliased T; -- Extra aliased needed here, even though it has no effect. P1 (Obj); P2 (Obj2'Access); -- Extra 'Access here, even though the code is essentially the same. Using access parameters clutters both the objects and the call site, adds run-time overhead, and in Ada 200Y, even might add null checks (unless you hadd even more clutter with "not null" in the parameter declaration). And what's the difference? For a tagged type, the code generated (and the evaluation order issues) for "in out" and "access" are essentially identical, but one is allowed and the other isn't. Makes lots of sense. > Furthermore, there's (annoyingly) no way to declare a formal parameter > aliased. So you use 'access' where 'in out' should suffice, or you > declared tagged types that have no need for a tag. There are no such types. :-) [OK, I'm kidding, but there certainly aren't many such types.] > Yes, there are workarounds for the lack of [in] out params on functions > -- but they have global consequences on your code. Yes, indeed. Randy.