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: a07f3367d7,15480fcd593513b9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!news-in-02.newsfeed.easynews.com!easynews!core-easynews-01!easynews.com!en-nntp-06.dc1.easynews.com.POSTED!not-for-mail From: Rob Solomon Newsgroups: comp.lang.ada Subject: Re: Table of pointers question Message-ID: References: <3cadnZif2YjGbyfXnZ2dnUVZ_tmdnZ2d@earthlink.com> X-Newsreader: Forte Agent 4.2/32.1118 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@easynews.com Organization: Forte Inc. http://www.forteinc.com/apn/ X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. Date: Sat, 26 Sep 2009 09:36:26 -0400 Xref: g2news2.google.com comp.lang.ada:8479 Date: 2009-09-26T09:36:26-04:00 List-Id: >> My question is that I would expect to have an array that contains the >> data, and a second array that is an array of pointers to the 1st >> array. The example does not define that. > > That sounds like what I'd have used in BASIC or FORTRAN -- an array >of INDICES (not [memory] pointers) used as subscripts to a static array >of the data -- and the sort would be implemented by swapping the >indices, not the physical data (IOWs, the indices start sorted 1..n, and >end up out-of-order -- but when you then retrieve the data be using the >indices from first to last, the data is in correct order). > You are describing how I expected the code to be written. Many years ago I wrote that very routine in Fortran, and I felt very satisfied that it worked. When I did the same routine in Modula-2, I structured it the same way, only used an array of pointer rather than indices. AFAIK, Modula-2 does not have the capability to place data in the heap and return a pointer in one assignment. So when I came across this example that did not structure it as I expected, I was confused. It did not occur to me that Ada could do what everyone here says it does. The syntax of the statement is also confusing to me. EntryPointerList(NumberOfEntries) := new DirectoryEntryType'(NewEntry); It would help me to break this statement down more. Why is the last part written the way it is? It uses a single quote and parens. I don't understand this syntax. How does this store data on the heap and then return a pointer to assign to the pointer list?