comp.lang.ada
 help / color / mirror / Atom feed
From: dmitry6243@my-deja.com
Subject: Re: controlled type in generic package?
Date: Fri, 09 Feb 2001 12:28:44 GMT
Date: 2001-02-09T12:28:44+00:00	[thread overview]
Message-ID: <960npn$ocb$1@nnrp1.deja.com> (raw)
In-Reply-To: f1c069.v1e.ln@skymaster.axlog.fr

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]

In article <f1c069.v1e.ln@skymaster.axlog.fr>,
  "Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr> wrote:
>
> <dmitry6243@my-deja.com> a �crit dans le message news:
95tpba$9va$1@nnrp1.deja.com...
> >[...]
> > >    procedure P is
> > >       type Child is new Parent with...;
> > >       procedure Proc (X : Child) is... end Proc;
> > >    begin
> > >       V := new Child;
> > >    end P;
> > >
> >
> > This is an issue of how dispatch tables are implemented and
> > maintained
> > at run-time. One could imagine a mechanism that would restore the
> > dispatch table, when a derived type goes away. The type tag could
> > be "redirected" to the base type tag, or the table slots
> > corresponding to the overriden methods could be restored etc. What
> > is really nasty, is that the semantic of V.Proc would depend on the
> > context.
> >
> No, you miss the point. A (dispatching) call to P.Proc could access
> P's local variables, but such variables would not exist at the
> time P.Proc is called.

No dispatch to P.Proc happens, if the dispatch table is corrected after
leaving P.Proc declaration scope (i.e. upon return from P). The
correction might be replacing address of P.Proc by address Pack.Proc.
Then V.Proc is dispatched to Pack.Proc.

Such approach has several drawbacks (starting from the necessity to have
dispatch dynamic tables). But I see no better way to allow local
overrides.

Another nasty thing with unlimited local overrides is that virtually
no expression involving methods will be static. If we write (this is
not Ada):

package MyNumbers is
   type MyNumber is tagged ...
   function "not" (X : MyNumber) return MyNumber;
   ...
end MyNumbers;

Then

procedure Foo is
   X : constant MyNumber := 1;     -- Static
   Y : constant MyNumber := not X; -- Not static!
begin
   ...
end Foo;

No matter the Y type tag is statically known, it cannot be static,
because "not" could be overriden at the call point of Foo!

--
Regards,
Dmitry Kazakov


Sent via Deja.com
http://www.deja.com/



  reply	other threads:[~2001-02-09 12:28 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
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 [this message]
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