From: Rob Solomon <usenet@drrob1-noreply.com>
Subject: Re: Table of pointers question
Date: Sat, 26 Sep 2009 09:45:51 -0400
Date: 2009-09-26T09:45:51-04:00 [thread overview]
Message-ID: <1k6sb5ljpnfb193qia4movirg8a09mckgc@4ax.com> (raw)
In-Reply-To: cdb7a8c4-5774-48de-8b22-16a6cb1e945c@s21g2000prm.googlegroups.com
>> > 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.
next prev parent reply other threads:[~2009-09-26 13:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-24 0:47 Table of pointers question Rob Solomon
2009-09-24 1:34 ` Adam Beneschan
2009-09-24 6:39 ` tmoran
2009-09-25 16:52 ` björn lundin
2009-09-25 17:12 ` Adam Beneschan
2009-09-24 2:00 ` (see below)
2009-09-24 3:46 ` Jeffrey R. Carter
2009-09-24 6:59 ` Georg Bauhaus
2009-09-24 7:06 ` Georg Bauhaus
2009-09-24 14:55 ` Adam Beneschan
2009-09-26 13:45 ` Rob Solomon [this message]
2009-09-24 6:59 ` Stephen Leake
2009-09-26 13:50 ` Rob Solomon
[not found] ` <3cadnZif2YjGbyfXnZ2dnUVZ_tmdnZ2d@earthlink.com>
2009-09-24 12:49 ` Robert A Duff
2009-09-26 13:36 ` Rob Solomon
2009-09-26 14:51 ` John B. Matthews
[not found] ` <3YSdnY7SXPNd_yPXnZ2dnUVZ_sydnZ2d@earthlink.com>
2009-09-26 18:58 ` Rob Solomon
2009-09-26 21:00 ` Georg Bauhaus
2009-09-27 5:53 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox