TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date: Thu, 1 Oct 1998 13:05:12 -0500
Reply-To: Samuel Mize <[log in to unmask]>
From: Samuel Mize <[log in to unmask]>
Content-Transfer-Encoding: 7bit
In-Reply-To: <[log in to unmask]> from "Scott Edgerton" at Oct 1, 98 11:59:03 am
Content-Type: text/plain; charset=US-ASCII
MIME-Version: 1.0
Parts/Attachments: text/plain (45 lines)
Scott Edgerton wrote:
  [quoting Michael Feldman]
> For example, if P and Q designate the same value, and you deallocate
> through P, what is the behavior if you try to dereference (access the
> designated block of) Q?
>   Once P has been deallocated, it's value is NULL
>   (ref RM 13.11.2 (7)). Therefore, the value at Q
>   should also be NULL (provided that that storage
>   hasn't been reallocated for something else)
>   Unless I'm missing something?

Sorry, yes, you are.

The value of P is null, but that's the pointer, not the pointed-at
storage space.  Meanwhile, Q (and any other duplicate pointers to
that space) still have their old value -- on some machines this is
now meaningless garbage, on others it still refers to the same
block of memory (which is now available for re-allocation).

>   Perhaps this is why people say that "Ada is hard to learn"...
>   Aliasing (on the surface) seems like a pretty
>   straight forward concept.

Aliasing is a general concept, and is pretty straightforward.  It
means you have two names for the same variable.

In this particular version of aliasing, using pointers, you can
you can have a name that outlives the storage allocation for the
variable.  This is a problem.  It's a common cause, in C, of
hard-to-trace weird behavior and "segmentation fault - core dumped"

Ada's access-value design tries to help the user keep track of
what he's doing.

Sam Mize

Samuel Mize -- [log in to unmask] (home email) -- Team Ada
Fight Spam: see \\\ Smert Spamonam