comp.lang.ada
 help / color / mirror / Atom feed
From: "Mark Lundquist" <mark@rational.com>
Subject: Re: controlled type in generic package?
Date: Wed, 7 Feb 2001 13:57:17 -0800
Date: 2001-02-07T13:57:17-08:00	[thread overview]
Message-ID: <95sgd9$ncg$1@usenet.rational.com> (raw)
In-Reply-To: slrn9827l8.ml.lutz@taranis.iks-jena.de


Lutz Donnerhacke <lutz@iks-jena.de> wrote in message
news:slrn9827l8.ml.lutz@taranis.iks-jena.de...
> * Mark Lundquist wrote:
> >The compilation error that was reported would have been due to the
> >instantiation.  The instantiation is a copy of the generic template, so
you
> >can't instantiate a generic that does something that would be illegal to
do
> >in the same place if it weren't in a generic :-).  In this case, that
> >something is to declare a type extension that's statically deeper than
the
> >parent.
>
> I don't understand the reason, but will keep it in mind, until I came
across
> this situation.

OK, here's the reason:

Suppose you have

    type T is tagged record
        .
        .

and

    procedure P (X : access T'Class);        -- (or a parameter of a named
access type)

Now suppose in a nested scope we say

    type D is new T with record
        .
        .

If we have an object of type D, we can pass a pointer to it in a call to P.
But maybe P does something squirrely with this pointer, like saving it on a
list.
Once the scope of D goes away, so have all objects of type D, so that
pointer is now dangling.  The result: The Kind Of Error That Is Not Supposed
To Happen To An Ada Program :-) :-)

I think Bob Duff's "limited access" proposal would fix this.  I really like
that proposal.

-- mark






  reply	other threads:[~2001-02-07 21:57 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-06 11:06 controlled type in generic package? Nils Priebe
     [not found] ` <slrn97vtf5.ho.lutz@taranis.iks-jena.de>
     [not found]   ` <95q19j$9d$1@usenet.rational.com>
2001-02-07 10:11     ` Lutz Donnerhacke
2001-02-07 21:57       ` Mark Lundquist [this message]
     [not found]   ` <95p2ab$463$1@nnrp1.deja.com>
2001-02-07 15:08     ` Jean-Pierre Rosen
2001-02-08 15:41       ` Ted Dennison
2001-02-08 18:21         ` Jean-Pierre Rosen
2001-02-08 16:31       ` Florian Weimer
2001-02-08 21:10       ` Brian Rogoff
2001-02-09 10:39         ` Florian Weimer
2001-02-09 17:02           ` Brian Rogoff
2001-02-09 18:45             ` Florian Weimer
2001-02-13  0:32           ` Nick Roberts
2001-02-14  0:30             ` Jon S Anthony
     [not found]               ` <x7vg0hd20cm.fsf@smaug.pushface.org>
     [not found]                 ` <hovk6.96$aw5.304@www.newsranger.com>
2001-02-23 20:50                   ` Simon Wright
     [not found]     ` <95q1fa$9e$1@usenet.rational.com>
2001-02-07 15:28       ` Ted Dennison
2001-02-07 16:29         ` Brian Rogoff
     [not found]           ` <3A82A66D.49DE7EBD@bton.ac.uk>
2001-02-08 15:15             ` Robert Dewar
2001-02-08 16:56             ` Florian Weimer
2001-02-09 10:25               ` John English
2001-02-09 19:46                 ` Brian Rogoff
2001-02-07 18:52         ` Pat Rogers
2001-02-07 19:23           ` Pat Rogers
2001-02-07 19:50             ` Ted Dennison
2001-02-07 22:52         ` Jean-Pierre Rosen
2001-02-08  9:36           ` dmitry6243
2001-02-09  8:51             ` Jean-Pierre Rosen
2001-02-09 12:28               ` dmitry6243
2001-02-08 19:58           ` Mark Lundquist
2001-02-10  9:54           ` Thomas Wolf
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox