In article <95sjs9$ral$1@wanadoo.fr>, "Jean-Pierre Rosen" wrote: > > "Ted Dennison" a �crit dans le message news: 95rpj5$gq7$1@nnrp1.deja.com... > > 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. > OK, let's go: > > package body Pack is > type Parent is tagged ...; > procedure Proc (X : Parent) is ... end Proc; > > type Ptr is access Parent'Class; > V : Ptr; > > procedure P is > type Child is new Parent with...; > procedure Proc (X : Child) is... end Proc; > begin > V := new Child; > end P; > > begin > P; > -- Now, V.all points to an object of type P.Child > -- We can call Proc (V.all) which will result in a dispatching call > to P.Proc, but P is out of scope at this point !!! 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. -- Regards, Dmitry Kazakov Sent via Deja.com http://www.deja.com/