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,effb80d4bb7716dd X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Wanted: Ada STL. Reward: Ada's Future Date: 1999/02/06 Message-ID: #1/1 X-Deja-AN: 441257244 Sender: matt@mheaney.ni.net References: <790f4q$3l@bgtnsc01.worldnet.att.net> <36B856E4.D921C1D@bton.ac.uk> <36BAEA8B.5B375A30@bton.ac.uk> NNTP-Posting-Date: Fri, 05 Feb 1999 21:11:04 PDT Newsgroups: comp.lang.ada Date: 1999-02-06T00:00:00+00:00 List-Id: Brian Rogoff writes: > Another strength of C++ is in automatic instantiation of generic > subprograms. This reduces the number of instantiations, and makes code a > lot more readable, IMO, in the same way that overloading properly used > makes code more readable. You can get some of this in Ada, by using default params for generic formal subprograms: generic type Item_Type is private; type Stack_Type is limited private; with procedure Push (Item : in Item_Type; On : in out Stack_Type) is <>; package GP is ...; If Push is directly visible at the point of instantiation, then you don't need to specify explicitly: package Item_Stacks is new Stacks (Item_Type); use Item_Stacks; package P is new GP (Item_Type, Stack_Type); Another, lesser-used technique is to provide default parameters by name: generic ... package GP is ... procedure Do_Nothing; generic with procedure Do_At_End_Of_Line is Do_Nothing; package GQ is ... end GQ; end GP; A client that doesn't need to do an end-of-line processing, doesn't need to say anything else in his instantiation: package Q is new P.GQ; Of course, he may want to do something different from the default: procedure Write_EOL; package Q is new P.GQ (Write_EOL);