From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a71f8d92e1423f6 X-Google-Attributes: gid103376,public From: dommo1234@my-deja.com Subject: Re: Generic type parameters Date: 1999/06/15 Message-ID: <7k5t3l$pp9$1@nnrp1.deja.com>#1/1 X-Deja-AN: 489873004 References: <7k3ae5$stk$1@nnrp1.deja.com> X-Http-Proxy: 1.1 x43.deja.com:80 (Squid/1.1.22) for client 194.202.27.93 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Tue Jun 15 15:56:44 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Date: 1999-06-15T00:00:00+00:00 List-Id: In article , Matthew Heaney wrote: > > > I don't know about "neater," but you can create another generic package > in which to declare the access types, and import an instantiation of > that package as a generic formal package: > > generic > type TypeX is private; > package TypeX_Access_Types_G is > > type TypeX_A is access all TypeX; > > type TypeX_AC is access constant TypeX; > > end; > > with TypeX_Access_Types_G; > > generic > > with package TypeX_Access_Types is > new TypeX_Access_Types_G (<>); > > use TypeX_Access_Types; > > package Example is > > > > end; > I think this is quite neat, but having done some experimentation, I''ve hit another problem that seems to relate to accesibility levels, a subject that I find very confusing. Here's my test program :- generic type TypeX is private; package TestGeneric is type TypeX_A is access all TypeX; type TypeX_AC is access constant TypeX; end TestGeneric; with TestGeneric; generic type TypeX is private; package OtherGeneric is package TypeXAccessTypes is new TestGeneric(TypeX); use TypeXAccessTypes; type TestType is record variable: aliased TypeX; end record; function returnNonConst(aa: access TestType) return TypeX_A; end OtherGeneric; package body OtherGeneric is function returnNonConst(aa: access TestType) return TypeX_A is begin -- The following causes a Program_Error at runtime -- unless an Unchecked_Access is passed in!!! return aa.variable'Access; end returnNonConst; end OtherGeneric; with OtherGeneric; package OthGenInst is new OtherGeneric(Integer); with OthGenInst; use OthGenInst; procedure Main is testVar2: aliased TestType; begin returnNonConst(testVar2'Access).all := 6; -- ERROR! returnNonConst(testVar2'Unchecked_Access).all := 6; -- OK! end Main; Can someone explain exactly what accessibility levels for testVar2, tsetVar2.variable etc. are in the various scopes so I can understand the rules better ... Thanks, Dom. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.