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,efe381d5ed2da234 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: aschwarz@acm.org (skidmarks) Newsgroups: comp.lang.ada Subject: Re: Ada Pointer Problem Date: 7 Oct 2004 11:45:41 -0700 Organization: http://groups.google.com Message-ID: <35f054ea.0410071045.58d3e9af@posting.google.com> References: <7KadnU33z-bmpsLcRVn-og@megapath.net> <35f054ea.0410060743.7b73aac3@posting.google.com> NNTP-Posting-Host: 199.46.200.237 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1097174742 23311 127.0.0.1 (7 Oct 2004 18:45:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 7 Oct 2004 18:45:42 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4890 Date: 2004-10-07T11:45:41-07:00 List-Id: Thank you for your response, most assuredly thank you for not taking offense and starting a flame. > > So maybe there is an opportunity to improve the exposition of > Ada language constructs for programmers expecting wide spread > terminology. > Even if there is good reason to make the distinction > between the _various_ pointer like things and addresses in Ada > explicit. > OTOH, almost every introductory chapter, starting from the beginning, > mentions access values. > Ada as a Second Language has a whole chapter describing access > types. They are also mentioned in the introductory chapter, IIRC. > Does Ada assume programmers that have had an opportunity to > become familiar with their tool? > > In order to find "pointer" in the ARM (Ada 95, admittedly) > I pressed the search key twice for "pointer" and found: > > 18. (77) Access values are called "pointers" or "references" in some > other languages. > Ada draws sharp distinction between Ada constructs and similar constructs in other languages. In the early years (Ada 83) this distinction seems to have led to an abandonment of the use of common terminology in favor of the Ada specific flavor. This resulted in my inability to find a 'pointer'. My recollection is that the Ada 83 LRM and 'Ada as a Second Language' have no index or table of contents reference to 'pointer'. Looking for a pointer becomes fruitless, and looking for an 'Access Type' works if you already know that an 'Access Type' is what you want. Ada 95 improves the search time for items with different Ada flavors but with common names in other languages. Pointer is one of the explicit references, and one which would have improved the Ada 83 LRM and books. > Could you give some examples? > The best example is the one that prompted my original posting. Within a subprogram I attempted to create a pointer to an object created in the same subprogrm using a typedef imported from another spec file. This thread shows good reasons why this is inadvisable and why such care was spent making it impossible to do using 'Access'. My compiler (Green Hills Version 3.5) provided not the slightest clue as to why this happened or where to look for a rationale. My argument is that even if the compiler had been more congenial, the language is still tortuous. And for me, tortuous to the point of being almost unusable. To continue the point, the Ada developers recognized both the indavisability of doing what I wanted and the advisability of letting me do this assignment, also mentioned in this thread and very gratefully received by me. However, this is a research game. Ada has protected me to the point that I can't get my job done without research. Commmon assumptions are uncommonly treated. Now (back to pointers) I am similarly frustrated. I want to point to an object created on the call stack and to pass/use this pointer to my hearts delight. However, I don't know how. Rather than belabor the point and spending my time in research (and your time in answering what must be almost frivolous questions), I am using heap allocation. 'Ada as a Second Language' recommends that the heap deallocator (Unchecked_Deallocation) not be used - on fear of death no doubt. Fortunately, this is a non-real-time program on a PC with an available address space of 2Gb. The period of execution is small enough that wasting space is not a problem. Hence, no Unchecked_Deallocation will be used. Why pointers? The compilers we are using pass by value. Arrays and records copied to the stack on subprogram entry, and copied back on subprogram exit (or so I have been told). A pointer reduces this copy operation. Pointers are useful for maintaining indirect references to volatile data. The reference changes when the data changes, but no copy operation is required. Pointers are useful in lists. And so on. The 'point' is that the required reading to do simple, but perhaps non-pedestrian things, is far larger than in other languages. This intrudes on my ability to produce a product (but does not impact good design). Putting it another way, I can build a house with a steel hammer or a brass hammer. If I used a brass hammer I would be required to periodically grind it's head to make it true. The brass hammer is shiny, bright, and a real pleasure to look at, but lacks something in use. As (in my opinion) does Ada. > > -- Georg art