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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,54e6f3bfd18d2769 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Pointer function parameter Date: 2000/10/21 Message-ID: <8ss8vo$69a$1@nnrp1.deja.com>#1/1 X-Deja-AN: 684143753 References: X-Http-Proxy: 1.0 x64.deja.com:80 (Squid/1.1.22) for client 205.232.38.240 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sat Oct 21 14:25:00 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-10-21T00:00:00+00:00 List-Id: In article , comp.lang.ada@ada.eu.org wrote: > The "in this vein" is there for a reason: in the vein of using > Ada access types for the same purposes you use C pointer types > for--and only in this vein--, attribute Access is in fact the > Ada equivalent of the C address operator &. But unless you are writing C code in Ada, you do NOT use Ada access types "for the same purposes you use C pointer types for". That's the important point. > > The equivalent strito senso--not in the vein above--is of course attribute > Address. But if you use Address everywhere where you use & in the > equivalent C program, you miss a great part of the gain of using Ada > instead of C. Ah, but what you are missing is that most normally the Ada approach is to use access types all over the place as required but almost NEVER to use the 'Access attribute. Sure if you want to write C code in Ada you can, but you are also missing a "great part of the gain in writing Ada" if you create dangerous aliasing all over the place by using the 'Access attribute and aliased objects and types. > (Perhaps you read "Address" where it says "Access" in my first reply?) No, not at all. The critical point here is that normally, other than when interfacing to foreign code, or building certain static data structures, you do not want to use EITHER attribute. Yes, of course 'Access is preferable to 'Address, but the far more important point is not to use either in ordinary code except in rare cases. When we discussed adding 'Access to the language, we recognized that, although it was useful in specialized cases, it opened up a Pandora's box of very bad programming practice, and, sad to say, I see far too many programmers opening this box! A C programmer has as much trouble seeing that the use of pointers needs limiting as an old style Fortran programmer has in seeing that gotos need limiting > And surely there is a _lot_ of uses of access types besides interfacing to > C: virtually all dynamic data structures (linked lists, trees, etc.) > require them. Yes, of course, but in Ada, you use pointers for these purposes WITHOUT using the 'Access attribute. If you find yourself using 'Access to implement linked lists, trees etc, you are most likely doing something wrong (wrong in the sense of not taking advantage of Ada). Sent via Deja.com http://www.deja.com/ Before you buy.