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 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-01.dc1.easynews.com.POSTED!not-for-mail From: Rob Solomon Newsgroups: comp.lang.ada Subject: Re: Table of pointers question Message-ID: <1k6sb5ljpnfb193qia4movirg8a09mckgc@4ax.com> References: <4abb18bc$0$30225$9b4e6d93@newsspool1.arcor-online.net> X-Newsreader: Forte Agent 4.2/32.1118 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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:45:51 -0400 Xref: g2news2.google.com comp.lang.ada:8480 Date: 2009-09-26T09:45:51-04:00 List-Id: >> > I am working my way thru Ada As A Second Language by Norman Cohen (c) >> > 1996 >> >> > This confuses me. >> >> > It is a simple sorting routine that swaps pointers rather than the >> > data. �Note that the variables are more like Modula-2 syntax as I am >> > very comfortable with that. �And it is easier to type. >> >> Has something gone wrong when (I'm guessing here) the >> program was rewritten for Ada? �The compiler shows some >> errors. �After correcting these formally, i.e. without thinking, >> it confirms Adam's observation, and hints to others: >> >> Compiling: printdirectory.adb (source file time stamp: 2009-09-24 06:42:50) >> >> � � 25. � EntryList � � � �: array (1..MaxEntries) of DirectoryEntryType; >> � � � � � | >> � � � � >>> warning: variable "EntryList" is not referenced >> >> � � 33. � � NewEntry.NamePart := To_Bounded_String(Buffer(1..Length)); >> � � � � � � | >> � � � � >>> warning: "NewEntry" may be null >> >> Here, the "correction" was >> 1 - �END IF; �-- semicolon, not colon >> ... >> 2, 3 - � �EntryPointerList(NumberOfEntries) := -- *new* >> DirectoryEntry*Pointer*Type'(NewEntry); �-- MY QUESTION HERE >> >> (NewEntry is of a pointer type already.) > >That's the error. NewEntry should not be a pointer type. The intent >appears to be that a record of type DirectoryEntryType is built, and >then a copy of it allocated on the heap and the pointer stored in the >array. (I'm assuming that's the case; I don't have Cohen's book >handy.) > >So the declaration of NewEntry is wrong. Perhaps that has to do with >a misunderstanding of the relationship between pointers and data; but >I think it's more likely just a typographical error, made harder to >spot by the lack of underscores. Thanks Adam. One of my problems here is that the example using pointers is not declared in its entirety, but modified from a prev example in the book. I did not understand what had to be modified and what remained. And I haven't attempted to understand section 8.5.4 yet.