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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f7a9613bbc2bd8c9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-10 12:27:38 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Generic default parameters Date: Fri, 10 May 2002 14:27:39 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:23868 Date: 2002-05-10T14:27:39-05:00 List-Id: Preben Randhol wrote in message ... >On Fri, 10 May 2002 16:22:50 +0200, Thomas Wolf wrote: >> >> 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. > >I actually like that Ada95 doesn't allow a default value, and I don't >understand what the gain is in a default value. Expecially not for >generic pacakges. If one want a default value why don't just do: > >package Some_Package is > new Some_Generic_Pacakge (Data_Type => Some_Default_Type); > >in a package and use this? The point of course is to provide defaults for some (not all) parameters, so the "package" you're talking about would have to be generic. The case that brought this up is something like: generic type Element_Type is private; type Count_Type is (<>) use Natural; package Lists is ... Generally, the default Count type is sufficient. But there may be occassions where some user-defined type would be valuable. A typical instantiation would look like: package My_List is new Element (Some_Record); To get that with a package, you'd have to have a generic package wrapper: generic type Element_Type is private; package List_with_Natural_Count is package List is new Lists (Element_Type, Natural); end List_with_Natural_Count; and then you would have complications in naming the items in the instantiation (especially if you do not want to use a "use clause" on the package). The net effect (either way) is to make it harder to create a general component that is also relatively easy to use. Randy.