From: "Pat Rogers" <progers@NOclasswideSPAM.com>
Subject: Re: controlled type in generic package?
Date: Wed, 7 Feb 2001 12:52:55 -0600
Date: 2001-02-07T12:52:55-06:00 [thread overview]
Message-ID: <hQgg6.41$bZ4.1624@nnrp1.sbc.net> (raw)
In-Reply-To: 95rpj5$gq7$1@nnrp1.deja.com
"Ted Dennison" <dennison@telepath.com> wrote in message
news:95rpj5$gq7$1@nnrp1.deja.com...
> In article <95q1fa$9e$1@usenet.rational.com>,
> "Mark Lundquist" <mark@rational.com> wrote:
> >
> > Ted Dennison <dennison@telepath.com> wrote in message
> > > Also, any instantiations of this generic will have to be done at the
> > > library level, since Limited_Controlled is declared at the library
> > > level, and types can't be declared at a lower level of scope than
> > > their parent types.
> ...
> > > (As a user, I hate that rule.)
> >
> > Do you hate it as much as what might happen if it weren't for the
> > rule? :-)
>
> I have to admit I'm a little unclear as to what nasty things could
> happen to me if I were allowed to declare a derived tagged type at a
> lower scope level than their parent type.
It is really very similar to the issue of an access value designating a
declared (aliased, on the stack) object. For example, one could have an
access-to-classwide value designating an allocated value of a type derived
within a nested declarative region. When that region "goes away", the type,
and hence, the primitive operations go away, and you don't want to try to
dispatch to them using that dangling pointer.
Consider:
package Graphics is
type Shape is tagged
record
...
end record;
type Any_Shape is access Shape'Class;
procedure Dispatch( O : in Shape );
end Graphics;
with Graphics; use Graphics;
procedure Illegal_Demo is
Global : Any_Shape;
procedure Bogus is
package Shapes is
type Circle is new Shape with ...
procedure Dispatch( C : in Circle );
end Shapes;
package body Shapes is
procedure Dispatch( C : in Circle ) is
begin
...
end Dispatch;
end Shapes;
begin
Global := new Shapes.Circle;
end Bogus;
begin
Bogus;
Dispatch( Global.all );
end Illegal_Demo;
Hoe this helps...
---
Patrick Rogers Consulting and Training in:
http://www.classwide.com Real-Time/OO Languages
progers@classwide.com Hard Deadline Schedulability Analysis
(281)648-3165 Software Fault Tolerance
next prev parent reply other threads:[~2001-02-07 18:52 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
[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 [this message]
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