TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

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

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To:
Date:
Thu, 1 Oct 1998 13:05:12 -0500
Reply-To:
Samuel Mize <[log in to unmask]>
Subject:
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"
failures.

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

Best,
Sam Mize

--
Samuel Mize -- [log in to unmask] (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam

ATOM RSS1 RSS2