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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f7a9613bbc2bd8c9,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-10 07:22:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!news.tesion.net!newsfeed-zh.ip-plus.net!news.ip-plus.net!not-for-mail From: Thomas Wolf Newsgroups: comp.lang.ada Subject: Generic default parameters Date: Fri, 10 May 2002 16:22:50 +0200 Organization: --- Message-ID: Reply-To: t_wolf@angelfire.com NNTP-Posting-Host: pargate2.paranor.ch X-Trace: rex.ip-plus.net 1021040566 18319 195.65.4.190 (10 May 2002 14:22:46 GMT) X-Complaints-To: abuse@ip-plus.net NNTP-Posting-Date: Fri, 10 May 2002 14:22:46 +0000 (UTC) X-Newsreader: MicroPlanet Gravity v2.50 Xref: archiver1.google.com comp.lang.ada:23839 Date: 2002-05-10T16:22:50+02:00 List-Id: It seems I'm not alone with these ideas... so let's summarize and see if we can get a halfway decent proposal for the ARG out of the discussions: Ada 95 lacks features for: 1. specifying a default type for generic formal type parameters The idea would be to allow something like generic type Something is range <> := Natural; and if an instantiation does *not* supply an actual for 'Something', 'Natural' will be taken. 2. specifying a default for generic formal package parameters: generic with package X is new Y (<>) := Z; where Z of course would have to be an instantiation of Y. Or maybe even generic with package X is new Y (<>) := Y (Param1 => Default1, Param2 => Default2, ...); i.e., allow the default to be an anonymous instance? (I guess, the first variant is sufficient, and the second would only unnecessarily complicate matters.) 3. specify a default for a generic formal "in out" object: with System.Storage_Pools; generic type Something is private; Pool : in out System.Storage_Pools.Root_Storage_Pool'Class := Some_Default_Pool_Instance; package X is type Some_Access is access all Something; for Some_Access'Storage_Pool use Pool; ... 4. providing defaults in a generic renaming: generic type Something is private; package A is ... generic package B renames A (Something => Integer); or even generic type Something is range <> := Natural; package C is ... generic package D renames C (Something => Integer); 5. Linked to (3) above: some way to specify a storage pool that is equal to whatever pool the compiler would use if no "for Some_Access'Storage_Pool use ..." clause was present, i.e. a generic way to refer to the standard storage pool of a type without referring to the type. Something like generic type Something is private; Pool : in out System.Storage_Pools.Root_Storage_Pool'Class := <>; package X is type Some_Access is access all Something; for Some_Access'Storage_Pool use Pool; ... and if an instantiation provides an actual for 'Pool', that will be taken as the storage pool of type 'Some_Access', but if an instantiation doesn't provide an actual, 'Some_Access' will use a standard storage pool. Not sure if point (5) makes sense, especially since it would be useful only for storage pools, but make no sense at all for other types... Personally, I have encountered several occasions where I would have liked to have some (or all) of these features. They'd help a lot in writing general generics (:-) that still are simple to instantiate. Comments, anyone? Would these things be worth to consider for inclusion in the next Ada revision? -- ----------------------------------------------------------------- Thomas Wolf e-mail: t_wolf@angelfire.com