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,9677a3433b89e25b X-Google-Attributes: gid103376,public From: Niklas Holsti Subject: Re: attributes in generic procedure Date: 1999/11/29 Message-ID: <3841CE51.862ACED3@icon.fi>#1/1 X-Deja-AN: 554229881 Content-Transfer-Encoding: 7bit References: <818esd$t6l$1@nnrp1.deja.com> <383DC78E.63A556E5@callnetuk.com> Content-Type: text/plain; charset=us-ascii X-Trace: read2.inet.fi 943835121 194.252.1.51 (Mon, 29 Nov 1999 02:25:21 EET) Organization: Space Systems Finland Ltd MIME-Version: 1.0 NNTP-Posting-Date: Mon, 29 Nov 1999 02:25:21 EET Newsgroups: comp.lang.ada Date: 1999-11-29T00:00:00+00:00 List-Id: Nick Roberts wrote: > > daelen@my-deja.com wrote: > > > > I would like to create a generic procedure as shown below which will only be > > used for scalar types. Does anybody have a hint how to accomplish this? > > > > generic > > type A_Type is private; > > ... > > end Update; > > The answer is simple: > > generic > type A_Type is (<>); > ... According to RM 12.5.2, this is a formal discrete type definition, not a formal scalar type definition. This means that it allows only enumeration and integer types, but not real types (3.2(3)). In fact, there is no formal_scalar_definition in the RM. I, too, would have liked to have one when I recently wrote a generic function to take the maximum value of a vector of some generic element type. The Max function needs only the attributes 'first and 'max, which exist for all scalar types, but different generic functions are needed for a discrete element type and a real element type, although the bodies of the two functions are identical. One can of course work around this by making 'first and 'max be additional generic formal parameters, instead of using type attributes, but it is a little messy. I don't know if it's worthwhile to consider adding a formal scalar class to Ada. It might be difficult for compilers that share generic code across instantiations Niklas Holsti Working at but not speaking for Space Systems Finland Ltd.