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 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: Matthew Heaney Subject: Re: Generic type parameters Date: 1999/06/15 Message-ID: #1/1 X-Deja-AN: 489654936 References: <7k3ae5$stk$1@nnrp1.deja.com> NNTP-Posting-Date: Mon, 14 Jun 1999 17:55:08 PDT Newsgroups: comp.lang.ada Date: 1999-06-15T00:00:00+00:00 List-Id: On 14 Jun 1999 16:25, dommo1234@my-deja.com wrote: > generic > type TypeX is private; > package Example is > function One(..) return TypeX; > function Two(..) return TypeX_A; > function Three(..) return TypeX_AC; > end Example; > > ... where 'TypeX_A' needs to be "access all TypeX" > and 'TypeX_AC' needs to be "access constant TypeX". > > The problem is that if I delcare the two types 'TypeX_A' and 'TypeX_AC' > inside the generic, then any code containing variables that catch the > values of functions 'Two' and 'Threee' inside my generic must be of type > .Type_A etc. This is not very readable or convenient! > > The only (not so sensible) solution I can think of is provide the > generic with 3 formal parameters, ie. TypeX, TypeX_A and TypeX_AC .... > > Does anyone have a neater solution to this?? 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;