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,9ce5fb49dc74582f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.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, 22 Nov 2006 17:57:50 -0600 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1163959439.299036.129940@e3g2000cwe.googlegroups.com> <87mz6nnt4v.fsf@ludovic-brenta.org> <20061119202320.19149a2f@cube.tz.axivion.com> <4560D5BE.5060508@obry.net> <1164059458.442430.110710@j44g2000cwa.googlegroups.com> <4562a51a$0$27404$ba4acef3@news.orange.fr> <45633396.10704@obry.net> Subject: Re: generic question Date: Wed, 22 Nov 2006 17:58:24 -0600 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-qu3dERwftvo4KEI5OgKmibte8PNawZiEpXHGzoQxD3S2oMUFqVZQNtBomfBE7QiLGC99bP/MMDU3mZC!0cBV3HU7q0VL0RQkEFuRhHkG156dXrVNSnIRk8bQqd/wN9MOpkW5fT0/u9l1YbYbPCLl7yyWjhYx!hfAWZpkI+s5WFg== 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: g2news2.google.com comp.lang.ada:7651 Date: 2006-11-22T17:58:24-06:00 List-Id: "Lutz Donnerhacke" wrote in message news:slrnem6dkc.3tk.lutz@belenus.iks-jena.de... > * Pascal Obry wrote: > > I find anonymous access type less useful this way... Why even bother > > with them then ? > > Because you can derive pointers without allocation. > E.g. self references of limited types. Well, that's one use. There are three others, IMHO: * To stand in for the lack of "in out" parameters on functions; * To avoid unnecessary type conversions between access-to-declared-in-limited-with; * To stand in for the lack of subprogram types (anonymous access-to-subprogram parameters). That's it. All other uses (especially controlling access parameters) are junk and should be avoided. In part, that follows from my opinion that there should be no access types in the vast majority of reusable Ada packages (if the user needs dynamic allocation, they can provide it). Of course, the implementation of the such a package might have some access types, but those might as well be named (there is no need for implicit conversions there). One of the reasons I feel this way that access types are inherently less safe than direct use of objects (because of the possibility of dangling pointers). And they force the customer of an abstraction to do memory management (or unsafe programming with very ugly calls) even when an stack-based allocation is fine. The reason anonymous access parameters were invented was because some people wanted to copy dubious OO designs from C++ directly into Ada without appropriate conversion. Which just brings the flaws of those designs into Ada - yuck. And, yes, I was against the expansion of the uses of anonymous access types in Ada 2007. I lost that discussion primarily because I didn't have a reasonable alternative for the second bullet above. Randy.