comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Table of pointers question
Date: Thu, 24 Sep 2009 07:55:42 -0700 (PDT)
Date: 2009-09-24T07:55:42-07:00	[thread overview]
Message-ID: <cdb7a8c4-5774-48de-8b22-16a6cb1e945c@s21g2000prm.googlegroups.com> (raw)
In-Reply-To: 4abb18bc$0$30225$9b4e6d93@newsspool1.arcor-online.net

On Sep 23, 11:59 pm, Georg Bauhaus <rm.tsoh.plus-
bug.bauh...@maps.futureapps.de> wrote:
> Rob Solomon wrote:
> > 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.

                                     -- Adam



  parent reply	other threads:[~2009-09-24 14:55 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 [this message]
2009-09-26 13:45     ` Rob Solomon
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